test(builder): the channel tests' stand-in game runs under bash, which takes descriptors of 10 and up #2519

Closed
madebyjordan wants to merge 1 commit from madebyjordan/Longshot:fix/channel-test-shell into main
Member

Summary

CI's Rust (rustfmt, clippy, cargo test) job fails now and then on any pull request, with nothing in it to blame. On #2518 (one Markdown page) it failed in run 53626:

sh: 1: Syntax error: Bad fd number
test channel::tests::a_game_process_says_hello_over_the_ends_it_inherits ... FAILED

and it passed on the same base, be663a08a, half an hour earlier on #1999 (run 53613).

Two channel tests from #2286 start a stand-in game with sh -c '… <&$r … >&$w': build-driver's a_game_process_says_hello_over_the_ends_it_inherits and build-core's a_child_talks_to_the_server_over_its_ends_and_the_builders_close_when_it_ends. The channel's pipe ends get whatever descriptor numbers are free in the test process, which runs its tests in parallel, so sometimes 10 or more. Dash, the sh of Debian and Ubuntu (CI's runner), redirects only one-digit descriptors and stops with "Bad fd number". Both tests now start bash, which takes any descriptor. The builder is unchanged: the game reads the numbers from LONGSHOT_BUILDER_CHANNEL, not through a shell.

Read builder/crates/build-driver/src/channel/tests.rs and builder/crates/build-core/src/channel.rs (tests).

Testing

Tested: Windows 11: cargo fmt --check -p build-core -p build-driver (Rust 1.99.1) passes. The two tests are #[cfg(unix)], so they don't run on Windows. On Ubuntu, CI's Rust job at b17f210d9 (run 53635): both pass (a_child_talks_to_the_server_over_its_ends_and_the_builders_close_when_it_ends ... ok, a_game_process_says_hello_over_the_ends_it_inherits ... ok), every test result: ok, no "Bad fd number". The Website checks fail on main too (fixed by #2518).

Still to test: none.

Measurements

Nothing to measure: two tests' shell, no builder or game code.

Risks

