代码拉取完成,页面将自动刷新
同步操作将从 徐堃元/Class-test 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# Makefile for C language exercise project
# Define the directory where the exercise files are stored
EXERCISE_DIR = ./exercises
# Define the test directory
TEST_DIR = ./test
# Define the build directory
BUILD_DIR = ./build
# Ensure the test and build directories exist
$(shell mkdir -p $(TEST_DIR) $(BUILD_DIR))
# Define the list of exercises
EXERCISES = $(wildcard $(EXERCISE_DIR)/*.c)
# Define the list of executables
EXECUTABLES = $(patsubst $(EXERCISE_DIR)/%.c, $(BUILD_DIR)/%, $(EXERCISES))
# Default target: build all executables
all: $(EXECUTABLES) clean
# Build rule for each executable
$(BUILD_DIR)/%: $(EXERCISE_DIR)/%.c
gcc -o $@ $<
# Clean rule to remove all executables and object files
clean:
rm -f $(EXECUTABLES) $(BUILD_DIR)/*.o
# Generate test cases rule
generate-test-cases: $(EXECUTABLES)
@for exe in $(EXECUTABLES); do \
./$$exe > $(TEST_DIR)/$$(basename $$exe).out; \
done
@$(MAKE) clean
# Test rule to compare output with expected results
test-output: $(EXECUTABLES)
@for exe in $(EXECUTABLES); do \
exercise_name=$$(basename $$exe); \
expected=$$(cat $(TEST_DIR)/$${exercise_name}.out); \
actual=$$($$exe); \
if [ "$$expected" = "$$actual" ]; then \
echo "Test for $${exercise_name} passed."; \
else \
echo "Test for $${exercise_name} failed."; \
echo "Expected:"; echo "$$expected"; \
echo "Actual:"; echo "$$actual"; \
fi; \
done
@$(MAKE) clean
# New target to save test results and count pass rate in JSON format
save-test-results: $(EXECUTABLES)
@total=0; \
passed=0; \
> $(BUILD_DIR)/test_results.json; \
for exe in $(EXECUTABLES); do \
exercise_name=$$(basename $$exe); \
expected=$$(cat $(TEST_DIR)/$${exercise_name}.out); \
actual=$$($$exe); \
total=$$((total+1)); \
if [ "$$expected" = "$$actual" ]; then \
passed=$$((passed+1)); \
fi; \
done; \
echo "{\"channel\": \"gitee\",\"courseId\": 1558,\"ext\": \"aaa\",\"name\": \"\",\"score\": $$passed,\"totalScore\": 100}" > $(BUILD_DIR)/test_results.json
@$(MAKE) clean
.PHONY: all clean generate-test-cases test-output save-test-results
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。