test: fix batch-2 regression tests linking prebuilt runtime archive (post-#5398)#5403
test: fix batch-2 regression tests linking prebuilt runtime archive (post-#5398)#5403proggeramlug wants to merge 2 commits into
Conversation
The five batch-2 regression tests set PERRY_NO_AUTO_OPTIMIZE=1, which links the prebuilt libperry_runtime.a instead of rebuilding a per-app runtime. Under `cargo test` the staticlib crate-type is not produced as a side effect of building the test binary (only the rlib is), so CI failed with "Could not find libperry_runtime.a". Add the ensure_runtime_archive() helper (cargo build -p perry-runtime, once) and pass PERRY_RUNTIME_DIR=target/debug to the compile, matching the existing convention in module_import_forms.rs and the issue_5xxx no-auto-optimize tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe regression test harness gains explicit ChangesPerry Runtime Archive Linking in Regression Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/perry/tests/functional_batch2_regressions.rs`:
- Around line 35-40: The `target_debug_dir()` function preserves relative paths
from the `CARGO_TARGET_DIR` environment variable as relative, which causes
incorrect resolution when `perry compile` runs with a different current
directory at line 93. Convert the `CARGO_TARGET_DIR` value to an absolute path
before joining it with "debug" by using canonicalize or a similar method to
ensure the path always resolves to the correct location regardless of the
current working directory context.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 12e9f4f6-9ef5-457c-8be4-d45850a02f93
📒 Files selected for processing (1)
crates/perry/tests/functional_batch2_regressions.rs
| fn target_debug_dir() -> PathBuf { | ||
| std::env::var_os("CARGO_TARGET_DIR") | ||
| .map(PathBuf::from) | ||
| .unwrap_or_else(|| workspace_root().join("target")) | ||
| .join("debug") | ||
| } |
There was a problem hiding this comment.
Resolve CARGO_TARGET_DIR to an absolute path before exporting PERRY_RUNTIME_DIR.
On Line 36 to Line 39, a relative CARGO_TARGET_DIR is preserved as relative. On Line 93, perry compile runs with current_dir(dir) (temp fixture), so PERRY_RUNTIME_DIR=target/debug can resolve to the wrong directory and fail runtime archive lookup.
Suggested fix
fn target_debug_dir() -> PathBuf {
std::env::var_os("CARGO_TARGET_DIR")
.map(PathBuf::from)
+ .map(|p| if p.is_absolute() { p } else { workspace_root().join(p) })
.unwrap_or_else(|| workspace_root().join("target"))
.join("debug")
}Also applies to: 93-93
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/perry/tests/functional_batch2_regressions.rs` around lines 35 - 40,
The `target_debug_dir()` function preserves relative paths from the
`CARGO_TARGET_DIR` environment variable as relative, which causes incorrect
resolution when `perry compile` runs with a different current directory at line
93. Convert the `CARGO_TARGET_DIR` value to an absolute path before joining it
with "debug" by using canonicalize or a similar method to ensure the path always
resolves to the correct location regardless of the current working directory
context.
|
Superseded by #5406, which fixed the same |
Summary
Follow-up to #5398, which merged with a red
cargo-test. The five newcrates/perry/tests/functional_batch2_regressions.rstests setPERRY_NO_AUTO_OPTIMIZE=1, which links the prebuiltlibperry_runtime.ainstead of rebuilding a per-app runtime. Under
cargo test, thestaticlibcrate-type is not produced as a side effect of building the test binary
(only the
rlibis), so CI failed for all five with:(They pass locally only because a prior
cargo build --releaseleft thearchive on disk.)
Fix
Adopt the same convention already used by
module_import_forms.rsand theissue_5xxxno-auto-optimize tests:ensure_runtime_archive()— runscargo build -p perry-runtimeonce (viastd::sync::Once) to materializetarget/debug/libperry_runtime.a.PERRY_RUNTIME_DIR=<target/debug>to the compile so the linker resolvesthe archive directly instead of relying on ambient discovery.
No production code changes — test harness only.
Validation
cargo test -p perry --test functional_batch2_regressions→ 5 passed.cargo fmt -p perry --checkclean.🤖 Generated with Claude Code
Summary by CodeRabbit