Skip to content

Allow test runner thread overrides - #2676

Open
luckyteagirl wants to merge 1 commit into
xcl-dev:mainfrom
luckyteagirl:codex/test-respect-thread-option
Open

luckyteagirl wants to merge 1 commit into
xcl-dev:mainfrom
luckyteagirl:codex/test-respect-thread-option

Conversation

@luckyteagirl

@luckyteagirl luckyteagirl commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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 Scripts: cover test runner failures and missing Cargo #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.

@luckyteagirl
luckyteagirl marked this pull request as ready for review November 26, 2026 05:53
@fromthemoonx

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 30, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

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

Decodere commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: 1c8b551
head: 23c12a4
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)

@github-actions github-actions Bot added area:docs-ci Documentation, scripts, workflows, repo governance area:tests Unit, integration, e2e tests, or testtitle needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs-ci Documentation, scripts, workflows, repo governance area:tests Unit, integration, e2e tests, or testtitle needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants