When you're tinkering with e.g. Make, or ant, or any other build tool, you're actually writing code.
Why is there no 'MUnit' or 'ANTUnit' to test these pieces of code? It makes sense to do so, for any bug in your project build system causes huge delays and frustration to the people who use it.
An example (note: this will probably not even work - untested, and that's not my focus either here):
#makefile v0
all: main.out
main.out: main.o x.o y.o
g++ $^ -o main.out
%.o: %.cpp
g++ -Wall $?
But now I want my object files in a separate build folder:
#makefile v1
all: main.out
main.out: $(addprefix build/,main.o x.o y.o)
g++ $^ -o main.out
build/%o: %.cpp
g++ Wall $< -o $@
Oh yes! that works! Commit! Commit!
(but... the Continuous Integration server has no 'build' folder yet...)
Oh noooo... the team's build failed... I'm to blame... Stupid!
It would be great to be able to specify a mock project, a mock folder-structure, and then call make all, and verify that main.out is there (and can be run)
So here the question:
What are my options to 'unittest' my make scripts? Am I doomed to write a gazillion test-shell-scripts, or does something exist already?
If you are using Ant, then there is AntUnit. I use it and it works.
I'm not aware of and cannot find a unit testing framework for Make. You could consider creating your own.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With