None for players: test code only. The tests now need bash on the PC that runs them (CI's Ubuntu runner and Linux desktops have it). A revert is enough.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary CI's `Rust (rustfmt, clippy, cargo test)` job fails now and then on any pull request, with nothing in it to blame. On https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2518 (one Markdown page) it failed in [run 53626](https://git.magicbean.dev/MagicBeanDev/Longshot/actions/runs/53626): ``` sh: 1: Syntax error: Bad fd number test channel::tests::a_game_process_says_hello_over_the_ends_it_inherits ... FAILED ``` and it passed on the same base, `be663a08a`, half an hour earlier on https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1999 ([run 53613](https://git.magicbean.dev/MagicBeanDev/Longshot/actions/runs/53613)). Two channel tests from https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2286 start a stand-in game with `sh -c '… <&$r … >&$w'`: `build-driver`'s `a_game_process_says_hello_over_the_ends_it_inherits` and `build-core`'s `a_child_talks_to_the_server_over_its_ends_and_the_builders_close_when_it_ends`. The channel's pipe ends get whatever descriptor numbers are free in the test process, which runs its tests in parallel, so sometimes 10 or more. Dash, the `sh` of Debian and Ubuntu (CI's runner), redirects only one-digit descriptors and stops with "Bad fd number". Both tests now start `bash`, which takes any descriptor. The builder is unchanged: the game reads the numbers from `LONGSHOT_BUILDER_CHANNEL`, not through a shell. Read `builder/crates/build-driver/src/channel/tests.rs` and `builder/crates/build-core/src/channel.rs` (tests). ## Testing **Tested:** Windows 11: `cargo fmt --check -p build-core -p build-driver` (Rust 1.99.1) passes. The two tests are `#[cfg(unix)]`, so they don't run on Windows. On Ubuntu, CI's Rust job at `b17f210d9` ([run 53635](https://git.magicbean.dev/MagicBeanDev/Longshot/actions/runs/53635)): both pass (`a_child_talks_to_the_server_over_its_ends_and_the_builders_close_when_it_ends ... ok`, `a_game_process_says_hello_over_the_ends_it_inherits ... ok`), every `test result: ok`, no "Bad fd number". The Website checks fail on `main` too (fixed by https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2518). **Still to test:** none. ## Measurements Nothing to measure: two tests' shell, no builder or game code. ## Risks None for players: test code only. The tests now need `bash` on the PC that runs them (CI's Ubuntu runner and Linux desktops have it). A revert is enough. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
test(builder): the channel tests' stand-in game runs under bash, which takes descriptors of 10 and up
Some checks failed
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
CI / Workflow lint (actionlint) (pull_request) Successful in 17s
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 17s
Third-party parts / As their notes say (pull_request) Successful in 21s
CI / Website build and checks (pull_request) Failing after 24s
CI / longshot-builder end to end (synthetic game) (pull_request) Successful in 1m31s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m56s
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Successful in 4m23s
PR description / Description follows the template (pull_request_target) Successful in 5s
b17f210d96
`build-driver`'s `a_game_process_says_hello_over_the_ends_it_inherits` and `build-core`'s
`a_child_talks_to_the_server_over_its_ends_and_the_builders_close_when_it_ends` start `sh -c`
with redirections to the channel's pipe ends (`>&$w`, `<&$r`). Those ends get whatever numbers
are free in the test process, which runs its tests in parallel, so sometimes 10 or more; dash,
the `sh` of Debian and Ubuntu (CI's runner), redirects only one-digit descriptors and stops with
"Syntax error: Bad fd number". CI's Rust job failed on it on #2518 and passed on the same base on
#1999. bash takes any descriptor. The builder itself is unchanged: the game reads the numbers
from LONGSHOT_BUILDER_CHANNEL, not through a shell.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
madebyjordan changed title from WIP: test(builder): the channel tests' stand-in game runs under bash, which takes descriptors of 10 and up to test(builder): the channel tests' stand-in game runs under bash, which takes descriptors of 10 and up 2026-11-25 08:57:49 +00:00
Author
Member

CI's Rust job on b17f210d9 ran both channel tests on Ubuntu: both pass, no "Bad fd number". In Tested now. @review

CI's Rust job on `b17f210d9` ran both channel tests on Ubuntu: both pass, no "Bad fd number". In Tested now. @review
Author
Member
@review
BeanBot left a comment

Recommendation: Request changes. The change addresses dash’s descriptor limit, but the tests do not reliably exercise the failure it fixes. The new bash processes also inherit startup configuration that can make the tests fail or run unrelated commands.

Both channel tests use bash for their stand-in game, allowing multi-digit pipe descriptors. This changes test code only and adds a bash dependency.

Blocking (1): must change before merging.

  1. L4: The check CI / Website build and checks (pull_request) fails on this head and passes on the base branch: Failing after 24s.

Should fix (3): not blocking, but worth doing before merging.

  • L1 builder/crates/build-core/src/channel.rs:148: Neither changed test ensures that the channel ends have multi-digit descriptors, so the fix has no reliable regression check for the reported failure. (more on the line) Do: Arrange for both tests to use game pipe ends numbered at least 10 and assert that condition before starting the child, so they fail with dash and pass with the fix.
  • L2 builder/crates/build-core/src/channel.rs:148: The new non-interactive bash processes inherit BASH_ENV, allowing a developer’s shell startup file to alter the tests or execute unrelated commands. (more on the line) Do: Remove BASH_ENV from both child commands and clear other inherited bash option variables that can change their behavior.
  • L3 builder/crates/build-driver/src/channel/tests.rs:307: The tests now require bash even on Unix systems where the existing sh is available but bash is not installed. (more on the line) Do: Use a stand-in executable that handles inherited descriptors without requiring bash, or declare and install bash as a test prerequisite on every supported test environment.

@fix can do L1, L2, L3 and L4.

More: does it help, other systems, switches, what was read

Does it help: Unproven for the reported case: the Ubuntu CI run passed both tests, but it did not record their descriptor numbers. The tests do not force descriptors of 10 or higher, so the same run could pass with the original shell.

Other systems: The changed tests run on Unix, not Windows; builder and game code are unchanged. Linux test environments now need bash, and inherited bash startup settings can affect both tests.

Switches: No project switches added, changed or removed. The new bash processes inherit BASH_ENV and other shell settings unless cleared.

Reviewed: b17f210d96 against be663a08a3: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the commit, both changed files and the channel server implementation. Reviewed the diff again; docs/review-checklist.md and the neighboring Tooling checkout were absent. The supplied CI results and review comments were read; run logs were not available.; nothing run (a code review).

Checked and fine:

  • The change contains no game-derived files, generated files, API version changes or project switch changes.
  • The commit records AI assistance with a Co-Authored-By trailer.
  • The channel implementation and player-facing builder behavior are unchanged.

Testing: No commands from the project were run, as required for this review. The supplied Ubuntu CI report says both changed tests passed; Windows ran formatting only.

Overlaps and merge order: None found in the supplied pull request information; the network was unavailable.


Automated code review by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The change addresses dash’s descriptor limit, but the tests do not reliably exercise the failure it fixes. The new bash processes also inherit startup configuration that can make the tests fail or run unrelated commands. Both channel tests use bash for their stand-in game, allowing multi-digit pipe descriptors. This changes test code only and adds a bash dependency. **Blocking (1)**: must change before merging. 1. **L4**: The check `CI / Website build and checks (pull_request)` fails on this head and passes on the base branch: Failing after 24s. **Should fix (3)**: not blocking, but worth doing before merging. - **L1** `builder/crates/build-core/src/channel.rs:148`: Neither changed test ensures that the channel ends have multi-digit descriptors, so the fix has no reliable regression check for the reported failure. (more on the line) **Do:** Arrange for both tests to use game pipe ends numbered at least 10 and assert that condition before starting the child, so they fail with dash and pass with the fix. - **L2** `builder/crates/build-core/src/channel.rs:148`: The new non-interactive bash processes inherit BASH_ENV, allowing a developer’s shell startup file to alter the tests or execute unrelated commands. (more on the line) **Do:** Remove BASH_ENV from both child commands and clear other inherited bash option variables that can change their behavior. - **L3** `builder/crates/build-driver/src/channel/tests.rs:307`: The tests now require bash even on Unix systems where the existing sh is available but bash is not installed. (more on the line) **Do:** Use a stand-in executable that handles inherited descriptors without requiring bash, or declare and install bash as a test prerequisite on every supported test environment. `@fix` can do L1, L2, L3 and L4. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven for the reported case: the Ubuntu CI run passed both tests, but it did not record their descriptor numbers. The tests do not force descriptors of 10 or higher, so the same run could pass with the original shell. **Other systems:** The changed tests run on Unix, not Windows; builder and game code are unchanged. Linux test environments now need bash, and inherited bash startup settings can affect both tests. **Switches:** No project switches added, changed or removed. The new bash processes inherit BASH_ENV and other shell settings unless cleared. **Reviewed:** b17f210d9684 against be663a08a30f: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the commit, both changed files and the channel server implementation. Reviewed the diff again; docs/review-checklist.md and the neighboring Tooling checkout were absent. The supplied CI results and review comments were read; run logs were not available.; nothing run (a code review). **Checked and fine:** - The change contains no game-derived files, generated files, API version changes or project switch changes. - The commit records AI assistance with a Co-Authored-By trailer. - The channel implementation and player-facing builder behavior are unchanged. **Testing:** No commands from the project were run, as required for this review. The supplied Ubuntu CI report says both changed tests passed; Windows ran formatting only. **Overlaps and merge order:** None found in the supplied pull request information; the network was unavailable. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by madebyjordan. Nothing was run; a maintainer decides.</sub>
@ -147,1 +146,3 @@
let mut game = Command::new("sh");
// (the game: reads a line from its read end, answers on its write end; the descriptors from the variable.
// bash, not sh: they can be 10 and up, and dash, Debian's sh, redirects only one-digit descriptors)
let mut game = Command::new("bash");
Member

L1 (should fix): Neither changed test ensures that the channel ends have multi-digit descriptors, so the fix has no reliable regression check for the reported failure.

When: When the low descriptor numbers are free, open() can assign both game ends numbers below 10. Replacing bash with dash then still passes, leaving the intermittent CI failure undetected.

Do: Arrange for both tests to use game pipe ends numbered at least 10 and assert that condition before starting the child, so they fail with dash and pass with the fix.

**L1** (should fix): Neither changed test ensures that the channel ends have multi-digit descriptors, so the fix has no reliable regression check for the reported failure. *When:* When the low descriptor numbers are free, open() can assign both game ends numbers below 10. Replacing bash with dash then still passes, leaving the intermittent CI failure undetected. **Do:** Arrange for both tests to use game pipe ends numbered at least 10 and assert that condition before starting the child, so they fail with dash and pass with the fix.
Member

L2 (should fix): The new non-interactive bash processes inherit BASH_ENV, allowing a developer’s shell startup file to alter the tests or execute unrelated commands.

When: If BASH_ENV names a file containing exit 1, bash exits before exchanging channel messages and both tests fail even though the channel works; the previous dash invocation did not read BASH_ENV.

Do: Remove BASH_ENV from both child commands and clear other inherited bash option variables that can change their behavior.

**L2** (should fix): The new non-interactive bash processes inherit BASH_ENV, allowing a developer’s shell startup file to alter the tests or execute unrelated commands. *When:* If BASH_ENV names a file containing `exit 1`, bash exits before exchanging channel messages and both tests fail even though the channel works; the previous dash invocation did not read BASH_ENV. **Do:** Remove BASH_ENV from both child commands and clear other inherited bash option variables that can change their behavior.
@ -306,0 +304,4 @@
// (the game: hello out of its write end, the answer into a file, then a request that is not allowed. bash, not
// sh: the pipe ends get whatever numbers are free, 10 and up too, and dash, Debian's sh, redirects only one-digit
// descriptors)
let mut game = Command::new("bash");
Member

L3 (should fix): The tests now require bash even on Unix systems where the existing sh is available but bash is not installed.

When: On a minimal Linux development or CI environment with dash as sh and no bash in PATH, both tests fail at spawn instead of testing the channel.

Do: Use a stand-in executable that handles inherited descriptors without requiring bash, or declare and install bash as a test prerequisite on every supported test environment.

**L3** (should fix): The tests now require bash even on Unix systems where the existing sh is available but bash is not installed. *When:* On a minimal Linux development or CI environment with dash as sh and no bash in PATH, both tests fail at spawn instead of testing the channel. **Do:** Use a stand-in executable that handles inherited descriptors without requiring bash, or declare and install bash as a test prerequisite on every supported test environment.
Author
Member

Superseded by #2536, which makes the same change (sh to bash in both channel tests, for dash's one-digit fd limit). On BeanBot's L1-L3: they now apply to main's version of these tests, not to this PR. Closing as a duplicate.

Superseded by #2536, which makes the same change (sh to bash in both channel tests, for dash's one-digit fd limit). On BeanBot's L1-L3: they now apply to main's version of these tests, not to this PR. Closing as a duplicate.
madebyjordan closed this pull request 2026-11-25 17:18:27 +00:00
Some checks failed
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 3s
CI / Workflow lint (actionlint) (pull_request) Successful in 17s
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 17s
Third-party parts / As their notes say (pull_request) Successful in 21s
CI / Website build and checks (pull_request) Failing after 24s
CI / longshot-builder end to end (synthetic game) (pull_request) Successful in 1m31s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m56s
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Successful in 4m23s
PR description / Description follows the template (pull_request_target) Successful in 5s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2519
No description provided.