Skip to content

Commit

Permalink
Shorten caching tests (#1211)
Browse files Browse the repository at this point in the history
* Tweak MinimizationCachingTest

* Tweak RelocationCachingTest

* Tweak ShadowJarCachingTest
  • Loading branch information
Goooler authored Jan 28, 2025
1 parent 83ca343 commit 529edc1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,21 @@ class MinimizationCachingTest : BaseCachingTest() {
}
""".trimIndent(),
)

assertFirstExecutionSuccess()
assertThat(outputShadowJar).useAll {
containsEntries(
"server/Server.class",
"junit/framework/Test.class",
)
doesNotContainEntries(
"client/Client.class",
)
val assertions = {
assertThat(outputShadowJar).useAll {
containsEntries(
"server/Server.class",
"junit/framework/Test.class",
)
doesNotContainEntries(
"client/Client.class",
)
}
}

assertFirstExecutionSuccess()
assertions()
assertExecutionsAreCachedAndUpToDate()
assertThat(outputShadowJar).useAll {
containsEntries(
"server/Server.class",
"junit/framework/Test.class",
)
doesNotContainEntries(
"client/Client.class",
)
}
assertions()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,21 @@ class RelocationCachingTest : BaseCachingTest() {
}
""".trimIndent(),
)

assertFirstExecutionSuccess()
assertThat(outputShadowJar).useAll {
containsEntries(
"shadow/Main.class",
"foo/junit/framework/Test.class",
)
doesNotContainEntries(
"junit/framework/Test.class",
)
val assertions = {
assertThat(outputShadowJar).useAll {
containsEntries(
"shadow/Main.class",
"foo/junit/framework/Test.class",
)
doesNotContainEntries(
"junit/framework/Test.class",
)
}
}

assertFirstExecutionSuccess()
assertions()
assertExecutionsAreCachedAndUpToDate()
assertThat(outputShadowJar).useAll {
containsEntries(
"shadow/Main.class",
"foo/junit/framework/Test.class",
)
doesNotContainEntries(
"junit/framework/Test.class",
)
}
assertions()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ class ShadowJarCachingTest : BaseCachingTest() {
assertFirstExecutionSuccess()
assertExecutionsAreCachedAndUpToDate()

val replaced = projectScriptPath.readText().lines().filter {
it != fromJar(projectJar)
}.joinToString(System.lineSeparator())
val replaced = projectScriptPath.readText().lines()
.filterNot { it == fromJar(projectJar) }
.joinToString(System.lineSeparator())
projectScriptPath.writeText(replaced)

assertFirstExecutionSuccess()
assertExecutionsAreCachedAndUpToDate()
}

@Test
Expand All @@ -45,6 +47,7 @@ class ShadowJarCachingTest : BaseCachingTest() {
)

assertFirstExecutionSuccess()
assertThat(outputShadowJar).isRegular()

projectScriptPath.appendText(
"""
Expand All @@ -53,6 +56,7 @@ class ShadowJarCachingTest : BaseCachingTest() {
}
""".trimIndent(),
)

assertExecutionsAreCachedAndUpToDate()
assertThat(jarPath("build/libs/foo-1.0-all.jar")).isRegular()
}
Expand Down Expand Up @@ -154,6 +158,7 @@ class ShadowJarCachingTest : BaseCachingTest() {

@Test
fun shadowJarIsCachedCorrectlyWhenUsingDependencyIncludesExcludes() {
writeMainClass(withImports = true)
projectScriptPath.appendText(
"""
dependencies {
Expand All @@ -162,8 +167,6 @@ class ShadowJarCachingTest : BaseCachingTest() {
""".trimIndent() + System.lineSeparator(),
)

writeMainClass(withImports = true)

assertFirstExecutionSuccess()
assertThat(outputShadowJar).useAll {
containsEntries(
Expand All @@ -181,24 +184,20 @@ class ShadowJarCachingTest : BaseCachingTest() {
}
""".trimIndent(),
)
assertFirstExecutionSuccess()
assertThat(outputShadowJar).useAll {
containsEntries(
"shadow/Main.class",
)
doesNotContainEntries(
"junit/framework/Test.class",
)
val assertions = {
assertThat(outputShadowJar).useAll {
containsEntries(
"shadow/Main.class",
)
doesNotContainEntries(
"junit/framework/Test.class",
)
}
}

assertFirstExecutionSuccess()
assertions()
assertExecutionsAreCachedAndUpToDate()
assertThat(outputShadowJar).useAll {
containsEntries(
"shadow/Main.class",
)
doesNotContainEntries(
"junit/framework/Test.class",
)
}
assertions()
}
}

0 comments on commit 529edc1

Please sign in to comment.