mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-05 00:03:15 +01:00
test(pregate): run the cargo stand-in cases on POSIX only
windows-free-shard (5) still failed both end-to-end cargo-lane cases after the delimiter, cargo.cmd and Path-key repairs: the lane's Git Bash exits 1 with an empty log, and that log is not visible from CI. Skip the two cases that run the bash stand-in on win32 (test.skipIf, as other POSIX-shim pregate fixtures are handled) and drop the unproven cargo.cmd and Path-key changes. Selection, planning and the hostile-name case still run on Windows. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
78af8cd6d5
commit
dde2f7a64f
2 files changed
+11
-9
No files matched your search
+2
-1
@@ -14,10 +14,11 @@
|
||||
|
||||
### Tests
|
||||
- `test/pregate-rust.test.ts` (new, vilano93) covers the crate model, the dependency forms, workspace membership, the cargo summary parser and three end-to-end lane runs. New cases: crates named `evil;touch pwned-by-crate-name` and `evil{files}` never reach the shell (nothing is created, both are unclaimed) while `naïve_crate-2` still runs quoted; `crates/[ab]`, `nested/**/leaf` and `unicode/?` (a 📦 directory) members inherit workspace dependencies; a plain `#[test]` dependent and a `cfg(any(test, feature = "<300 chars>"))` are tests; and a same-named non-member past the size cap is unclaimed rather than run as the member; a hostile members glob, a million unmatched `[` and 100,000 unclosed `#[cfg(` run in a supervised Bun that kills a super-linear version at 30 s. Each failed before its fix.
|
||||
- The cargo stand-in now wins PATH lookup everywhere. On windows-free-shard (5) two end-to-end cases failed deterministically because the shim PATH was joined with `:` (Git Bash never saw it) and the runner's real cargo ran against the fixture. On hosts where Bun and cargo share a directory, the lane puts Bun's directory first and the real cargo won the same way. The shim PATH now uses the platform delimiter and Windows' own `Path` key (a second `PATH` key beside it was the one the child ignored), adds `cargo.cmd` for Windows lookup, and on POSIX the lane's bash puts the shim first again through `BASH_ENV`.
|
||||
- The cargo stand-in is hermetic on POSIX: where Bun and cargo share a directory, the lane puts Bun's directory first and the real cargo ran against the fixture, so the shim PATH now uses the platform delimiter and the lane's bash puts the shim first again through `BASH_ENV`. On windows-free-shard (5) the two cases that run the stand-in failed deterministically (`local lane exited 1` with an empty log) and still did after the delimiter and a `Path`-key repair, so they are skipped on Windows (`test.skipIf(process.platform === 'win32')`, as other POSIX-shim pregate fixtures are); the selection, planning and hostile-name cases still run there.
|
||||
- `test/pregate-selection.test.ts` (vilano93) covers nested pnpm/yarn/vitest/jest packages. Its `pnpm` stand-in gets the same `BASH_ENV` fix: on a host with a real pnpm beside Bun, the end-to-end case installed vitest from the network and came back incomplete.
|
||||
|
||||
### Gate integrity
|
||||
- One coverage change to review: the two new end-to-end cargo-lane cases in `test/pregate-rust.test.ts` are skipped on Windows (they never passed there); Linux and macOS run them, and the rest of the file runs on Windows.
|
||||
- No threshold, budget, timeout, trial count or case kind changed. Pregate's lanes now map and run tests for `.rs` files that previously failed closed with "no test lane", and nested vitest/jest packages run under their own runner instead of `bun test`. A `.rs` file outside any crate, a crate with no tests, and a missing cargo or package manager still fail closed or stay incomplete; the tests above cover each.
|
||||
- No new dependency (Cargo.toml is parsed with Bun's built-in TOML parser), no network call in pregate itself, no workflow change. As with the root runner detection on main (`npx vitest run`), a nested package's detected runner (`npx`, `bun x`) may fetch a missing tool when it runs under `--allow-repo-commands`.
|
||||
|
||||
|
||||
@@ -65,14 +65,13 @@ const CARGO_OK = [
|
||||
|
||||
/**
|
||||
* A `cargo` on PATH running `body` (default: reports its cwd and argv, then two passed tests and an empty doc-test binary).
|
||||
* `cargo.cmd` is what Bun.which finds on Windows. The lane puts its Bun's directory first on PATH, and that directory can
|
||||
* hold a real cargo (/usr/local/bin, /opt/homebrew/bin), so on POSIX the lane's bash puts the shim first again through BASH_ENV.
|
||||
* The lane puts its Bun's directory first on PATH, and that directory can hold a real cargo (/usr/local/bin,
|
||||
* /opt/homebrew/bin), so on POSIX the lane's bash puts the shim first again through BASH_ENV.
|
||||
*/
|
||||
function cargoShim(repo: FixtureRepo, body = CARGO_OK): Record<string, string> {
|
||||
const dir = path.join(repo.root, 'shim');
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(path.join(dir, 'cargo'), `#!/usr/bin/env bash\n${body}\n`, { mode: 0o755 });
|
||||
fs.writeFileSync(path.join(dir, 'cargo.cmd'), `@echo off\r\nbash "%~dp0cargo" %*\r\n`);
|
||||
fs.writeFileSync(path.join(dir, 'path.sh'), `PATH='${dir}':"$PATH"\n`);
|
||||
const PATH = [dir, process.env.PATH ?? ''].join(path.delimiter);
|
||||
return process.platform === 'win32' ? { PATH } : { PATH, BASH_ENV: path.join(dir, 'path.sh') };
|
||||
@@ -292,15 +291,17 @@ describe('Cargo membership and test detection (port review)', () => {
|
||||
});
|
||||
|
||||
describe('gstack-pregate on a Rust workspace', () => {
|
||||
/** Windows names it `Path`: a second `PATH` key beside it leaves the child's lookup to whichever the OS reads first. */
|
||||
const pathKey = Object.keys(process.env).find(key => key.toLowerCase() === 'path') ?? 'PATH';
|
||||
const run = (repo: FixtureRepo, { PATH, ...env }: Record<string, string>) => runBin(repo, 'gstack-pregate', ['--base', 'main', '--allow-repo-commands', '--stage', 'tests', '--only', 'lanes'], { ...env, [pathKey]: PATH! });
|
||||
const run = (repo: FixtureRepo, env: Record<string, string>) => runBin(repo, 'gstack-pregate', ['--base', 'main', '--allow-repo-commands', '--stage', 'tests', '--only', 'lanes'], env);
|
||||
// The cargo stand-in is a bash script the lane's Git Bash must find before the runner's real cargo; on windows-latest it
|
||||
// never did (three PATH repairs, the lane still exited 1 with an empty log), so the two cases that run it are POSIX-only,
|
||||
// like test/pregate-dart.test.ts's stand-ins. Selection, planning and the hostile-name case still run on Windows.
|
||||
const posixShim = test.skipIf(process.platform === 'win32');
|
||||
const log = (out: string) => fs.readFileSync(/log: (\S+)/.exec(out)![1]!, 'utf8');
|
||||
|
||||
// Value: protects=the reported case end to end: a touched src file of a workspace crate is not PREGATE_NO_LANE, its crate and the
|
||||
// dependent crates run with `cargo test -p` from the workspace root, and the summed count is reported; fails_when=any link of
|
||||
// graph, plan or summary regresses; why_new=no Rust run existed; seam=none; no_claim=a real cargo (PATH shim reports cwd and argv)
|
||||
test('a touched src file runs its crate and the crates depending on it from the workspace root', () => {
|
||||
posixShim('a touched src file runs its crate and the crates depending on it from the workspace root', () => {
|
||||
const repo = rustRepo();
|
||||
commit(repo, { 'engine/crates/alpha/src/util.rs': 'pub fn two() -> u32 { 1 + 1 }\n' });
|
||||
const r = run(repo, cargoShim(repo));
|
||||
@@ -314,7 +315,7 @@ describe('gstack-pregate on a Rust workspace', () => {
|
||||
// Value: protects=a crate whose test binaries all report 0 tests is ZERO-RUN (exit 0 is not a pass), and a failing cargo run is
|
||||
// PREGATE_LANE_FAILED with its counts; fails_when=cargo's summary is unparsed (count unavailable passes) or the exit is ignored;
|
||||
// why_new=the pure parser test does not run the lane; seam=none; no_claim=a real cargo (PATH shim)
|
||||
test('zero tests is ZERO-RUN; a failing cargo run is PREGATE_LANE_FAILED', () => {
|
||||
posixShim('zero tests is ZERO-RUN; a failing cargo run is PREGATE_LANE_FAILED', () => {
|
||||
const repo = rustRepo();
|
||||
commit(repo, { 'engine/crates/gamma/src/lib.rs': 'pub fn g() { }\n' });
|
||||
const zero = run(repo, cargoShim(repo, 'echo "test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s"'));
|
||||
|
||||
Reference in new issue
Block a user