Skip to content

Detect panics early in test framework Output construction#1541

Open
Sim-hu wants to merge 4 commits intotrifectatechfoundation:mainfrom
Sim-hu:fix/detect-panic-in-tests
Open

Detect panics early in test framework Output construction#1541
Sim-hu wants to merge 4 commits intotrifectatechfoundation:mainfrom
Sim-hu:fix/detect-panic-in-tests

Conversation

@Sim-hu
Copy link
Copy Markdown

@Sim-hu Sim-hu commented Apr 7, 2026

Closes #1375

This adds automatic panic detection when constructing Output from process::Output in the test framework. Instead of silently succeeding when a tested program panics, the test now fails immediately with a clear message.

Two checks are added in TryFrom<process::Output>:

  • Exit code 101 — Rust uses this as the default exit code when a thread panics. If the process exited with code 101, the test fails.
  • "panicked" in stderr — Rust panic output contains the word "panicked" (e.g. thread 'main' panicked at ...). If stderr contains this, the test fails regardless of exit code.

Both checks run before the Output is returned, so any panic is caught at the earliest possible point rather than relying on individual tests to check for it manually.

Sim-hu added 2 commits April 7, 2026 15:40
Add early panic detection in TryFrom<process::Output> for Output:
- Check for exit code 101 (Rust's default panic exit code)
- Check for "panicked" in stderr output

Closes trifectatechfoundation#1375
}

if stderr.contains("panicked") {
panic!("program panicked\nstdout:\n{stdout}\n\nstderr:\n{stderr}");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
panic!("program panicked\nstdout:\n{stdout}\n\nstderr:\n{stderr}");
panic!("program panicked with {}\nstdout:\n{stdout}\n\nstderr:\n{stderr}", output.status);

for both panics and then it should be fine to merge both ifs together.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Collapsed the two checks into a single condition and switched both cases to the same panic message with output.status in e60c882.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check that we never panic in the test framework

3 participants