Skip to content

Re-raise internal errors instead of swallowing#173

Draft
Liam-DeVoe wants to merge 13 commits intomainfrom
cell/c69bf879
Draft

Re-raise internal errors instead of swallowing#173
Liam-DeVoe wants to merge 13 commits intomainfrom
cell/c69bf879

Conversation

@Liam-DeVoe
Copy link
Copy Markdown
Member

@Liam-DeVoe Liam-DeVoe commented Apr 4, 2026

Claude-written description

Previously, when hegel-internal code panicked during test execution (e.g. invalid generator config like integers().min_value(100).max_value(10), or an unexpected server error response), the panic was caught by catch_unwind, treated as a test failure, and reported as "Property test failed: unknown" — completely losing the actual error. This follows the same pattern as Hypothesis's _execute_once_for_engine, which re-raises exceptions that originate from Hypothesis's own source files.

Now we check the panic location's file path against CARGO_MANIFEST_DIR to detect hegel-internal panics and propagate them immediately on the first test case — no shrinking, no wrapping. The error message includes the original source location and backtrace so users can trace where things went wrong.

Fixes #47.

When hegel-internal code panics during test execution (e.g., invalid
generator config, server protocol error), the panic was caught by
catch_unwind, treated as a test failure, and either lost entirely
("Property test failed: unknown") or unnecessarily shrunk.

Now we check the panic location against CARGO_MANIFEST_DIR to detect
hegel-internal panics and propagate them immediately with the original
error message and backtrace, following Hypothesis's pattern.
@Liam-DeVoe Liam-DeVoe marked this pull request as ready for review April 4, 2026 04:18
@Liam-DeVoe Liam-DeVoe marked this pull request as draft April 4, 2026 04:27
Liam-DeVoe and others added 9 commits April 4, 2026 00:55
Three fixes for CI failures:

1. Make thread ID optional in panic output regex: `(?: \(\d+\))?`
   Rust 1.86 doesn't include thread IDs in panic output, but nightly
   does. The regex now handles both.

2. Bump regex dev-dependency from "1.0" to "1.5" to avoid bugs in
   regex 1.0.0 with complex (?s) patterns in the minimal-versions CI
   job.

3. Add in-process test (test_internal_error_message) that exercises the
   internal error code path directly, providing coverage for the new
   InternalError handling in runner.rs. The subprocess-based tests
   (TempRustProject) don't contribute to coverage instrumentation.
Previously, is_hegel_file would treat any file existing under
CARGO_MANIFEST_DIR as hegel-internal, including test files. Paths like
tests/test_find_quality/../common/utils.rs resolved to tests/common/utils.rs
which exists in the crate, causing test panics (e.g. HEGEL_MINIMAL_FOUND)
to be re-raised as internal errors instead of treated as test failures.

Now the function normalizes ".." components and checks the path starts
with src/ or hegel-macros/src/, so only actual library source files are
considered internal.
- Add codepoints field to text conformance metrics (required by updated
  TextConformance validator)
- Add test for CurDir path component in is_hegel_file (coverage gap)
- Fix backtrace regex to handle generic params after ::draw on nightly
Kept main's version which removed the redundant `length` field
from Metrics, since it's derivable from codepoints.len().
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.

Re-raise internal errors instead of swallowing

1 participant