From 91ffb33c8406c062677421f1b97bb5cb653f3d63 Mon Sep 17 00:00:00 2001 From: vjackson725 Date: Sat, 18 Apr 2020 14:36:44 +1000 Subject: [PATCH] tests: fix run-test-suite when phases don't exist see #362 --- cogent/tests/run-test-suite.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cogent/tests/run-test-suite.py b/cogent/tests/run-test-suite.py index 64dfb119b..552d33ac1 100755 --- a/cogent/tests/run-test-suite.py +++ b/cogent/tests/run-test-suite.py @@ -30,7 +30,7 @@ def check_import(name): importlib.import_module(name) return True except ImportError as exc: - print("Dependancy module '{}' not installed - please install via pip3".format(name)) + print("Dependency module '{}' not installed - please install via pip3".format(name)) return False @@ -330,7 +330,11 @@ def run_tests(self, context, tests): try: results.append( self.run_phase(context, f, context.phases[phasename], test) ) except KeyError: - raise PreconditionViolation("bad phase: {}".format(phasename)) + results.append( TestResult( + ("error", "phase not found: {}\n".format(phasename), test['expected_result']), + f, + test['test_name'] + )) print() return results @@ -418,8 +422,11 @@ def main(): print("error: could not find the cogent compiler at '{}'".format(cogent)) sys.exit(1) - files = Path(args.phase_dir).glob("*.sh") - phases = dict(map(lambda p: (p.stem,Phase(p)), files)) + if Path(args.phase_dir).exists(): + files = Path(args.phase_dir).glob("*.sh") + phases = dict(map(lambda p: (p.stem,Phase(p)), files)) + else: + phases = dict() context = TestContext(repo, cogent, TEST_DIST_DIR, TEST_SCRIPT_DIR, phases)