Skip to content

Fix some test issues#135

Open
DRMacIver wants to merge 1 commit intomainfrom
fix/pre-existing-test-issues
Open

Fix some test issues#135
DRMacIver wants to merge 1 commit intomainfrom
fix/pre-existing-test-issues

Conversation

@DRMacIver
Copy link
Copy Markdown
Member

Fix two flaky/broken tests:

  • TempRustProject: PID-based temp target dirs to prevent parallel test binary races
  • test_output: accept both {closure#0} and {{closure}} backtrace formats (Rust 1.92 changed the stable format)

@DRMacIver DRMacIver force-pushed the fix/pre-existing-test-issues branch 2 times, most recently from 9170d76 to c4f7a3e Compare March 27, 2026 07:50
- TempRustProject: use PID-based temp target dirs to prevent parallel
  test binaries from racing on shared build cache
- test_output: accept both {closure#0} and {{closure}} backtrace formats

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@DRMacIver DRMacIver force-pushed the fix/pre-existing-test-issues branch from c4f7a3e to 813e535 Compare March 27, 2026 08:18
@DRMacIver DRMacIver changed the title Fix pre-existing test issues Fix some test issues Mar 27, 2026
@DRMacIver DRMacIver marked this pull request as ready for review March 27, 2026 09:16
Comment on lines 10 to 26

// cache build output from TempRustProject across tests. Compilation time is substantial
// (10+ seconds) and this lets us only incur that cost on the first test.
// Cache build output from TempRustProject across tests within the same process.
//
// We clear the dir at the start to ensure a fresh environment on each test run.
// Under coverage (CARGO_LLVM_COV=1), we reuse the main project's llvm-cov target
// dir so that subprocess builds share the same instrumented artifacts. This lets
// cargo-llvm-cov's report phase map subprocess profraw data back to source files.
// Cargo's internal file locks prevent corruption from concurrent access.
//
// Outside coverage, each test binary gets its own target dir (via PID) to avoid
// heavy lock contention when multiple test binaries build in parallel.
static SHARED_TARGET_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
let path = std::env::temp_dir().join("hegel-test-cargo-target");
if std::env::var("CARGO_LLVM_COV").is_ok() {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("target/llvm-cov-target");
return path;
}
let path = std::env::temp_dir().join(format!("hegel-test-cargo-target-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&path);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why have we changed from a shared target dir to mixing in pid outside of coverage? This lessens the benefit of a shared target dir for compilation times by a factor of n where n is the number of cores

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.

2 participants