我写了一个C代码。我想使用makefile对其进行测试,因为代码主要围绕命令行参数工作并返回退出代码并printf()写入原因。return 0; //SUCCESS和return 1; //FALIURE
我将这篇文章用作我预期目的的参考指南。
这是一个想法的结构。
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
但是,据我了解,它应该完成所有测试的执行。