From 37e47dca7a78501e3d5f22203036a51fec8a3102 Mon Sep 17 00:00:00 2001 From: Tom Martin Date: Wed, 26 Jun 2024 12:08:49 +0100 Subject: [PATCH 1/2] Separate long-running tests into a separate tag which is always tested in CI --- .github/workflows/gradleBuild.yml | 4 +- .github/workflows/gradleBuildPR.yml | 4 +- build.gradle | 40 ++++++++++++++----- .../level/IntegrationTestCubicChunkMap.java | 3 +- .../cubicchunks/test/LongRunTest.java | 16 ++++++++ .../cubicchunks/test/package-info.java | 7 ++++ 6 files changed, 61 insertions(+), 13 deletions(-) create mode 100644 src/test/java/io/github/opencubicchunks/cubicchunks/test/LongRunTest.java create mode 100644 src/test/java/io/github/opencubicchunks/cubicchunks/test/package-info.java diff --git a/.github/workflows/gradleBuild.yml b/.github/workflows/gradleBuild.yml index 510e207b..ff9ebb4c 100644 --- a/.github/workflows/gradleBuild.yml +++ b/.github/workflows/gradleBuild.yml @@ -26,7 +26,9 @@ jobs: with: java-version: 17 - name: Build with Gradle - run: ./gradlew build + run: ./gradlew build -x test + - name: Run tests + run: ./gradlew check - uses: actions/upload-artifact@v2 with: name: Compiled jars diff --git a/.github/workflows/gradleBuildPR.yml b/.github/workflows/gradleBuildPR.yml index 27a44d70..dd669c05 100644 --- a/.github/workflows/gradleBuildPR.yml +++ b/.github/workflows/gradleBuildPR.yml @@ -23,4 +23,6 @@ jobs: with: java-version: 17 - name: Build with Gradle - run: ./gradlew build + run: ./gradlew build -x test + - name: Run tests + run: ./gradlew check diff --git a/build.gradle b/build.gradle index 8d35f58b..984efc12 100644 --- a/build.gradle +++ b/build.gradle @@ -257,15 +257,6 @@ dependencies { testImplementation("org.hamcrest:hamcrest:2.2") } -test { - useJUnitPlatform() - testLogging { - events "passed", "skipped", "failed" - } - jvmArgs("-ea", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true", "-Dmixin.checks.interfaces=true") - exclude "**/mixin*" -} - tasks.withType(ProcessResources).configureEach { var replaceProperties = [ minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range, @@ -313,7 +304,9 @@ test { maxHeapSize = "2048M" dependsOn(project.tasks.named("unzipTests")) - useJUnitPlatform() + useJUnitPlatform { + excludeTags "longRunTest" + } // Always run tests, even when nothing changed. dependsOn("cleanTest") @@ -322,6 +315,33 @@ test { testLogging { events("passed", "skipped", "failed") } + + jvmArgs("-ea", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true", "-Dmixin.checks.interfaces=true") + exclude "**/mixin*" +} + +def longRunTest = tasks.register("longRunTest", Test) { + minHeapSize = "512M" + maxHeapSize = "2048M" + + useJUnitPlatform { + includeTags "longRunTest" + } + + // Show test results. + testLogging { + events("passed", "skipped", "failed") + } + + jvmArgs("-ea", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true", "-Dmixin.checks.interfaces=true") + exclude "**/mixin*" + + group = "Verification" + shouldRunAfter test +} + +tasks.named("check") { + dependsOn longRunTest } publishing { diff --git a/src/test/java/io/github/opencubicchunks/cubicchunks/integrationtest/server/level/IntegrationTestCubicChunkMap.java b/src/test/java/io/github/opencubicchunks/cubicchunks/integrationtest/server/level/IntegrationTestCubicChunkMap.java index b211aac4..c0aa6aae 100644 --- a/src/test/java/io/github/opencubicchunks/cubicchunks/integrationtest/server/level/IntegrationTestCubicChunkMap.java +++ b/src/test/java/io/github/opencubicchunks/cubicchunks/integrationtest/server/level/IntegrationTestCubicChunkMap.java @@ -17,11 +17,11 @@ import io.github.opencubicchunks.cubicchunks.mixin.test.common.server.level.ChunkHolderTestAccess; import io.github.opencubicchunks.cubicchunks.mixin.test.common.server.level.ChunkMapTestAccess; import io.github.opencubicchunks.cubicchunks.mixin.test.common.server.level.ServerChunkCacheTestAccess; +import io.github.opencubicchunks.cubicchunks.test.LongRunTest; import io.github.opencubicchunks.cubicchunks.testutils.BaseTest; import io.github.opencubicchunks.cubicchunks.testutils.CloseableReference; import io.github.opencubicchunks.cubicchunks.world.level.chunklike.CloPos; import io.github.opencubicchunks.cubicchunks.world.level.cube.LevelCube; -import net.minecraft.Util; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkLevel; import net.minecraft.server.level.ChunkMap; @@ -251,6 +251,7 @@ public void testSingleChunkAllDependenciesForStatus(ChunkStatus status) throws E /** * Load a single cube at full status */ + @LongRunTest @Test public void singleFullCube() throws Exception { try(var serverChunkCacheRef = createServerChunkCache()) { var serverChunkCache = serverChunkCacheRef.value(); diff --git a/src/test/java/io/github/opencubicchunks/cubicchunks/test/LongRunTest.java b/src/test/java/io/github/opencubicchunks/cubicchunks/test/LongRunTest.java new file mode 100644 index 00000000..697c5737 --- /dev/null +++ b/src/test/java/io/github/opencubicchunks/cubicchunks/test/LongRunTest.java @@ -0,0 +1,16 @@ +package io.github.opencubicchunks.cubicchunks.test; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.junit.jupiter.api.Tag; + +@Target({ TYPE, METHOD }) +@Retention(RUNTIME) +@Tag("longRunTest") +public @interface LongRunTest { +} diff --git a/src/test/java/io/github/opencubicchunks/cubicchunks/test/package-info.java b/src/test/java/io/github/opencubicchunks/cubicchunks/test/package-info.java new file mode 100644 index 00000000..692ea219 --- /dev/null +++ b/src/test/java/io/github/opencubicchunks/cubicchunks/test/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +package io.github.opencubicchunks.cubicchunks.test; + +import javax.annotation.ParametersAreNonnullByDefault; + +import io.github.opencubicchunks.cc_core.annotation.MethodsReturnNonnullByDefault; From 54d33433ab117c5bfd2bf4d566199dc720fb4ba1 Mon Sep 17 00:00:00 2001 From: Tom Martin Date: Thu, 27 Jun 2024 13:28:37 +0100 Subject: [PATCH 2/2] Fix implicit dependency created by unzipTests modifying the input directory of longRunTest --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 984efc12..a9dbf522 100644 --- a/build.gradle +++ b/build.gradle @@ -337,7 +337,8 @@ def longRunTest = tasks.register("longRunTest", Test) { exclude "**/mixin*" group = "Verification" - shouldRunAfter test + mustRunAfter project.tasks.named("unzipTests") + shouldRunAfter project.tasks.named("test") } tasks.named("check") {