I am writing some C++ library, and I already use some CI (Continuous Integration) process, to make sure the features work. The build is makefile-based, so the CI script holds a make test
line. That target will run the automated tests (say, using Catch), and build passes only if it succeeds.
The good practices mandates that a wrong usage of the library by user code should preferably trigger a compile error, instead of a run-time error. So I included lots of static checking.
However, I want to make sure in my automated testing process that this is really the case (that user code using the library erroneously will fail to build).
So I put up a folder holding several .cpp files, each demonstrating an incorrect usage of the library, thus each of them should fail to build.
My problem is that if I add a new target in my makefile to build these, it will return after first failure.
What I want to do is make sure that all these files fail to build, and return 0 only in that case.
How can I write a target that performs this ?
Some (not working) code, that will return after first failure.
SRC_FILES := $(wildcard *.cpp)
OBJ_FILES := $(patsubst %.cpp, %.o, $(SRC_FILES))
all: $(OBJ_FILES)
@echo "done"
%.o: %.cpp
$(CXX) -o $@ -c $<
If I basically ignore the failures (prepending line with -
), I won't be able to check that all of the files are incorrect.
Aucun commentaire:
Enregistrer un commentaire