Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can build systems to be unittested?

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?

like image 807
xtofl Avatar asked Dec 27 '25 22:12

xtofl


1 Answers

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.

like image 138
Tom Howard Avatar answered Dec 30 '25 23:12

Tom Howard