Repository navigation
Make the Gradle --global-prefix tests fail when the flag is ignored - #2267
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Conversation
Opens the branch for #1982: three Gradle tests named for --global-prefix pass with the flag's handling broken, because their harness hands the CLI the same cache through GRADLE_USER_HOME. Assisted-by: Claude Code
Three tests named for --global-prefix passed with the flag's handling broken, because their harness also set GRADLE_USER_HOME to the cache the prefix names (or, for the scan note, to a stand-in that silences the note either way): - gradle_agent_cli::global_prefix_apply_vex_rollback and the real- Gradle e2e_gradle_agent_build::gradle_agent_global_prefix passed with the Maven crawler ignoring the prefix for JVM caches. Project discovery reached the same cache through GRADLE_USER_HOME. - e2e_gradle_discovery_build's global_prefix_scan_says_nothing_about_the_user_home passed with scan emitting gradle_user_home_differs under --global-prefix. The note is never emitted while GRADLE_USER_HOME is set, and the harness always set it. The two apply/vex/rollback tests now run the CLI under another, empty Gradle user home, so only the prefix names the cache, and first check that an apply without the prefix leaves the jar alone. The scan test runs with no GRADLE_USER_HOME, as its helper's doc already said None meant, and checks first that a --global scan does print the note. Test code only. Each test fails on its mutation and passes on the unchanged production code. Fixes #1982. Assisted-by: Claude Code
From review of the previous commit. The control apply of the two apply/vex/rollback tests only checked that the jar stayed pristine, which an apply failing for another reason would also satisfy. It now checks the run skipped the package as package_not_installed, and the real-Gradle test checks that it compared at least one cached jar. The scan test's control reads the account's own Gradle cache, so its failure message prints the warnings and not the whole envelope, which lists that cache's packages. The real-Gradle test's closure no longer shadows the suite's ok() helper. Refs #1982. Assisted-by: Claude Code
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview The agent and e2e harnesses used to point
Reviewed by Cursor Bugbot for commit f26c483. Configure here. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit f26c483. Configure here.
|
[agent] CI on It is The changed tests ran and passed here: Generated by Claude Code |
|
[agent] PR shepherd: review brief for approval What it does. Test-only change for #1982. Three Gradle tests named for Risk: low. Only tests change, in Look here
Verified
Changes I made: none. Generated by Claude Code |
LLM Description written by Claude Code
Fixes #1982.
Problem
Three Gradle tests are named for
--global-prefix, and all three pass with the flag's handling broken:gradle_agent_cli::global_prefix_apply_vex_rollback(fabricated cache, every platform)apply,vexandrollbackreach the cache the prefix namesrun()setsGRADLE_USER_HOMEto that same cache, so project discovery reaches it with the flag ignorede2e_gradle_agent_build::gradle_agent_global_prefix(real Gradle)socket()setsGRADLE_USER_HOMEto the cell's home, the cache the prefix namese2e_gradle_discovery_build::global_prefix_scan_says_nothing_about_the_user_homescan --global-prefixnever printsgradle_user_home_differsGRADLE_USER_HOMEis set, andjvm_env::isolate_clialways sets itSo no CLI test fails when
apply,vexorrollbackignore--global-prefixfor a Gradle cache, or whenscan --global-prefixstarts printing the note thatCLI_CONTRACT.mdsays is "never emitted with--global-prefix". Someone who changes the JVM cache-root selection or the note's guard gets a green run either way. No user sees a wrong result today.Evidence on
main(cfc870f)Two one-line mutations of production code, never committed:
With the first mutation, on
main's tests:With the second alone:
Fix
Test code only.
apply/vex/rollbacktests run the CLI under another, empty Gradle user home, so only the prefix names the cache. Each first runsapply --offlinewithout the prefix as a control and checks it skips the package aspackage_not_installedand leaves the jar pristine. The real build in the e2e test still uses the cell's home.GRADLE_USER_HOME, which its helper's doc already saidNonemeant. It first runs a--global --ecosystems mavenscan as a control and checks that scan does print the note, then checks the--global-prefixscan does not.Red, then green
The same mutations with this PR's tests:
The crawler mutation stops all three commands at
apply. To show thevexandrollbackassertions hold on their own, I dropped--global-prefixfrom one call at a time inglobal_prefix_apply_vex_rollback: without it onvexthe test fails atout.ok()(exit 1,no_applicable_patches), and without it onrollbackat the finalpristine_jar()comparison (the jar stays patched).On the unchanged production code all three pass.
Deleted
Nothing.
Behavior change
None. No production code is changed.
Risk
<passwd home>/.gradle. I see no way around that without a test seam in production code. The control is a--globalscan, which only reports. It asserts nothing about what that cache holds, and its failure message printswarnings[]only. I ran it with a fabricated module in/root/.gradle/caches/modules-2/files-2.1: the test passes, and the--global-prefixscan still queries exactly the fixture's package. On a machine with a large~/.gradlethis one test takes as long as a global Maven scan of it.--global-prefixhalf is as weak as before. It ran on Linux in this PR'scoveragejobs; the macOStestlegs do not run per PR push.cfg(unix)orcfg(windows)code changed.Review
/code-review highfound no correctness bug and four smaller things:applyonly checked that the jar stayed pristine, which anapplyfailing for another reason also satisfies. It now checks thepackage_not_installedskip, and the e2e test checks that it compared at least one cached jar.ok()helper.scan_annotates_lock_membership_without_filteringalso passes--global-prefixwithGRADLE_USER_HOMEnaming the same cache. That test is about theinLockannotation of a global run, not about the prefix reaching the cache;scan --global-prefixreaching it is covered by thequeriedassertion of the scan test above, which needs the flag.Verification
f26c483: 81 of 83 checks pass, and Bugbot found no issues.coverage (1)andcoverage (2)ran the two fabricated-cache tests, and the Gradle 9.8.0e2eleg rangradle_agent_global_prefix.hosted-e2eand its aggregateci-okfail on CI: hosted-e2e gem leg fails on every PR: production published activestorage 6.0.3 patch 146ef6aa, not in GEM_UUIDS #2270 (production published a gem patch thate2e_hosted_productiondoes not pin), which this PR does not touch; the comment below has the output.cargo test -p socket-patch-cli --test gradle_agent_cli: 37 passed.cargo test -p socket-patch-cli --test e2e_gradle_discovery_build: 22 passed, 1 ignored.SOCKET_PATCH_GRADLE_E2E_REQUIRED=1 cargo test -p socket-patch-cli --test e2e_gradle_discovery_build --test e2e_gradle_agent_build -- --ignored gradle_agent_: 1 and 11 passed (before the review fixes;gradle_agent_global_prefixre-run after them).cargo test -p socket-patch-cli --test cli(the test-tree ratchets): 125 passed.rustfmt --checkon the three files: clean.cargo clippyover these test targets reports only what it reports onmain(tests/common,tests/prebuilt_common, and one signature ingradle_agent_cli.rsthis PR does not touch); CI's clippy does not lint test targets.Diff
3 files, +84 −11, all test code:
e2e_gradle_agent_build.rs+36 −5,gradle_agent_cli.rs+25 −5,e2e_gradle_discovery_build.rs+23 −1. Production +0 −0. No file here is changed by another openarch-refactor/oragent/PR.Generated by Claude Code