Skip to content

Commit

Permalink
build: allow toggling benchmark/integration/unit tests independently
Browse files Browse the repository at this point in the history
Change-Id: I88f7816c97a9884f328bf05b6c7e47b2e918ccf0
  • Loading branch information
Pesa committed Feb 25, 2024
1 parent 682b2af commit 906dde5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tests/benchmarks/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ def build(bld):
bld.program(name=f'test-{name}',
target=name,
source=[test],
use='tests-common',
use='BOOST_TESTS ndn-cxx',
install_path=None)
6 changes: 3 additions & 3 deletions tests/unit/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
top = '../..'

def build(bld):
tmpdir = 'UNIT_TESTS_TMPDIR="%s"' % bld.bldnode.make_node('tmp-files')
tmpdir = 'UNIT_TESTS_TMPDIR="%s"' % bld.bldnode.make_node('tests-tmp')

# unit test objects
srcFiles = bld.path.ant_glob('**/*.cpp',
excl=['main.cpp',
'**/*-osx.t.cpp',
'**/*-sqlite3.t.cpp'])

if bld.env['HAVE_OSX_FRAMEWORKS']:
if bld.env.HAVE_OSX_FRAMEWORKS:
srcFiles += bld.path.ant_glob('**/*-osx.t.cpp')

# In case we want to make it optional later
srcFiles += bld.path.ant_glob('**/*-sqlite3.t.cpp')

# unit test objects
bld.objects(
target='unit-tests-objects',
source=srcFiles,
Expand Down
25 changes: 15 additions & 10 deletions tests/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
top = '..'

def build(bld):
# common objects that can be shared among all tests
bld.objects(
target='tests-common',
source=bld.path.ant_glob('*.cpp'),
features='pch',
headers='tests-pch.hpp',
use='BOOST_TESTS ndn-cxx')
if bld.env.WITH_INTEGRATION_TESTS or bld.env.WITH_UNIT_TESTS:
bld.objects(
target='tests-common',
source=bld.path.ant_glob('*.cpp'),
features='pch',
headers='tests-pch.hpp',
use='BOOST_TESTS ndn-cxx')

bld.recurse('benchmarks')
bld.recurse('integration')
bld.recurse('unit')
if bld.env.WITH_BENCHMARKS:
bld.recurse('benchmarks')

if bld.env.WITH_INTEGRATION_TESTS:
bld.recurse('integration')

if bld.env.WITH_UNIT_TESTS:
bld.recurse('unit')
19 changes: 13 additions & 6 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ def options(opt):
help='Build examples')

opt.add_option('--with-tests', action='store_true', default=False,
help='Build tests')
help='Build all tests (benchmarks, integration tests, unit tests)')
opt.add_option('--with-benchmarks', action='store_true', default=False,
help='Build benchmarks')
opt.add_option('--with-integration-tests', action='store_true', default=False,
help='Build integration tests')
opt.add_option('--with-unit-tests', action='store_true', default=False,
help='Build unit tests')

opt.add_option('--without-tools', action='store_false', default=True, dest='with_tools',
help='Do not build tools')
Expand Down Expand Up @@ -76,7 +82,9 @@ def configure(conf):
'doxygen', 'sphinx_build'])

conf.env.WITH_EXAMPLES = conf.options.with_examples
conf.env.WITH_TESTS = conf.options.with_tests
conf.env.WITH_BENCHMARKS = conf.options.with_benchmarks or conf.options.with_tests
conf.env.WITH_INTEGRATION_TESTS = conf.options.with_integration_tests or conf.options.with_tests
conf.env.WITH_UNIT_TESTS = conf.options.with_unit_tests or conf.options.with_tests
conf.env.WITH_TOOLS = conf.options.with_tools

conf.find_program('dot', mandatory=False)
Expand Down Expand Up @@ -134,7 +142,7 @@ def configure(conf):

conf.check_boost(lib=boost_libs, mt=True)

if conf.env.WITH_TESTS:
if any((conf.env.WITH_BENCHMARKS, conf.env.WITH_INTEGRATION_TESTS, conf.env.WITH_UNIT_TESTS)):
conf.check_boost(lib='unit_test_framework', mt=True, uselib_store='BOOST_TESTS')

if conf.env.WITH_TOOLS:
Expand All @@ -153,7 +161,7 @@ def configure(conf):
conf.env.prepend_value('STLIBPATH', ['.'])

conf.define_cond('HAVE_STACKTRACE', conf.env.HAVE_STACKTRACE)
conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS)
conf.define_cond('HAVE_TESTS', conf.env.WITH_INTEGRATION_TESTS or conf.env.WITH_UNIT_TESTS)
conf.define_cond('WITH_OSX_KEYCHAIN', conf.env.HAVE_OSX_FRAMEWORKS and conf.options.with_osx_keychain)
conf.define_cond('DISABLE_SQLITE3_FS_LOCKING', not conf.options.with_sqlite_locking)
conf.define('SYSCONFDIR', conf.env.SYSCONFDIR)
Expand Down Expand Up @@ -227,8 +235,7 @@ def build(bld):
name='ndn-cxx-static' if bld.env.enable_shared else 'ndn-cxx',
**libndn_cxx)

if bld.env.WITH_TESTS:
bld.recurse('tests')
bld.recurse('tests')

if bld.env.WITH_TOOLS:
bld.recurse('tools')
Expand Down

0 comments on commit 906dde5

Please sign in to comment.