Gradle: disable the no-repositories metadata test only when a mirror is injected - #8664
Open
Niloyyy wants to merge 1 commit into
Open
Gradle: disable the no-repositories metadata test only when a mirror is injected#8664Niloyyy wants to merge 1 commit into
Niloyyy wants to merge 1 commit into
Conversation
…is injected cannotDownloadMetaDataWhenNoRepositoriesAreDefined has carried a blanket @disabled since openrewrite#7566, so it runs nowhere -- not in CI, and not for anyone building without a mirror configured. It fails under a mirror for a specific reason: the test asserts that a build file declaring no repositories produces an "Unable to download metadata" marker, and OpenRewriteModelBuilder.mirrorScriptSnippet() prepends the mirror to project.repositories via gradle.beforeProject when the mirror env vars are set. The build then has a repository, guava metadata resolves, and the recipe upgrades to 30.1.1-jre instead of marking. That is the same situation EffectiveGradleRepositoriesTest.emptyRepositories and FindRepositoryOrderTest.emptyRepositories are in, so use the conditional disable openrewrite#7566 gave those two, reusing their disabledReason verbatim. The test stays skipped in CI and runs everywhere else.
This was referenced Aug 26, 2026
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.
What's changed?
UpgradeDependencyVersionTest.cannotDownloadMetaDataWhenNoRepositoriesAreDefinedhas carried a blanket@Disabledsince Provide Artifactory credentials to CI #7566, so it runs nowhere — not in CI, and not for anyone building without a mirror configured. It's the last@Disabled("...temporarily disabled after Artifactory introduction")left inrewrite-gradle.This swaps it for the conditional disable that Provide Artifactory credentials to CI #7566 already applied to the two tests in the same situation.
Why it fails under a mirror
The test asserts that a build file declaring no repositories produces an
Unable to download metadatamarker. WhenREWRITE_GRADLE_MIRROR_URL/_USERNAME/_PASSWORDare all set,OpenRewriteModelBuilder.mirrorScriptSnippet()prepends the mirror toproject.repositoriesviagradle.beforeProject:So the embedded build no longer has zero repositories, guava metadata resolves, and the recipe upgrades instead of marking. Simply deleting the
@Disabledreddens CI — with the mirror env set locally (pointed at Maven Central, standing in for Artifactory):EffectiveGradleRepositoriesTest.emptyRepositoriesandFindRepositoryOrderTest.emptyRepositoriesare in, and Provide Artifactory credentials to CI #7566 gave those two a conditional disable rather than a blanket one. This applies the same annotation, reusing theirdisabledReasonverbatim because the scenario is identical.What it costs
This does not make the test run in CI. CI always sets the mirror, so it stays skipped there — same as the two
emptyRepositoriestests. What it buys is that the test runs for every contributor and downstream build without a mirror, instead of being dead everywhere.If you'd rather have the scenario covered in CI too, the alternative is to make the assertion tolerate an injected repository (or to suppress injection for this one build), which is a larger change to
OpenRewriteModelBuilder— happy to take that on instead if you prefer it.Tests
Verified all four combinations locally on
f90af07:REWRITE_GRADLE_MIRROR_URL@Disabled(before)@DisabledIfEnvironmentVariable(after)@DisabledIfEnvironmentVariable(after)The middle two are the point: the test is sound off-mirror, and the guard is doing real work rather than being decorative.
The full
UpgradeDependencyVersionTestclass passes with the change: 110 tests, 0 failures, 0 errors, 0 skipped (no mirror configured, so the guarded test runs).Any additional context
moderne-gradle-plugin:0.2.1in Artifactory #7576. This does not fix that issue — the two tests named there,ChangeDependencyTest.changeDependencyWithLowerVersionAfterandChangePluginTest.changeApplyPluginSyntax, were re-enabled in Re-enabling some tests in rewrite-gradle #7999 and are green onmaintoday. The remaining five@Disabled("...Artifactory introduction")tests are all inrewrite-maven; I haven't investigated their root causes and deliberately left them alone.