CxxTest/cxxtest

SCons script fails with template CXXTEST_OPTS

Opened this issue · 0 comments

Hi,

if you specify a template, e.g. with
env['CXXTEST_OPTS'] = '--template=' + Dir('.').srcnode().abspath + '/src/tests/mpirunner.tpl'
and then use multiple test suites, e.g.
env.CxxTest(target='#/build/parallel_test_suite',source=['test1.t.h' ,'test2.t.h'])
the linker will fail because mutiple main() are defined.

The reason for this lies in lines 374-379 in build_tools/SCons/cxxtest.py:
deps.append(env.CxxTestCpp(headers.pop(0), *_kwargs))
deps.extend(
[env.CxxTestCpp(header, CXXTEST_RUNNER = 'none',
CXXTEST_ROOT_PART = '--part', *_kwargs)
for header in headers]
)
The "second" test suite gets the option cxxtest_runner='none' which prevents the generation of another main. If you use a template, however, cxxtest_runner has no effect and a main will be generated according to the template.

We fixed this in our project by adding CXXTEST_OPTS = ''. However, a better solution would be to filter --template from CXXTEST_OPTS and add CXXTEST_OPTS = filteredOpts.