diff --git a/test_framework/runner.py b/test_framework/runner.py index d690f790..df86239b 100644 --- a/test_framework/runner.py +++ b/test_framework/runner.py @@ -241,7 +241,11 @@ def parse_arguments() -> argparse.Namespace: # if --check-setup is present, shouldn't have any other options if args.check_setup: ignored_args = [ - k for k, v in vars(args).items() if bool(v) and (k != "check_setup") + k + for k, v in vars(args).items() + if bool(v) + and (k != "check_setup") + and (k != "stage" or (k == "stage" and v != "run")) ] if ignored_args: warnings.warn( @@ -273,7 +277,6 @@ def parse_arguments() -> argparse.Namespace: warnings.warn("Option --no-coalescing has no impact on Part I & Part II tests") if args.expected_error_codes: - out_of_range = [str(i) for i in args.expected_error_codes if i < 1 or i > 255] if out_of_range: bad_codes = ", ".join(out_of_range) @@ -436,7 +439,10 @@ def main() -> int: """Main entry point for test runner""" args = parse_arguments() if args.check_setup: - return check_setup() + success = check_setup() + if success: + return 0 + return 1 compiler = Path(args.cc).resolve() diff --git a/test_framework/test_tests/test_toplevel.py b/test_framework/test_tests/test_toplevel.py index d15c300f..09849833 100644 --- a/test_framework/test_tests/test_toplevel.py +++ b/test_framework/test_tests/test_toplevel.py @@ -91,6 +91,27 @@ def get_failure_count(failure: subprocess.CalledProcessError) -> int: class TopLevelTest(unittest.TestCase): + def test_check_setup(self) -> None: + """Test the check-setup command""" + try: + check = run_test_script("./test_compiler --check-setup") + self.assertEqual(check.stdout, "All system requirements met!\n") + self.assertEqual(check.stderr, "") + except subprocess.CalledProcessError as err: + # Test should still pass if only problem is that GDB isn't installed (it isn't on Github's runners) + if ( + err.stdout.startswith( + "No debugger found. The test script doesn't require a debugger but you probably want one for, ya know, debugging." + ) + and err.stderr == "" + ): + # okay + return + # we found some other error + self.fail( + f"--check-setup option failed.\nstderr:\n{err.stderr}\nstdout:\n{err.stdout}" + ) + def test_one_chapter(self) -> None: """We can run tests for a single chapter with --latest-only""" expected_test_count = get_expected_test_count(chapters=[2])