Skip to content

Commit

Permalink
Merge pull request #34 from nlsandler/check-setup-fix
Browse files Browse the repository at this point in the history
Fix spurious check-setup warning
  • Loading branch information
nlsandler authored Jun 28, 2024
2 parents 7d4cba6 + 44f1033 commit 4901505
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test_framework/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down
21 changes: 21 additions & 0 deletions test_framework/test_tests/test_toplevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 4901505

Please sign in to comment.