Repository navigation
Gradle: disable the no-repositories metadata test only when a mirror is injected - #8664
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.
|
Hey @timtebeek — you approved CI on #8666 a couple of weeks back and it came back green, but this one's never had a run, so it's been sitting here untested. Any chance you could kick off the workflows? And if the blanket The change is one annotation. One heads-up so the run doesn't look odd: it stays skipped in CI either way. What this buys is the test coming back for anyone building without a mirror. |
|
@timtebeek it's okay btw I was waiting for your review. Anyway thanks for merging. |
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.