Repository navigation
fix(test): make build work in Nix hermetic sandboxes (closes #1119) - #1120
Merged
Merged
Conversation
#1119) The integration test fixture in price_clobber_post_fetch.rs wrote an executable shell script with a #!/usr/bin/env bash shebang. In hermetic build sandboxes that don't expose /usr/bin (Nix in particular), the kernel's shebang resolution returns ENOENT, Command::spawn fails, ExternalCommandSource::fetch_price returns an Err, and the failure path silently logs to stderr while returning Ok(()) — so out.status.success() is true but stdout is empty. The _emits_duplicate_when_clobber_is_set test failed loudly because its expected output (a fresh price directive) was missing. The _skips_when_response_date_matches_existing test "passed" for the wrong reason: its expectation of zero output happened to match the empty-stdout failure mode. Both tests were actually broken — only one surfaced. Fix: stop writing a shell script and instead pass sh -c '<body>' directly via --source-cmd. Resolving sh through $PATH works on every Unix the test suite targets, including Nix's stdenv. Eliminates the need for chmod +x and removes the /usr/bin/env dependency. Verified against the three tests in the file (release profile) post-fix; all pass on x86_64-linux without /usr/bin/env reliance. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a hermetic build failure in the price_clobber_post_fetch integration tests by avoiding a generated script with a /usr/bin/env bash shebang.
Changes:
- Replaces the temporary executable shell script helper with an inline
sh -c--source-cmd. - Removes chmod/shebang-related setup and narrows
TempDirusage to the Linux-only cache test. - Updates comments to document the Nix-related failure mode.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
📊 Benchmark Results
vs main branch (2026-05-15)
What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
Two #[should_panic] tests in rustledger-validate target the debug_assert! calls in ValidationSession::check_phase_ordering. Since debug_assert! is a no-op in release builds, the tests fail under cargo test --release with note panic-as-expected — which is exactly what Nix package builds via crane do. Surfaced while verifying the #1119 fix with a real nix build: the sandbox failed checkPhase on these two tests after the primary /usr/bin/env-shebang fix made everything else pass. The phase-ordering check still works correctly in release builds (it no-ops and returns false instead of panicking) — documented on ValidationSession. Only the panic-assertion test is debug-only. Verified: 71 passes in debug (tests included), 69 in release (gated out), nix build .#rustledger green end-to-end. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
robcohen
added a commit
that referenced
this pull request
May 15, 2026
Bumps the workspace from 0.14.1 to 0.15.0. Minor-version bump per SemVer because 0.14.2..0.15.0 ships PR #1116, which is a breaking API change for downstream consumers: * `rustledger_validate` — removed the `validate()`, `validate_with_options()`, `validate_with_today()`, and the two spanned variants. Replaced with `ValidationSession::new(opts). run_phase(_, Phase::Early, today).run_phase(_, Phase::Late, today). finalize()`. * `rustledger_plugin_types` — `PluginOutput.directives: Vec<DirectiveWrapper>` replaced with `ops: Vec<PluginOp>` where `PluginOp { Keep(usize) | Modify(usize, DirectiveWrapper) | Insert(DirectiveWrapper) | Delete(usize) }`. The wrapper round-trip's span-fidelity loss is now eliminated by construction. * `rustledger_plugin::NativePlugin` — new `is_synth()` trait method for self-classifying plugins as pre-booking synthesizers. * `rustledger_loader` — new `PluginPass { PreBookingSynth | PostBooking | All }` enum; `run_plugins` takes a `pass` parameter. `run_booking` returns `(Vec<Spanned<Directive>>, Vec<Spanned<Directive>>)` partitioned into (booked, failed) instead of `Vec<usize>` of failed indices. * `rustledger_booking` — `INTERPOLATED_MARKER` const removed. Plus the v0.14.1..v0.15.0 fix train: pad multi-currency / future-date regressions, duplicate-Open suppression across five plugins, plugin-error source-location propagation, `--clobber` post-fetch dedup hardening (#1120 / #1119) and the `cfg(debug_assertions)` gate on the should-panic phase-ordering tests so Nix package builds via `cargo test --release` pass. # Surface coverage (per RELEASING.md) * Workspace `Cargo.toml`: `[workspace.package].version` + 10 `[workspace.dependencies]` path-pinned crates. * 14 crate `Cargo.toml` files. * `Cargo.lock` regenerated via `cargo check --workspace`. * `packages/mcp-server/package.json`: `version` and the `@rustledger/wasm` dep pin. * `packaging/rpm/rustledger.spec`: `Version`, `Source0` URL, and `%setup -n rustledger-X.Y.Z` directory. `BuildRequires: rust >= 1.94` already matches the workspace MSRV — no change. # Pre-flight smoke checks * `cargo check --workspace --all-features --all-targets` — clean. * `cd packages/mcp-server && npm ci && npm run build` — clean (temporarily reverted `@rustledger/wasm` to `^0.14.1` during the build since `^0.15.0` isn't on npm yet; restored to `^0.15.0` before committing). * `cd crates/rustledger-wasm && wasm-pack build --target web --release` — clean. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1119.
Two Nix-sandbox / release-mode build issues, both surfaced by hermetic-sandbox testing.
1.
/usr/bin/envshebang in test stubcrates/rustledger/tests/price_clobber_post_fetch.rswrote a shell script with#!/usr/bin/env bash. Hermetic sandboxes that don't expose/usr/bin— Nix in particular — fail kernel shebang resolution:Command::spawnreturns ENOENT,ExternalCommandSource::fetch_pricereturnsErr, andrun_with_external_commandsilently logs to stderr while returningOk(()). Net effect: exit code 0 + empty stdout.That single failure mode produced asymmetric behavior:
clobber_post_fetch_emits_duplicate_when_clobber_is_set— expects non-empty stdout. Fails on Nix (the symptom in [Bug]: Doesn't build on aarch64-linux when used with Nix #1119).clobber_post_fetch_skips_when_response_date_matches_existing— expects zeroprice AAPLlines. Passes for the wrong reason (empty stdout matches its zero-count expectation).Fix. Pass
sh -c '<body>'directly via--source-cmdinstead of writing an executable shell script. Resolves through$PATH(Nix stdenv providessh); no/usr/bin/env, nochmod, no shebang.2.
#[should_panic]ondebug_assert!paths in release buildscrates/rustledger-validate/src/lib.rshad two#[should_panic]tests targetingdebug_assert!calls inValidationSession::check_phase_ordering.debug_assert!is a no-op in release builds, so the tests fail undercargo test --releasewith "test did not panic as expected". Nix package builds (via crane) compile with--release, so they hit this.Fix. Gate both tests on
#[cfg(debug_assertions)]. The phase-ordering check still works correctly in release (it returnsfalseand no-ops the misuse, as documented onValidationSession); only the panic-assertion test is debug-only.Deeper verification
In addition to running the failing test directly:
unshare --user --map-root-user --mount sh -c "mount --bind /tmp /usr ..."— same panic, same stack trace as the issue report.price_clobber_post_fetchtests pass.bean_price_compat.rsuses the same pattern but skips entirely whenbean-priceisn't on PATH (which it isn't in the Nix sandbox), so it never reaches the stub-script code.nix build .#rustledgerend-to-end — checkPhase passes, all tests + doctests green, binary builds and installs.How to test
Verification
cargo test --workspace --all-featuresclean (debug).cargo test --workspace --all-features --releaseclean.cargo clippy -p rustledger --tests -- -D warningsclean.price_clobber_post_fetchtests pass.nix build .#rustledger --no-link --print-build-logs— full checkPhase passes, binary builds.🤖 Generated with Claude Code