Allow test runner thread overrides #2666

Open
luckyteagirl wants to merge 1 commit from upstream-pr/2676 into main
luckyteagirl commented 2026-11-26 05:49:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T05:49:57Z.


scripts/test.ps1 always added --test-threads=4. On Rust 1.99.0, libtest rejected a caller's second option before running tests; on Rust 1.100.0, duplicate options are accepted with the last value winning. The runner now gives callers a consistent override without passing duplicates.

What is in it

  • Put the four-thread default in RUST_TEST_THREADS for cargo test and restore the caller's environment afterward.
  • Forward the arguments unchanged so libtest can distinguish options from filter values and arguments after --.

Tested

  • A standalone Rust 1.99.0 test binary rejected duplicate --test-threads=N and --test-threads N arguments with exit 101. Both explicit forms took precedence over the environment default.
  • An independent reviewer reproduced Rust 1.98.1's rejection and Rust 1.100.0's last-value behavior, and passed the real PowerShell 5.1 runner on 1.100.0 on both main and this patch (report).
  • scripts/test-test-threads.tests.ps1 and scripts/test-native-stderr.tests.ps1 passed on PowerShell 5.1 and 7.6.9. The mock Cargo fixture checks argument forwarding, the four-thread default, and restoration for both an unset and a previously set environment variable.
  • The expanded native stderr fixture from #296 at 29e66d46 passed with the patched runner on both shells for success, build failure, test failure, and missing Cargo.
  • git diff --check passed.

Regression run

  • Not applicable. The change affects only the PowerShell test runner and its test.

Not tested

  • The Rust workspace suite or GPU tests. The PowerShell regression uses mock Cargo and the libtest check uses a standalone binary.

AI use

  • Codex (GPT-6.2 Sol) implemented the change and fixtures, verified libtest behavior, and drafted this description.
