Skip to content

Catch KeyboardInterrupt when aborting netlab test cleanup - #3720

Open
Sanjays2402 wants to merge 2 commits into
ipspace:devfrom
Sanjays2402:fix/test-cleanup-keyboardinterrupt
Open

Catch KeyboardInterrupt when aborting netlab test cleanup#3720
Sanjays2402 wants to merge 2 commits into
ipspace:devfrom
Sanjays2402:fix/test-cleanup-keyboardinterrupt

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #3696

Pressing CTRL/C at the Press RETURN to continue -> prompt in netlab test's cleanup step raised an uncaught KeyboardInterrupt and printed a Python traceback. The prompt now catches it and exits through log.fatal with a message noting the test directory was not cleaned up, matching how netlab install and strings.confirm already handle CTRL/C.

Regression test added in a new tests/test_cli.py (mocks input() to raise KeyboardInterrupt); it fails on the current code and passes with the fix. pytest -k 'error_cases or cli' is green and mypy -p netsim is unchanged.

This change was prepared with AI assistance; the regression test was run locally and fails without the fix.

Sanjays2402 and others added 2 commits July 30, 2026 04:43
When 'netlab test' fails, cleanup_force() prompts before running
'netlab down --cleanup --force'. Pressing CTRL/C at that prompt raised
an uncaught KeyboardInterrupt and printed a Python traceback.

The prompt now catches KeyboardInterrupt and exits through log.fatal
with a message stating the test directory was not cleaned up, matching
how netlab install and strings.confirm already handle CTRL/C.

Adds tests/test_cli.py with a regression test that mocks input() to
raise KeyboardInterrupt.

@ipspace ipspace left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a million. One less thing to do ;)

I removed the regression test -- the only tests we run on the CLI commands are the platform integration tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] netlab test command crashes on abort attempt

2 participants