Skip to content

Commit

Permalink
Fix #276
Browse files Browse the repository at this point in the history
  • Loading branch information
brettviren committed Feb 14, 2024
1 parent 2cbba27 commit 23a439c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
30 changes: 17 additions & 13 deletions waft/smplpkgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ def __init__(self, bld, uses):
# fixme: ugly layer-busting hack.
self.script_environ['.bats'] = dict(BATS_LIB_PATH=bld.path.parent.find_dir("test").abspath())

if not self.bld.env.TESTS:
debug("smplpkgs: tests suppressed for " + self.bld.path.name)
return
# fixme: want to still build but just not run tests if --tests is omitted....
# if not self.bld.env.TESTS:
# debug("smplpkgs: tests suppressed for " + self.bld.path.name)
# return
debug(f"smplpkgs: test status: {self.bld.env.TESTS}")

for group in test_group_sequence:
self.do_group(group)
Expand All @@ -174,17 +176,21 @@ def __init__(self, bld, uses):

def do_group(self, group):
self.bld.cycle_group("testing_"+group)
features = "" if group == "check" else "test"
features = ""
if group in ("atomic",) and self.bld.env.TESTS:
features = "test" # run as unit test

prefixes = [group]
prefixes += self.extra_prefixes.get(group, [])

debug(f'tests: group "{group}" with features "{features}" and prefixes "{prefixes}"')

for prefix in prefixes:

for ext in self.compiled_extensions:
pat = self.source_glob(prefix, ext)
for one in self.bld.path.ant_glob(pat):
debug("tests: (%s) %s" %(features, one))
debug(f'tests: ({features}) source: "{one}"')
self.program(one, features)

if group == "check":
Expand All @@ -199,8 +205,8 @@ def do_group(self, group):


def __enter__(self):
if not self.bld.env.TESTS:
debug("smplpkgs: variant checks will not be built nor run for " + self.bld.path.name)
# if not self.bld.env.TESTS:
# debug("smplpkgs: variant checks will not be built nor run for " + self.bld.path.name)
return self

def __exit__(self, exc_type, exc_value, exc_traceback):
Expand Down Expand Up @@ -246,11 +252,9 @@ def nodify_declare(self, name_or_node, path=None):
def program(self, source, features=""):
'''Compile a C++ program to use in validation.
Add "test" as a feature to also run as a unit test.
'''
if not self.bld.env.TESTS:
return
# if not self.bld.env.TESTS:
# return
features = ["cxx","cxxprogram"] + to_list(features)
rpath = self.bld.get_rpath(self.uses) # fixme
source = self.nodify_resource(source)
Expand Down Expand Up @@ -306,8 +310,8 @@ def script(self, source):

def rule(self, rule, source="", target="", **kwds):
'Simple wrapper for arbitrary rule'
if not self.bld.env.TESTS:
return
# if not self.bld.env.TESTS:
# return
self.bld(rule=rule, source=source, target=target, **kwds)


Expand Down
4 changes: 2 additions & 2 deletions waft/wcb_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def make_interpreted_test(self):
self.ut_env = env
else:
self.ut_env = dict(os.environ)
Logs.debug("wut: bats lib path: " + self.ut_env.get("BATS_LIB_PATH", "none"))

paths = getattr(self, 'test_scripts_paths', {})
for (k,v) in paths.items():
Expand Down Expand Up @@ -321,7 +320,6 @@ def options(opt):
"""
Provide the ``--alltests``, ``--notests`` and ``--testcmd`` command-line options.
"""

opt.add_option('--tests', default=None, action='store_true',
help="Activate tests [default: off]")
opt.add_option('--test-duration', type="float", action='store',
Expand All @@ -343,13 +341,15 @@ def options(opt):
opt.add_option('--dump-test-scripts', action='store_true', default=False,
help='Create python scripts to help debug tests', dest='dump_test_scripts')


def intern_test_options(ctx, force=False):
'''
Set ctx.env from options if they are given or forced.
'''

if force or ctx.options.tests is not None:
ctx.env.TESTS = bool(ctx.options.tests)
Logs.debug(f'wut: tests:{ctx.options.tests} TESTS:{ctx.env.TESTS}')

if force or ctx.options.test_duration is not None:
ctx.env.TEST_DURATION = ctx.options.test_duration
Expand Down

0 comments on commit 23a439c

Please sign in to comment.