Repository navigation
Keep three tests off machine state - #2099
Conversation
Three test-only fixes. No product code changes. A Maven crawler unit test counted the machine's caches. `project_mode_crawl_keeps_only_the_projects_graph` wanted exactly 3 packages from a global crawl. A global crawl also reads the Coursier and Ivy caches the process environment names (HOME, COURSIER_CACHE and the JVM option sources), which `JvmEnv` does not pin, so the count depended on the machine: with one package in a Coursier cache under HOME it is 4 and the test fails. The test now looks up the three packages of its own repository in the result. It still fails if a global crawl is scoped to the project, because the package that another project cached would be missing. The CLI tests' patch service missed a Go module's directory on Windows. `prebuilt_common::source_dir` picks the directory a Go module's archive is packed from by comparing each listed directory, as text, with the purl's `<module>@<version>`. A module path has a `/` in it and Windows lists the module cache with `\`, so nothing matched and the service served the stand-in of `package_layout` in silence: a `go.mod` and the patched files, none of the module's own. The comparison now normalizes the separator. A self-test passes `\`-separated and `\\?\`-prefixed directories as text, so it fails without the fix on every platform. The self-update fixture names a binary that is too large to serve. `make_served_binary` serves the built `socket-patch` as the release payload, and the updater refuses an extracted binary above 256 MiB (`MAX_BINARY_BYTES`). A build above the cap failed every test that serves it with "exceeds the 268435456-byte cap", far from the cause; #2071 fixed one such build. The fixture now asserts the size first and says which setting to change. Checked on macOS arm64: - The Maven test before and after the change, with HOME as it is, with an empty HOME and with a HOME that holds a one-package Coursier cache. Before, the third run fails with 4 != 3. After, all three pass, and so do the 72 tests of the module. - The new self-test fails with the separator fix taken out (it gets the stand-in, `project/missing`) and passes with it in each of the 78 test targets that compile `prebuilt_common`. - Every test that is not ignored in the 72 of those targets that need no Docker and in the three targets that compile `update_fixture` (`self_update_e2e`, `self_update_failures_e2e`, `update`): 2623 pass. Two old-toolchain tests of `e2e_vendor_cargo_build` fail the same way without this change on that machine, whose rustup holds an x86_64 toolchain it cannot execute. Left out: nothing ran on Windows, where every Go fixture whose module cache the service lists is now packed from the module's own directory in place of the stand-in. That needs a Windows run of the CLI suites. The global crawl still reads the Coursier and Ivy caches of the process environment; that is the product's behaviour and is unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- The Maven global-crawl assertion keeps only the packages whose path is under the test's own repository and compares them with the three expected purls exactly, so the machine's Coursier and Ivy caches cannot satisfy or break it and an extra or duplicate package is caught. - The fixture server matches a Go module directory from a path-component boundary, so the directory of a module on a longer host (sigs.k8s.io/x for k8s.io/x) is no longer taken. - It applies Go's case escaping to the module path and the version before comparing, so a purl with an upper-case letter finds its directory (github.com/Azure is github.com/!azure in the module cache). - It prints one line naming the purl and the cache when it archives the package_layout stand-in although the test handed over a cache for that ecosystem; this stays a notice because two tests of vendor_rerun_no_network_e2e hand over a Cargo home without the crate on purpose. - The served-binary size assertion checks the bytes as served, so the trailer counts only where it is appended and the check is the updater's own on every platform. - That assertion reads the updater's MAX_BINARY_BYTES, now #[doc(hidden)] pub, in place of a second hard-coded copy, and its message names the cause for any profile. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryLow Risk Overview Maven crawler — Prebuilt fixture server — Go module lookup in Self-update fixture — No runtime product behavior changes beyond exposing that constant for tests. Reviewed by Cursor Bugbot for commit b09019c. Configure here. |
|
[agent] PR shepherd: review brief What it does Risk: low. Only test code changes, plus one product line: Look here
Verified
Changes I made: none. Open questions: none. Generated by Claude Code |
No user-visible change.
Three test fixes in four files, +249 / -23, in two commits (the second answers the code review below). One line of product code changes: a constant of the updater becomes public and doc-hidden so that a test fixture can read it. No behaviour changes. The fixes came out of the Bazel work and none of them is about Bazel: each is about a test that passed or failed for a reason outside the code under test.
What it contains
crates/socket-patch-core/src/crawlers/maven_crawler.rs: a unit test counted the machine's caches.project_mode_crawl_keeps_only_the_projects_graphwanted exactly 3 packages from a global crawl. A global crawl also reads the Coursier and Ivy caches that the process environment names (HOME,COURSIER_CACHE, the JVM option sources), whichJvmEnvdoes not pin, so the count depended on the machine: with one package in a Coursier cache underHOMEit is 4 and the test fails. The test now keeps the crawled packages whose path is under its own repository and compares them with the three expected purls exactly. It pins no process environment: the Maven repository is crawled before those caches and the first copy of a purl wins. It still fails if a global crawl is scoped to the project.crates/socket-patch-cli/tests/prebuilt_common/mod.rs: the tests' patch service could serve a stand-in for a Go module without saying so.source_dirpicks the directory a Go module's archive is packed from by comparing each listed directory with the purl's<module>@<version>. Three things were wrong with the comparison:\, a module path has/, so nothing matched there. The separator is now normalized.sigs.k8s.io/xfork8s.io/x) was accepted. It now starts at a path-component boundary.github.com/Azureis stored asgithub.com/!azure), so a purl with an upper-case letter never matched. The module path and the version are now escaped before comparing; the rule mirrorsgo_crawler::encode_module_path.When nothing matches, the service still archives the
package_layoutstand-in (ago.modand the patched files, none of the module's own), because two tests ofvendor_rerun_no_network_e2ehand over a Cargo home without the crate on purpose. It now prints one line that names the purl and the cache whenever it does so although a cache for that ecosystem was handed over.crates/socket-patch-cli/tests/common/update_fixture.rsandcrates/socket-patch-core/src/update/download.rs: the self-update fixture names a binary that is too large to serve.make_served_binaryserves the builtsocket-patchas the release payload, and the updater refuses an extracted binary above 256 MiB (MAX_BINARY_BYTES). A build above the cap failed every test that serves it with "exceeds the 268435456-byte cap", far from the cause (#2071 fixed one such build). The fixture now asserts the size of the bytes as served, which is the updater's own comparison on every platform, and says that the build carries too much debug info for the fixture. It reads the updater's constant, which is now#[doc(hidden)] pub, in place of a second hard-coded copy.What it proves in CI
coverage(required, Linux) runs every test of the workspace that is neither ignored nor behind thedocker-e2efeature: the Maven unit test, the self-update suites with the new assertion, and the six self-tests ofprebuilt_commonin each of the 72 CLI test targets that compile it without that feature.clippyjob's second step,cargo check --workspace --all-targets --all-features, type-checks the changed code in every target, the six Docker ones included.windows-compile-checktype-checks the helper and its self-tests on Windows. It does not run them.ci.ymlwithos=windowson the final head is where the self-tests and the Go fixture suites run on Windows: https://github.com/SocketDev/socket-patch/actions/runs/43962290418 (green: 48 jobs, none failed)ci.ymlwithos=macoson the final head runs the same tests on a macOS runner: https://github.com/SocketDev/socket-patch/actions/runs/43962297386 (green: 56 jobs, none failed)gradle-compatibility.ymlandbench.ymlmatch, so those two workflows start on the pull request as well.CI cannot show the Maven test's old failure: it needs a machine with a Coursier or Ivy cache in the home directory.
Checked locally (macOS arm64)
prebuilt_commonand need no Docker, plusself_update_e2e,self_update_failures_e2eandupdate: 2893 passed, 194 ignored, 2 failed. The two failures are old-toolchain tests ofe2e_vendor_cargo_build('cargo': Bad CPU type in executable): that machine's rustup holds x86_64 toolchains it cannot execute, and they fail the same way on main.cargo fmt --all -- --check,cargo clippy --locked --workspace --all-features -- -D warningsandcargo check --locked --workspace --all-targets --all-featurespass.What it changes for a user
Nothing.
socket_patch_core::update::download::MAX_BINARY_BYTESbecomes public and doc-hidden; its value and every use of it are unchanged.Code review
/code-review highran on the first commit and reported seven findings, none of them a product bug; the second commit answers all of them.make_served_binary, and 19 of the 31 tests that call it never have the updater extract the bytes (dry runs, checksum and download failures, refusals). An over-cap build fails those too, with the one clear message, because such a build cannot be served by this fixture at all.What it leaves out
e2e_vendor_cargo_buildtests that depend on which rustup toolchains a machine can execute are not fixed here.🤖 Generated with Claude Code