Skip to content

Commit

Permalink
Separate long-running tests into a separate tag which is always teste…
Browse files Browse the repository at this point in the history
…d in CI
  • Loading branch information
NotStirred committed Jun 26, 2024
1 parent 9332214 commit 37e47dc
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/gradleBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/gradleBuildPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 30 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package io.github.opencubicchunks.cubicchunks.test;

import javax.annotation.ParametersAreNonnullByDefault;

import io.github.opencubicchunks.cc_core.annotation.MethodsReturnNonnullByDefault;

0 comments on commit 37e47dc

Please sign in to comment.