Repository navigation
Conversation
lanes reported PREGATE_NO_LANE for every touched .rs file and ran a nested pnpm+vitest package's tests as `bun test` from the repo root. - Rust: a .rs file of a crate (nearest Cargo.toml with [package]) is a test under <crate>/tests/ or when it holds a #[cfg(test)]; every .rs file of a crate and its Cargo.toml select the crate's tests and those of every crate depending on it (lib/pregate/rust.ts). Selected tests run per crate as `cargo test -p <name>` from the workspace root, judged on the summed `test result:` lines (doc-tests included); zero tests stays ZERO-RUN and a missing cargo is incomplete, like a missing Dart SDK. - JS/TS: a test owned by a nested package.json that declares vitest or jest runs from that package with package-relative paths, through the package manager its packageManager field or nearest lockfile names (pnpm exec, yarn, bun x, else npx). Root detection and a declared runner are unchanged. - init notes that Rust tests run per crate; docs/pregate.md updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The line scan of Cargo.toml missed dependents (a false green) and picked the
wrong workspace:
- an inherited renamed dependency (`base = { workspace = true }` with
`[workspace.dependencies] base = { package = "alpha", path = ... }`);
- dotted keys (`alpha.path = "../a"`), `[dependencies.<name>]` tables and
target-specific tables, matched by key name only;
- a crate the workspace excludes ran `cargo test -p` from the workspace root.
Manifests are now parsed with Bun.TOML. A dependency resolves by path
(relative to the manifest declaring it, or to the workspace root when
inherited), else by package name. A crate runs from the workspace it is a
member of under Cargo's rules (package.workspace, the nearest [workspace],
members globs, exclude, literal members, path dependencies of members),
else from its own directory. Nothing runs cargo.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
Thank you @vilano93. This is landing as #3380, with your two commits kept as they are and credited to you. The crate model, the TOML follow-up for renamed, inherited and dotted dependencies, and the nested pnpm/vitest runners all went in unchanged. On top of them we quoted and grammar-checked the crate name (it reached the lane's shell from Cargo.toml), switched members globs to a Cargo-style matcher so |
…ers (#3344, port of #3346) (#3380) * fix(pregate): Rust crate lanes and nested JS package runners lanes reported PREGATE_NO_LANE for every touched .rs file and ran a nested pnpm+vitest package's tests as `bun test` from the repo root. - Rust: a .rs file of a crate (nearest Cargo.toml with [package]) is a test under <crate>/tests/ or when it holds a #[cfg(test)]; every .rs file of a crate and its Cargo.toml select the crate's tests and those of every crate depending on it (lib/pregate/rust.ts). Selected tests run per crate as `cargo test -p <name>` from the workspace root, judged on the summed `test result:` lines (doc-tests included); zero tests stays ZERO-RUN and a missing cargo is incomplete, like a missing Dart SDK. - JS/TS: a test owned by a nested package.json that declares vitest or jest runs from that package with package-relative paths, through the package manager its packageManager field or nearest lockfile names (pnpm exec, yarn, bun x, else npx). Root detection and a declared runner are unchanged. - init notes that Rust tests run per crate; docs/pregate.md updated. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(pregate): parse Cargo manifests as TOML; follow workspace membership The line scan of Cargo.toml missed dependents (a false green) and picked the wrong workspace: - an inherited renamed dependency (`base = { workspace = true }` with `[workspace.dependencies] base = { package = "alpha", path = ... }`); - dotted keys (`alpha.path = "../a"`), `[dependencies.<name>]` tables and target-specific tables, matched by key name only; - a crate the workspace excludes ran `cargo test -p` from the workspace root. Manifests are now parsed with Bun.TOML. A dependency resolves by path (relative to the manifest declaring it, or to the workspace root when inherited), else by package name. A crate runs from the workspace it is a member of under Cargo's rules (package.workspace, the nearest [workspace], members globs, exclude, literal members, path dependencies of members), else from its own directory. Nothing runs cargo. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(pregate): the Rust fixture's cargo shim wins PATH on Windows and beside a real cargo windows-free-shard (5) failed 'a touched src file runs its crate...' and 'zero tests is ZERO-RUN...' deterministically: the shim PATH was joined with ':' so Git Bash never saw the shim dir, and the runner's real cargo ran against the fixture (exit 1, no test result lines). On POSIX hosts where Bun and cargo share a directory (/usr/local/bin on Capy's image), the lane puts Bun's directory first and the real cargo wins the same way. Join with path.delimiter, add cargo.cmd for Bun.which on Windows, and on POSIX put the shim first again in the lane's own bash through BASH_ENV. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(pregate): quote the crate name in cargoRunner The crate name is read from the repo's Cargo.toml and was interpolated into 'cargo test -p <name>', which the lane runs through bash. A name like 'evil;touch pwned' ran the second command. Quote it like every file and cwd the lane already passes; a new end-to-end case checks the name reaches cargo as one argument and runs nothing. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(pregate): the nested-package pnpm shim wins PATH beside a real pnpm 'a touched file in a nested pnpm+vitest package runs vitest there' ran the host's real pnpm wherever Bun and pnpm share a directory (/usr/local/bin on Capy's image): the lane puts Bun's directory first, so pnpm installed vitest from the network, dirtied the fixture tree and the check came back incomplete. Put the shim first again in the lane's bash through BASH_ENV, as the Rust fixture does. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(changelog): pregate Rust crate lanes and nested package runners (#3344) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(pregate): a crate name Cargo would reject never reaches the lane's shell Port review (outside voice): quoting alone was not enough, because the lane expands {files} after the runner string is built, so a crate named 'evil{files}' spliced the quoted file list into the quoted name and a file name like tests/$(cmd).rs then ran. A name outside Cargo's grammar (letters, digits, _ and -) now gets no runner: its files are unclaimed and the lane is incomplete, as Cargo itself would refuse the manifest. A valid name, Unicode included, still runs quoted. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(pregate): match Cargo members globs per path component, without a backtracking regex Port review (outside voice): members globs went through ship-policy's matchesAny, which escapes [...] classes (crates/[ab] matched nothing, so the crate was no member, lost its inherited [workspace.dependencies] path and its dependents' tests were never selected: a false green) and backtracks exponentially on a hostile glob such as '*a*a...*ab' (over 5 s for one crate, before any runner deadline). A small dynamic-programming matcher handles *, ?, [..] with negation and ranges, and ** across components, in O(pattern x path). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(pregate): a plain #[test] in src is a Rust test; bound the cfg attribute scan Port review (outside voice): only #[cfg(test)] modules and tests/ files counted, so a dependent crate whose tests are plain #[test] or #[tokio::test] functions in src never ran when its dependency changed (a false green). The cfg scan also went quadratic on a run of unclosed '#[cfg(' (about 3 s on 120 KB). Test attributes now count, and the cfg predicate and its strings are length-bounded so the scan stays linear. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(pregate): Rust test attributes, workspace membership and rejected crate names; changelog for the port review fixes Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(pregate): match members globs by code point in one pass, and admit every crate past a size cap Second port review round (outside voice): the matcher counted UTF-16 units, so 'crates/?' missed a crate directory named with a supplementary character and dropped its inherited dependencies (a false green); and each unmatched '[' rescanned the rest of the glob (5 s for one crate with a million of them). Tokenize by code point with a precomputed next-']' table, and past 4096 characters of members globs admit every crate under the workspace: a wrong member fails loudly in cargo, a dropped one is silent. The new supervised probe kills a super-linear matcher at 30 s instead of hanging the file. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(pregate): scan cfg attributes once without truncating them; an unclosable one counts as a test Second port review round (outside voice): the length bound from the first round dropped a valid cfg(any(test, feature = "<257 chars>")), so its crate's tests were no longer selected (a false green). Read each attribute once to its closing ']' and resume after it, which keeps the scan linear without a bound; an attribute the scan cannot close (an unterminated string, no ']') counts as a test, which selects more, never fewer. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(changelog): second port review round (code-point member globs, unbounded linear cfg scan) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(pregate): past the members size cap, a crate's run root is undecided and its tests unclaimed Third port review round (outside voice): admitting every crate past the cap made a non-member run as 'cargo test -p <name>' from the workspace root, where a same-named member answered and its passing tests stood in for the orphan's failing one (a false green). Keep the conservative membership for dependency edges, but leave such a crate's workspace undecided (null): planRuns leaves its files unclaimed and the lane incomplete. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(pregate): the Rust end-to-end runs put the cargo shim under Windows' own Path key windows-free-shard (5) still failed both end-to-end cases at fe99b20 with the same symptom (the runner's real cargo, exit 1, no test result lines). runBin merges process.env, whose Windows key is 'Path', with the shim's 'PATH', so the child got two path variables and read the original. Write the shim under the key process.env actually uses, as test/helpers/unreachable-gbrain.ts and sync-gbrain-readiness-fixture.ts do. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * 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> * v1.91.197.0 stamp Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: vilano93 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Why (in your own words)
/shipcan't produce a receipt on a repo that mixes a Cargo workspace with a nested pnpm/vitest package.gstack-pregate'slanescheck has no Rust support: every touched.rsfile isPREGATE_NO_LANE, even when the file holds a#[cfg(test)]module that CI runs withcargo test. Separately, JS runner detection reads only the rootpackage.json, so a vitest package inapp/runs underbun testfrom the repo root. That gives about 98 false failures, becausevi.stubGlobaldoesn't exist under bun.This change does three things:
cargo test -p <crate>from its workspace root.runnerbehave as before.Fixes #3344.
Live evidence
The real repo where this broke: a Cargo workspace in
engine/, a pnpm+vitest package inapp/, and no rootpackage.json. The branch touches 9.rsfiles and 14 other files.The one file left really has no unit test in that repo; only Playwright covers it.
VERSIONis now covered through the crate'stests/cli_version.rs, which reads it.The run below used
--allow-repo-commandsand a temporary.gstack/pregate.jsonthat declared that one file as[]. The file was deleted afterwards.The cargo part was 13
test result:lines, 501 passed, 0 failed. Before this change, the same TS files ran underbun testfrom the root, with about 98 false failures.The new tests were red first, then green:
Scope
lib/pregate/rust.ts: Cargo manifests are parsed withBun.TOML.parse, which the repo already uses, so there is no new dependency and pregate never calls cargo. It also builds the crate model:<crate>/tests/, or one containing#[cfg(test)];package =renames,{ workspace = true }inheritance, dotted keys, table form, dev, build and target-specific dependencies;package.workspace,membersandexclude, path-dependency members.lib/pregate/import-graph.ts: the Rust links are added to the selection graph.lib/pregate/checks/lanes.ts:test result:summary that adds up every line, doc-tests included; zero tests run isZERO-RUN; cargo missing is incomplete, not passed;packageManageror the lockfile.lib/pregate/init-draft.ts:initnow says Rust tests run per crate.docs/pregate.md.test/pregate-rust.test.ts, plus 3 nested-package cases intest/pregate-selection.test.ts.bun run typecheck: clean;bun run typecheck:test: "819 known diagnostics, none new".upstream/mainworktree on macOS:TMPDIR=$(realpath $TMPDIR)doesn't change them.bun run test:quickfails the same 46 on both.bun run testfails the same set on both. The only file that differed wasexercised-mapparity, and only because the new file wasn't tracked yet; it passes once tracked.pregate-regate.test.tstimes out now and then under load, on both sides.package.workspacepointer and a literal member overridingexcludehave no dedicated test; they are implemented following Cargo's rules.cargo testin the engine job) claims every selected test (lane-selection.ts). On this repo that turns all 146 files, Rust included, into obligations for the Linuxappandlizenz-gatejobs.Cargo.tomlorCargo.lockstill needs adependenciesdeclaration.Liveness proof (required for external contributors)
Checklist
GSTACK PRtyped live into a real surface) or PR author is @garrytan (owner exemption)🤖 Generated with Claude Code