<!-- greyfinch-sync:ivall/xcl:issue:5504777639 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2676). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T05:49:57Z. --- `scripts/test.ps1` always added `--test-threads=4`. On Rust 1.99.0, libtest rejected a caller's second option before running tests; on Rust 1.100.0, duplicate options are accepted with the last value winning. The runner now gives callers a consistent override without passing duplicates. **What is in it** - Put the four-thread default in `RUST_TEST_THREADS` for `cargo test` and restore the caller's environment afterward. - Forward the arguments unchanged so libtest can distinguish options from filter values and arguments after `--`. **Tested** - A standalone Rust 1.99.0 test binary rejected duplicate `--test-threads=N` and `--test-threads N` arguments with exit 101. Both explicit forms took precedence over the environment default. - An independent reviewer reproduced Rust 1.98.1's rejection and Rust 1.100.0's last-value behavior, and passed the real PowerShell 5.1 runner on 1.100.0 on both main and this patch ([report](https://github.com/xcl-dev/xcl/pull/2676#issuecomment-7184118000)). - `scripts/test-test-threads.tests.ps1` and `scripts/test-native-stderr.tests.ps1` passed on PowerShell 5.1 and 7.6.9. The mock Cargo fixture checks argument forwarding, the four-thread default, and restoration for both an unset and a previously set environment variable. - The expanded native stderr fixture from #296 at `29e66d46` passed with the patched runner on both shells for success, build failure, test failure, and missing Cargo. - `git diff --check` passed. **Regression run** - Not applicable. The change affects only the PowerShell test runner and its test. **Not tested** - The Rust workspace suite or GPU tests. The PowerShell regression uses mock Cargo and the libtest check uses a standalone binary. **AI use** - Codex (GPT-6.2 Sol) implemented the change and fixtures, verified libtest behavior, and drafted this description.
fromthemoonx commented 2026-11-26 07:03:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-26T06:07:39Z.


The real runner works on Windows PowerShell 5.1, and the bug it fixes depends on the Rust version: Rust 1.98.1's libtest rejects a second --test-threads, Rust 1.100.0's accepts it (the last one wins). So on 1.100.0 main's runner already works with an explicit --test-threads; on 1.98.1 and older, this change is what makes it work.

Windows 11 Pro 26300, Windows PowerShell 5.1.26100, RTX 3060, main b49be18:

result
a one-test crate, cargo +1.98.1 test -- --test-threads=4 --test-threads=2 error: Option 'test-threads' given more than once
same with +stable (1.100.0), and XCL's lib test binary with = and space forms in any order runs, test result: ok
.\scripts\test.ps1 vfs::tests --test-threads=2 under PS 5.1 (real Cargo, Rust 1.100.0): main / this PR merged onto main both exit 0; 37 targets, 12 passed, 0 failed
scripts\test-test-threads.tests.ps1 and scripts\test-native-stderr.tests.ps1 under PS 5.1 on 23c12a4 both exit 0 (test-threads: ok)

Not tested: the whole workspace suite through the runner (only the vfs::tests filter), PowerShell 7.

AI use: Claude Code (Claude Opus 5.5) ran the checks and wrote this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7184118000 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2676#issuecomment-7184118000). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-11-26T06:07:39Z. --- **The real runner works on Windows PowerShell 5.1, and the bug it fixes depends on the Rust version: Rust 1.98.1's libtest rejects a second `--test-threads`, Rust 1.100.0's accepts it (the last one wins).** So on 1.100.0 `main`'s runner already works with an explicit `--test-threads`; on 1.98.1 and older, this change is what makes it work. Windows 11 Pro 26300, Windows PowerShell 5.1.26100, RTX 3060, `main` `b49be18`: | | result | |---|---| | a one-test crate, `cargo +1.98.1 test -- --test-threads=4 --test-threads=2` | `error: Option 'test-threads' given more than once` | | same with `+stable` (1.100.0), and XCL's lib test binary with `=` and space forms in any order | runs, `test result: ok` | | `.\scripts\test.ps1 vfs::tests --test-threads=2` under PS 5.1 (real Cargo, Rust 1.100.0): `main` / this PR merged onto `main` | both exit 0; 37 targets, 12 passed, 0 failed | | `scripts\test-test-threads.tests.ps1` and `scripts\test-native-stderr.tests.ps1` under PS 5.1 on `23c12a4` | both exit 0 (`test-threads: ok`) | **Not tested:** the whole workspace suite through the runner (only the `vfs::tests` filter), PowerShell 7. **AI use:** Claude Code (Claude Opus 5.5) ran the checks and wrote this comment.
github-actions[bot] commented 2026-11-30 08:43:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:43:25Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7273262370 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2676#issuecomment-7273262370). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:43:25Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 08:40:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:40:48Z.


Triage (#1607) – head 23c12a4

No open or merged PR makes the same change. #1399 also touches the --test-threads=4 line of scripts/test.ps1 (a .env-driven $testThreads), but that is a different, larger change.
The diff moves the default to RUST_TEST_THREADS=4 and restores the caller's value afterwards, so an explicit --test-threads in the arguments no longer reaches libtest twice. Note that a caller's own RUST_TEST_THREADS is still overridden by 4 (same as on main). No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305635763 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2676#issuecomment-7305635763). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:40:48Z. --- **Triage (#1607)** – head 23c12a4 No open or merged PR makes the same change. #1399 also touches the `--test-threads=4` line of `scripts/test.ps1` (a `.env`-driven `$testThreads`), but that is a different, larger change. The diff moves the default to `RUST_TEST_THREADS=4` and restores the caller's value afterwards, so an explicit `--test-threads` in the arguments no longer reaches libtest twice. Note that a caller's own `RUST_TEST_THREADS` is still overridden by 4 (same as on main). No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Decodere commented 2026-12-02 09:14:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T09:14:21Z.


merge-check
base: 1c8b551475
head: 23c12a4200
merge: clean (git merge --no-edit onto 1c8b5514, git diff --check clean; scripts/test.ps1 +12/-5, scripts/test-test-threads.tests.ps1 +47)
build: not run (Tier 0 PowerShell script diff touching only scripts/; no Rust code changed)
tests: Windows PowerShell 5.1 (5.1.26100.8457): scripts/test-test-threads.tests.ps1 -> ok (test-threads: ok); other passing scripts (perf-compare.tests.ps1, perf-run.tests.ps1, smoke-title.tests.ps1, test-smoke-artifacts.tests.ps1) -> 4/4 ok. test-native-stderr.tests.ps1 fails with exit 127 identically on clean base 1c8b5514 (pre-existing mock cargo.cmd mismatch with cargo bench in scripts/test.ps1). Rust workspace tests not run (Tier 0); PowerShell 7 not installed here.
review: Read the full merged diff (scripts/test.ps1:19-32, scripts/test-test-threads.tests.ps1). Moving the 4-thread default from a hardcoded --test-threads=4 CLI flag to RUST_TEST_THREADS=4 inside try/finally restores the caller's RUST_TEST_THREADS on exit while allowing explicit --test-threads overrides to pass through without duplicate-option errors on older Rust toolchains (e.g. 1.98.1). The fixture test covers = and space forms, --skip --test-threads=1, -- --test-threads=1, and env restoration for both set and unset caller values. Clean, minimal, no regressions.
performance: none (script-only change in scripts/; zero runtime impact)
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Windows PowerShell 5.1.26100.8457, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)

<!-- greyfinch-sync:ivall/xcl:comment:7340586258 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2676#issuecomment-7340586258). Originally posted by [Decodere](https://github.com/Decodere) on 2026-12-02T09:14:21Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: 23c12a4200bfef126cda93c97fd190d9c21df74a merge: clean (`git merge --no-edit` onto `1c8b5514`, `git diff --check` clean; `scripts/test.ps1` +12/-5, `scripts/test-test-threads.tests.ps1` +47) build: not run (Tier 0 PowerShell script diff touching only `scripts/`; no Rust code changed) tests: Windows PowerShell 5.1 (`5.1.26100.8457`): `scripts/test-test-threads.tests.ps1` -> ok (`test-threads: ok`); other passing scripts (`perf-compare.tests.ps1`, `perf-run.tests.ps1`, `smoke-title.tests.ps1`, `test-smoke-artifacts.tests.ps1`) -> 4/4 ok. `test-native-stderr.tests.ps1` fails with exit 127 identically on clean base `1c8b5514` (pre-existing mock `cargo.cmd` mismatch with `cargo bench` in `scripts/test.ps1`). Rust workspace tests not run (Tier 0); PowerShell 7 not installed here. review: Read the full merged diff (`scripts/test.ps1:19-32`, `scripts/test-test-threads.tests.ps1`). Moving the 4-thread default from a hardcoded `--test-threads=4` CLI flag to `RUST_TEST_THREADS=4` inside `try`/`finally` restores the caller's `RUST_TEST_THREADS` on exit while allowing explicit `--test-threads` overrides to pass through without duplicate-option errors on older Rust toolchains (e.g. 1.98.1). The fixture test covers `=` and space forms, `--skip --test-threads=1`, `-- --test-threads=1`, and env restoration for both set and unset caller values. Clean, minimal, no regressions. performance: none (script-only change in `scripts/`; zero runtime impact) verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Windows PowerShell 5.1.26100.8457, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2676:upstream-pr/2676'
git switch 'upstream-pr/2676'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2676'
git switch 'upstream-pr/2676'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2676'
git switch 'upstream-pr/2676'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2676'
git switch 'main'
git merge --squash 'upstream-pr/2676'
git switch 'main'
git merge --ff-only 'upstream-pr/2676'
git switch 'main'
git merge 'upstream-pr/2676'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2666
No description provided.