fix: correct exit code success detection in test runner#793
Merged
lpcox merged 2 commits intoclaude/extract-rust-one-shot-token-libfrom Feb 13, 2026
Merged
Conversation
The awf-runner was incorrectly handling undefined exit codes from execa. When exitCode was undefined, it would set exitCode field to 0 (via || operator) but success field would evaluate undefined === 0 which is false. This caused tests to fail with the confusing message: "Expected awf to succeed, but it failed with exit code 0" Fixed by normalizing exitCode to a variable first using ?? operator, then using that normalized value for both fields. Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes inconsistent success detection in the AwfRunner test fixture when execa returns an undefined exitCode, which could yield exitCode: 0 while incorrectly reporting success: false and fail workflows like “Test Chroot Package Managers”.
Changes:
- Normalize
exitCodeonce viaconst exitCode = result.exitCode ?? 0inrun(). - Apply the same normalization in
runWithSudo(). - Use the normalized
exitCodefor both the returnedexitCodeandsuccessfields to keep them consistent.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Feb 13, 2026
pelikhan
pushed a commit
that referenced
this pull request
Feb 13, 2026
* Initial plan * feat: add rust one-shot-token library implementation Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> * docs: update README for rust implementation Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> * feat: update Dockerfile and entrypoint for rust build Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> * fix(security): use multi-stage build for rust compilation Use official rust:1.77-slim Docker image in multi-stage build to avoid executing unverified rustup installer script. This mitigates supply chain attack risk during container builds. Changes: - Add rust-builder stage using rust:1.77-slim official image - Build one-shot-token library in isolated builder stage - Copy pre-built library to main stage via COPY --from=rust-builder - Remove curl/build-essential from main stage (no longer needed) - Add security comments documenting supply chain attack mitigation Addresses security review recommendation from @lpcox. Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> * feat(ci): add crates.io to build-test-rust network allowlist * chore(ci): regenerate build-test-rust lock file with crates.io Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> * fix: correct exit code success detection in test runner (#793) * Initial plan * fix: correct exit code success detection in test runner The awf-runner was incorrectly handling undefined exit codes from execa. When exitCode was undefined, it would set exitCode field to 0 (via || operator) but success field would evaluate undefined === 0 which is false. This caused tests to fail with the confusing message: "Expected awf to succeed, but it failed with exit code 0" Fixed by normalizing exitCode to a variable first using ?? operator, then using that normalized value for both fields. Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> * Initial plan (#794) Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com> * fix: add Rust toolchain setup and RUSTUP_HOME support for chroot package manager tests (#797) * Initial plan * fix: add explicit toolchain to rust setup in test workflow Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> * feat: add RUSTUP_HOME environment variable support for Rust toolchain Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
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.
The "Test Chroot Package Managers" workflow was failing with a paradoxical error: "Expected awf to succeed, but it failed with exit code 0". The test runner in
awf-runner.tswas mishandling undefined exit codes from execa.Root Cause
When
execareturnsundefinedforexitCode, the code was creating a mismatch:This caused
exitCode: 0butsuccess: false, making passing tests appear as failures.Changes
??) before using it for both fieldsrun()andrunWithSudo()methods intests/fixtures/awf-runner.tsThe rustc test was actually passing; the test framework was incorrectly reporting it as failed.