@@ -82,11 +82,28 @@ class MuzzleDependencyAgeFunctionalTest : MuzzlePluginTestFixture() {
8282 assertThat(eligible.task(" ${assertionPrefix} 1.0.0" )?.outcome).isEqualTo(SUCCESS )
8383 }
8484
85- @Test
86- fun `reconsiders publication timestamps when configuration caching is requested` () {
85+ @ParameterizedTest
86+ @ValueSource(booleans = [false , true ])
87+ fun `cached graphs revalidate newly eligible releases` (incompatible : Boolean ) {
8788 fixture.publishVersions(" com.example.test" , " demo-lib" , listOf (" 1.0.0" ))
8889 fixture.publishVersions(" com.example.test" , " demo-lib" , listOf (" 1.1.0" ), publishedAt = Instant .now())
8990 writeProject(libraryProject(fixture))
91+ if (incompatible) {
92+ writeScanPlugin(
93+ """
94+ try (java.io.InputStream input = testApplicationClassLoader.getResourceAsStream(
95+ "META-INF/maven/com.example.test/demo-lib/pom.properties")) {
96+ java.util.Properties properties = new java.util.Properties();
97+ properties.load(input);
98+ if ("1.1.0".equals(properties.getProperty("version"))) {
99+ throw new IllegalStateException("Newly eligible version is incompatible");
100+ }
101+ } catch (java.io.IOException e) {
102+ throw new AssertionError(e);
103+ }
104+ """
105+ )
106+ }
90107
91108 val first = runMuzzle(" --configuration-cache" )
92109 assertThat(first.output).contains(" BUILD SUCCESSFUL" , " Configuration cache entry stored" )
@@ -100,43 +117,14 @@ class MuzzleDependencyAgeFunctionalTest : MuzzlePluginTestFixture() {
100117 val pom = fixture.repoDir.resolve(" com/example/test/demo-lib/1.1.0/demo-lib-1.1.0.pom" )
101118 check(pom.setLastModified(Instant .now().minusSeconds(72 * 3600L ).toEpochMilli()))
102119
103- val second = runMuzzle(" --configuration-cache" )
104- assertThat(second.output).contains(" BUILD SUCCESSFUL" ).doesNotContain(" Reusing configuration cache" )
105- assertThat(second.task(" ${assertionPrefix} 1.1.0" )?.outcome).isEqualTo(SUCCESS )
106- }
107-
108- @Test
109- fun `a deferred incompatible release fails validation after becoming eligible with configuration caching` () {
110- fixture.publishVersions(" com.example.test" , " demo-lib" , listOf (" 1.0.0" ))
111- fixture.publishVersions(" com.example.test" , " demo-lib" , listOf (" 1.1.0" ), publishedAt = Instant .now())
112- writeProject(libraryProject(fixture))
113- writeScanPlugin(
114- """
115- try (java.io.InputStream input = testApplicationClassLoader.getResourceAsStream(
116- "META-INF/maven/com.example.test/demo-lib/pom.properties")) {
117- java.util.Properties properties = new java.util.Properties();
118- properties.load(input);
119- if ("1.1.0".equals(properties.getProperty("version"))) {
120- throw new IllegalStateException("Newly eligible version is incompatible");
121- }
122- } catch (java.io.IOException e) {
123- throw new AssertionError(e);
124- }
125- """
126- )
127-
128- val first = runMuzzle(" --configuration-cache" )
129- assertThat(first.output).contains(" BUILD SUCCESSFUL" , " Configuration cache entry stored" )
130- assertThat(first.task(" ${assertionPrefix} 1.1.0" )).isNull()
131-
132- val pom = fixture.repoDir.resolve(" com/example/test/demo-lib/1.1.0/demo-lib-1.1.0.pom" )
133- check(pom.setLastModified(Instant .now().minusSeconds(72 * 3600L ).toEpochMilli()))
134-
135- val second = runMuzzle(" --configuration-cache" , expectFailure = true )
136- assertThat(second.output).contains(" Muzzle validation failed" ).doesNotContain(" Reusing configuration cache" )
137- assertThat(second.task(" ${assertionPrefix} 1.1.0" )?.outcome).isEqualTo(FAILED )
138- assertThat(resultFile(" muzzle-AssertPass-com.example.test-demo-lib-1.1.0" ).toFile().readText())
139- .contains(" Newly eligible version is incompatible" )
120+ val second = runMuzzle(" --configuration-cache" , expectFailure = incompatible)
121+ assertThat(second.output).doesNotContain(" Reusing configuration cache" )
122+ .contains(if (incompatible) " Muzzle validation failed" else " BUILD SUCCESSFUL" )
123+ assertThat(second.task(" ${assertionPrefix} 1.1.0" )?.outcome).isEqualTo(if (incompatible) FAILED else SUCCESS )
124+ if (incompatible) {
125+ assertThat(resultFile(" muzzle-AssertPass-com.example.test-demo-lib-1.1.0" ).toFile().readText())
126+ .contains(" Newly eligible version is incompatible" )
127+ }
140128 }
141129
142130 @Test
@@ -190,24 +178,6 @@ class MuzzleDependencyAgeFunctionalTest : MuzzlePluginTestFixture() {
190178 .containsExactlyElementsOf(first.tasks.filter { it.path.startsWith(assertionPrefix) }.map { it.path })
191179 }
192180
193- @Test
194- fun `core JDK checks reuse configuration cache without publication lookups` () {
195- writeProject(
196- """
197- plugins { id("java"); id("dd-trace-java.muzzle") }
198- muzzle { pass { coreJdk() } }
199- """
200- )
201-
202- val first = runMuzzle(" --configuration-cache" )
203- val second = runMuzzle(" --configuration-cache" )
204-
205- assertThat(first.output).contains(" BUILD SUCCESSFUL" , " Configuration cache entry stored" )
206- assertThat(second.output).contains(" BUILD SUCCESSFUL" , " Reusing configuration cache" )
207- assertThat(first.task(" $task -AssertPass-core-jdk" )?.outcome).isEqualTo(SUCCESS )
208- assertThat(second.output).doesNotContain(" Muzzle deferring" , " Muzzle retaining" )
209- }
210-
211181 @Test
212182 fun `invalid cooldown fails before dependency resolution` () {
213183 writeProject(libraryProject(fixture))
0 commit comments