refactor(rust): derive cross test runners from qemuArch - #651
Open
rvolosatovs wants to merge 1 commit into
Open
Conversation
The per-target test-runner selection in `buildPackageFor` was a ~150-line
`if/else` chain with one branch per target, each hardcoding
`CARGO_TARGET_<T>_RUNNER = "qemu-<arch>"` and repeating the same
"disable testing on a Darwin build host" guard.
Every `qemu-<arch>` value is exactly `pkgsCross.stdenv.hostPlatform.qemuArch`
(verified for all previously-listed targets: aarch64, arm, mips/mips64(el),
ppc64(le), riscv64, s390x, x86_64), so the whole chain collapses to:
- an explicit `noTestRunner` list for targets with no usable emulator
(android, wasm32-unknown-unknown, windows-under-sandbox),
- `wasmtime` for wasm targets (works on every host, incl. Darwin),
- `qemu-${qemuArch}` for everything else, with the Darwin guard applied
once, and the original "unknown runner" warning kept as a fallback for
targets whose `qemuArch` is null.
Net: 139 lines removed, 22 added. Behaviour is preserved for the targets
in the examples/CI matrix; emulatable Linux targets that previously fell
through to the warning now get a qemu runner automatically, so adding such
a target no longer requires editing this function.
Verified by cross-building `rust-complex` for `x86_64-unknown-linux-gnu`
on an aarch64-linux host: its test suite runs under `qemu-x86_64`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors cross-compilation test-runner selection by deriving the Cargo runner from pkgsCross.stdenv.hostPlatform.qemuArch, replacing a long per-target conditional chain while preserving previous behavior for known targets.
Changes:
- Introduces a single computed
runnerEnvand uses it to setCARGO_TARGET_<TRIPLE>_RUNNERdynamically. - Adds a small explicit “no test runner” list for targets that cannot be cross-tested in this environment.
- Uses
wasmtimefor WASM targets andqemu-${qemuArch}for other emulatable targets, applying the Darwin guard once.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| else | ||
| warn | ||
| "do not know which test runner to use for target `${target}`, set `CARGO_TARGET_${toUpper (kebab2snake target)}_RUNNER` to appropriate `qemu` binary name" | ||
| "do not know which test runner to use for target `${target}`, set `${runnerEnv}` to appropriate `qemu` binary name" |
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 per-target test-runner selection in
buildPackageForwas a ~150-lineif/elsechain with one branch per target, each hardcodingCARGO_TARGET_<T>_RUNNER = "qemu-<arch>"and repeating the same "disable testing on a Darwin build host" guard.Every
qemu-<arch>value is exactlypkgsCross.stdenv.hostPlatform.qemuArch(verified for all previously-listed targets: aarch64, arm, mips/mips64(el), ppc64(le), riscv64, s390x, x86_64), so the whole chain collapses to:noTestRunnerlist for targets with no usable emulator (android, wasm32-unknown-unknown, windows-under-sandbox),wasmtimefor wasm targets (works on every host, incl. Darwin),qemu-${qemuArch}for everything else, with the Darwin guard applied once, and the original "unknown runner" warning kept as a fallback for targets whoseqemuArchis null.Net: 139 lines removed, 22 added. Behaviour is preserved for the targets in the examples/CI matrix; emulatable Linux targets that previously fell through to the warning now get a qemu runner automatically, so adding such a target no longer requires editing this function.
Verified by cross-building
rust-complexforx86_64-unknown-linux-gnuon an aarch64-linux host: its test suite runs underqemu-x86_64.