| 1 |
env = Environment() |
| 2 |
|
| 3 |
# Add the cgreen headers to the include path |
| 4 |
env.Append(CPPPATH=['../../include', ]) |
| 5 |
|
| 6 |
# Build the cgreen library |
| 7 |
cgreendir = '../../src/' |
| 8 |
cgreenfiles = """unit.c messaging.c breadcrumb.c reporter.c |
| 9 |
assertions.c vector.c mocks.c constraint.c |
| 10 |
parameters.c text_reporter.c""".split() |
| 11 |
cgreensources = ['../../src/'+f for f in cgreenfiles] |
| 12 |
cgreenlib = env.StaticLibrary('cgreen', cgreensources) |
| 13 |
|
| 14 |
#Build our code to be tested |
| 15 |
env.Append(CPPPATH=['include']) |
| 16 |
mainlib = env.StaticLibrary('main', env.Glob('src/*.c')) |
| 17 |
|
| 18 |
for test in env.Glob('tests/*.c'): |
| 19 |
testprog = env.Program(test, LIBS=[cgreenlib, mainlib]) |
| 20 |
|
| 21 |
# This is a nasty little hack here. |
| 22 |
# We run the test twice, the first time is so we can see the output on the |
| 23 |
# console, and get the results logged. Unfortunately it will not cause the |
| 24 |
# build to stop on test failures since the result of the command is the |
| 25 |
# return value of tee, not the tests. So we run it again to catch the |
| 26 |
# possibly failed return value ... those tests better be repeatable! |
| 27 |
env.Command(testprog[0].path+'.results', testprog, |
| 28 |
'$SOURCE 2>&1 | tee $TARGET') |
| 29 |
env.Command(testprog[0].path+'.results_', testprog, |
| 30 |
'$SOURCE > $TARGET 2>&1 ') |
| 31 |
|