Skip to content

test(ffi-component): find the component under CARGO_TARGET_DIR - #2943

Merged
robcohen merged 2 commits into
mainfrom
fix/component-test-target-dir
Nov 11, 2026
Merged

robcohen merged 2 commits into
mainfrom
fix/component-test-target-dir

Conversation

@robcohen

@robcohen robcohen commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

What

  • crates/rustledger-ffi-component-tests/src/lib.rs now holds the single resolver for the wasip2 component artifact, used by both tests/parity.rs and tests/corpus_parity.rs (their duplicated hardcoded component_path() copies are removed):
    • CARGO_TARGET_DIR set and absolute: used as is
    • CARGO_TARGET_DIR set and relative: taken against the workspace root
    • unset or empty: the workspace target/
  • component_built() replaces the 32 if !component_path().exists() guards. When the artifact is missing it prints skip: component wasm not built (looked for <exact path>; build it with ...). Ten guards previously returned without printing anything; all of them print the marker now.
  • Unit tests for the resolver: env unset, empty, absolute, relative.

Why

The tests looked for ../../target/wasm32-wasip2/... regardless of CARGO_TARGET_DIR, so with a custom target dir every component test skipped and a local run passed without testing anything. CI was protected only because it uses the default target dir.

CI compatibility

The component-parity job builds with cargo build -p rustledger-ffi-component --target wasm32-wasip2 (default target dir) and fails if the log contains skip: component wasm not built. That prefix is unchanged (it is now SKIP_MARKER), and the default resolution is still <workspace>/target/wasm32-wasip2/debug/rustledger_ffi_component.wasm.

CI hardening (second commit)

The component-parity "Run parity tests" step piped cargo test into tee without pipefail, so a failing parity test or a non-compiling test crate left the job green; only a skip marker could fail it. It now sets pipefail, runs --lib --tests (the doc-test binary has no tests), and requires every test binary, at least three, to report test result: ok. with a nonzero passed count. workspace_root() is also canonicalized so the skip message carries no ...

How to test

export CARGO_TARGET_DIR=/some/custom/dir
cargo build -p rustledger-ffi-component --target wasm32-wasip2
cargo test -p rustledger-ffi-component-tests -- --nocapture 2>&1 | tee log
grep -c "skip: component wasm not built" log   # 0

Repeat with CARGO_TARGET_DIR unset. Locally, both runs gave 4 + 2 + 30 tests passed with zero skip markers; the parity suite took about 6 to 7 minutes, which shows the component was actually exercised. Pointing CARGO_TARGET_DIR at a directory without the artifact prints the skip marker with the full looked-for path.

Closes #2933

🤖 Generated with Claude Code

The parity and corpus-parity tests looked for the wasip2 component at a
hardcoded ../../target/wasm32-wasip2/..., so with CARGO_TARGET_DIR set the
artifact was built elsewhere and every component test skipped, letting a
local run pass without testing anything.

Resolve the artifact in one helper in the crate's lib target, shared by
both test files: $CARGO_TARGET_DIR when set (a relative value is taken
against the workspace root), else the workspace target/. A missing
artifact now prints the exact path that was checked, after the unchanged
"skip: component wasm not built" prefix that CI's component-parity job
greps for. Every guard now prints the marker; ten of them returned
silently before. Unit tests cover the env unset, empty, absolute and
relative cases.

Closes #2933

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robcohen
robcohen requested a review from a team as a code owner November 11, 2026 07:08
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Shape rustledger beancount Speedup RSS (rledger / beancount)
simple 51.6ms ± 1.8ms 785.6ms ± 13.6ms 15.2x 44.9 MB / 51.1 MB
investment 76.4ms ± 0.5ms 2851.3ms ± 9.3ms 37.3x 47.1 MB / 59.1 MB
fifo 74.6ms ± 0.5ms 14513.4ms ± 29.3ms 194.5x 49.0 MB / 59.0 MB

vs base, measured in this run

Shape base this PR Change RSS base → PR
simple 50.2ms ± 0.3ms 51.6ms ± 1.8ms +2.9% ✅ within noise 44.8 MB → 44.9 MB (+0.3%)
investment 75.9ms ± 0.6ms 76.4ms ± 0.5ms +0.7% ✅ within noise 47.3 MB → 47.1 MB (-0.3%)
fifo 77.6ms ± 6.1ms 74.6ms ± 0.5ms -3.9% ✅ within noise 49.0 MB → 49.0 MB (+0.1%)

A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: simple 0.8ms, investment 0.4ms, fifo 2.7ms), and is at least 5%.
10,000 transactions per shape · 20 runs, 3 warmup · hyperfine

What do these numbers mean?
  • simple — Two-posting transfers, one currency. The historical workload — keep as the floor, not as the benchmark.
  • investment — Cost specs, per-unit prices and lot reductions. Exercises booking and inventory, which simple leaves at 0.3%.
  • fifo — Bare {} reductions against a FIFO account — how FIFO sells are normally written. The other four shapes reach the ordered-selection path twice in 2k transactions between them, so it was effectively unprofiled until it turned out to be quadratic (plan_ordered scans every lot per reduction: FIFO ledgers are quadratic (8.8s at 20k transactions) #2083).
  • vs base: the PR and the base-branch commit it is built on, built and measured in the same job
  • RSS: peak resident set size, a single sample — reported without a verdict because there is no spread to test it against
  • A shape with no beancount column is one bean-check reports errors on; it is timed for rledger only

@codecov

codecov Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100% (raw 93%, 179 masked)
Full AST Match 100%
Total Files 826
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
    The headline is the EFFECTIVE rate, after pairs where beanquery
    itself is wrong are masked. raw is the same run with nothing
    masked. A widening gap means the registry grew, not that rledger
    changed.
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

The "Run parity tests" step piped cargo test into tee without pipefail,
so its status was tee's: a failing parity test, or a test crate that did
not compile, left the job green. Set pipefail, run --lib --tests (the
doc-test binary has no tests), and require every test binary, at least
three, to report a nonzero passed count.

Also canonicalize workspace_root() so the skip message prints a clean
path, pin that with a test, and name corpus_parity.rs in the crate doc.

Refs #2933

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

test(ffi-component): component tests silently skip when CARGO_TARGET_DIR is set

1 participant