1 Star 0 Fork 168

lsong/2024-exercises-stage-1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Makefile 2.25 KB
一键复制 编辑 原始数据 按行查看 历史
徐堃元 提交于 2024-06-03 23:50 . update gitee workflow and readme
AUX_DIR := aux
BUILD_DIR := build
SRC_DIR := src
RESULT_DIR := result
TEST_DIR := test
CC ?= gcc
CFLAGS = -std=c11 -Wall -Wextra -Wpedantic -Werror -g
LDFLAGS = -Wl,--as-needed -Wl,--no-undefined -fsanitize=address -fsanitize=undefined
EXERCISES := $(shell find $(SRC_DIR) -type d -name 'exercise-*' -exec basename {} \;)
all: $(EXERCISES)
$(EXERCISES):
@mkdir -p $(abspath $(BUILD_DIR))/$(notdir $@)
$(MAKE) -C $(SRC_DIR)/$@ OUTPUT_DIR=$(abspath $(BUILD_DIR))/$(notdir $@) || true
test: $(RESULT_DIR) $(EXERCISES:%=test-%) report generate_json_report
test-%: $(BUILD_DIR)/%
@mkdir -p $(RESULT_DIR)/$*
@echo "Running tests for $*"
@$(TEST_DIR)/$*/test.sh $(BUILD_DIR)/$*/$* && touch $(RESULT_DIR)/$*/$*.pass || touch $(RESULT_DIR)/$*/$*.fail
$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)
$(RESULT_DIR):
@mkdir -p $(RESULT_DIR)
report:
@echo "Generating test report..."
@total=$$(find $(RESULT_DIR) -type f -name '*.pass' -o -name '*.fail' | wc -l); \
success=$$(find $(RESULT_DIR) -type f -name '*.pass' | wc -l); \
failed=$$(find $(RESULT_DIR) -type f -name '*.fail' | wc -l); \
echo "Total tests: $$total"; \
echo "Success: $$success"; \
echo "Failed: $$failed"; \
echo "Success tests:"; \
find $(RESULT_DIR) -type f -name '*.pass' -exec basename {} .pass \; | sed 's/^/ /'; \
echo "Failed tests:"; \
find $(RESULT_DIR) -type f -name '*.fail' -exec basename {} .fail \; | sed 's/^/ /'
generate_json_report:
@echo "Generating JSON report..."
@success=$$(find $(RESULT_DIR) -type f -name '*.pass' | wc -l); \
score=$$((success * 5)); \
total_score=100; \
channel="gitee"; \
course_id=1546; \
ext="aaa"; \
name=""; \
echo '{' > $(RESULT_DIR)/report.json; \
echo ' "channel": "'$$channel'"'',' >> $(RESULT_DIR)/report.json; \
echo ' "courseId": ' $$course_id',' >> $(RESULT_DIR)/report.json; \
echo ' "ext": "'$$ext'"'',' >> $(RESULT_DIR)/report.json; \
echo ' "name": "'$$name'"'',' >> $(RESULT_DIR)/report.json; \
echo ' "score": ' $$score',' >> $(RESULT_DIR)/report.json; \
echo ' "totalScore": ' $$total_score >> $(RESULT_DIR)/report.json; \
echo '}' >> $(RESULT_DIR)/report.json;
clean:
for dir in $(EXERCISES); do \
$(MAKE) -C $$dir clean; \
done
rm -rf $(BUILD_DIR) $(RESULT_DIR)
.PHONY: all clean $(EXERCISES) report generate_json_report
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/li-lisong-1/2024-exercises-stage-1.git
git@gitee.com:li-lisong-1/2024-exercises-stage-1.git
li-lisong-1
2024-exercises-stage-1
2024-exercises-stage-1
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385