2 # \brief BoostUnitTests build
4 ## \package senfscons.BoostUnitTests
5 # \brief Builder utilizing the <a href="http://www.boost.org/libs/test/doc/index.html">Boost.Test</a> unit-test framework
7 # The BoostUnitTests builder will build a unit-test executable using
9 # href="http://www.boost.org/libs/test/doc/index.html">Boost.Test</a>
10 # library. After building, the unit-test will be executed.
12 # This builder is used by the SENFSCons.Object() helper to build the
15 # \par Construction Envrionment Variables:
16 # <table class="senf">
17 # <tr><td>\c BOOSTTESTLIB</td><td>Name of the library to use, defaults to \c boost_unit_test_framework</td></tr>
18 # <tr><td>\c BOOSTTESTARGS</td><td>Command line arguments of the test, defaults to <tt>--build_info=yes --log_level=test_suite</tt></td></tr>
21 # \todo This is not really a builder. This should be rewritten as one
24 import SCons.Script.SConscript
29 def BoostUnitTests(env, target, objects, test_sources=None, LIBS = [], OBJECTS = [], DEPENDS = [], **kw):
30 path, name = os.path.split(target)
32 if type(test_sources) is not type([]):
33 test_sources = [ test_sources ]
36 testEnv = env.Copy(**kw)
37 testEnv.Prepend(LIBS = '$BOOSTTESTLIB')
38 testEnv.Prepend(LIBS = LIBS)
42 all_objects = objects + env.Object(test_sources) + OBJECTS
43 binName = os.path.join(path,'.' + name +'.bin')
44 testRunner = testEnv.Program(binName, all_objects)
45 stamp = os.path.join(path,'.' + os.path.splitext(name)[0]+'.stamp')
47 env.Depends(testRunner, DEPENDS)
48 return env.Command([ stamp ], testRunner,
49 [ '$SOURCE $BOOSTTESTARGS',
52 def dispatcher(*arg,**kw):
53 return BoostUnitTests(*arg,**kw)
56 env['BOOSTTESTLIB'] = 'boost_unit_test_framework'
57 env['BOOSTTESTARGS'] = [ '--build_info=yes', '--log_level=test_suite' ]
58 env.__class__.BoostUnitTests = dispatcher