【发布时间】:2021-07-05 13:28:09
【问题描述】:
我写了一个 C 代码。我想使用 makefile 对其进行测试,因为代码主要围绕命令行参数工作并返回退出代码,printf() 写出原因。 return 0; //SUCCESS 和 return 1; //FALIURE
我使用this 文章作为参考指南,以达到我的预期目的。
这是一个想法的结构。
MAKE = gcc
FILENAME = topcgpas.c
TARGET = topcgpas
compile:
$(MAKE) $(FILENAME) -o $(TARGET)
run: compile
./$(TARGET) students.csv a.csv
testAll: compile test1 test2 test3 test4 test5 test6
@echo "All done"
test1:
@echo "TEST: Incorrect number of arguments"
./$(TARGET) 1 2 3
test2:
@echo "TEST: Incorrect input/output filename"
./$(TARGET) no.csv output.csv
make testAll给我
gcc topcgpas.c -o topcgpas
TEST: Incorrect number of arguments
./topcgpas 1 2 3
Usage ./topcgpas <sourcecsv> <outputcsv>
make: *** [makefile:16: test1] Error 1
但是,据我了解,它应该完成所有测试的执行。
【问题讨论】:
-
@EugeneSh。是的,它部分回答了我的问题,但我想从输出中删除
make: *** [makefile:16: test1] Error 1