Skip to content

Commit

Permalink
Enable gametests
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Oct 12, 2024
1 parent a1814ad commit f57ce14
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 7 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ jobs:
if: ${{ env.COVERALLS_REPO_TOKEN }}
run: ./gradlew test jacocoTestReport coveralls
- name: 'Game Test'
env:
GAME_TEST: ${{ secrets.GAME_TEST }}
if: ${{ env.GAME_TEST }}
run: ./gradlew runGameTestServer
run: ./gradlew runGameTestServer -x :loader-forge:downloadAssets
- name: 'Deploy as GitHub CI artifacts'
uses: actions/upload-artifact@v4
with:
Expand Down
11 changes: 11 additions & 0 deletions buildSrc/src/main/groovy/multiloader-loader-fabric.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,20 @@ loom {
ideConfigGenerated(true)
runDir('runs/server')
}
gameTest {
server()
setConfigName('Loader-fabric: GameTestServer')
ideConfigGenerated(true)
runDir('runs/gametest')
vmArg "-Dfabric-api.gametest"
}
}
}

task runGameTestServer {
dependsOn tasks.runGameTest
}

publishing {
publications { PublicationContainer publicationContainer ->
publicationContainer.getByName("maven") { MavenPublication publication ->
Expand Down
16 changes: 16 additions & 0 deletions buildSrc/src/main/groovy/multiloader-loader-forge.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ minecraft {

runs {
client {
property 'forge.enabledGameTestNamespaces', "cyclopscore,${mod_id}"
workingDirectory file('runs/client')
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'Client'
Expand All @@ -63,6 +64,8 @@ minecraft {
}

server {
property 'forge.enabledGameTestNamespaces', "cyclopscore,${mod_id}"
args '--nogui'
workingDirectory file('runs/server')
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'Server'
Expand All @@ -73,6 +76,18 @@ minecraft {
}
}

gameTestServer {
property 'forge.enabledGameTestNamespaces', "cyclopscore,${mod_id}"
workingDirectory file('runs/gametest')
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'runGameTestServer'
mods {
modDataRun {
source sourceSets.main
}
}
}

data {
workingDirectory file('runs/data')
ideaModule "${rootProject.name}.${project.name}.main"
Expand Down Expand Up @@ -108,3 +123,4 @@ sourceSets.forEach {
it.output.resourcesDir = dir
it.java.destinationDirectory = dir
}

6 changes: 3 additions & 3 deletions buildSrc/src/main/groovy/multiloader-loader-neoforge.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ runs {
}

client {
systemProperty 'neoforge.enabledGameTestNamespaces', mod_id
systemProperty 'neoforge.enabledGameTestNamespaces', "cyclopscore,${mod_id}"
}

server {
systemProperty 'neoforge.enabledGameTestNamespaces', mod_id
systemProperty 'neoforge.enabledGameTestNamespaces', "cyclopscore,${mod_id}"
programArgument '--nogui'
}

gameTestServer {
systemProperty 'neoforge.enabledGameTestNamespaces', mod_id
systemProperty 'neoforge.enabledGameTestNamespaces', "cyclopscore,${mod_id}"
}

data {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.cyclops.cyclopscore.gametest;

import net.minecraft.gametest.framework.GameTest;
import net.minecraft.gametest.framework.GameTestHelper;
import org.cyclops.cyclopscore.Reference;

/**
* @author rubensworks
*/
public class StartupTestFabric {

@GameTest(template = Reference.MOD_ID + ":empty")
public void testDummy(GameTestHelper helper) {
// A dummy test to ensure the server starts properly
helper.succeed();
}

}
3 changes: 3 additions & 0 deletions loader-fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"entrypoints": {
"main": [
"org.cyclops.cyclopscore.CyclopsCoreFabric"
],
"fabric-gametest": [
"org.cyclops.cyclopscore.gametest.StartupTestFabric"
]
},
"accessWidener" : "cyclopscore.accesswidener",
Expand Down
14 changes: 14 additions & 0 deletions loader-forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ minecraft {
}
}

gameTestServer {
property 'forge.enableGameTest', 'true'
property 'forge.enabledGameTestNamespaces', mod_id
workingDirectory file('runs/gametest')
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'runGameTestServer'
mods {
modDataRun {
source sourceSets.main
source sourceSets.api
}
}
}

data {
workingDirectory file('runs/data')
ideaModule "${rootProject.name}.${project.name}.main"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.cyclops.cyclopscore.gametest;

import net.minecraft.gametest.framework.GameTest;
import net.minecraft.gametest.framework.GameTestHelper;
import net.minecraftforge.gametest.GameTestHolder;
import org.cyclops.cyclopscore.Reference;

/**
* @author rubensworks
*/
@GameTestHolder(Reference.MOD_ID)
public class StartupTestForge {

@GameTest(template = Reference.MOD_ID + ":empty")
public void testDummy(GameTestHelper helper) {
// A dummy test to ensure the server starts properly
helper.succeed();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.cyclops.cyclopscore.gametest;

import net.minecraft.gametest.framework.GameTest;
import net.minecraft.gametest.framework.GameTestHelper;
import net.neoforged.neoforge.gametest.GameTestHolder;
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
import org.cyclops.cyclopscore.Reference;

/**
* @author rubensworks
*/
@GameTestHolder(Reference.MOD_ID)
@PrefixGameTestTemplate(false)
public class StartupTestNeoForge {

@GameTest(template = "empty")
public void testDummy(GameTestHelper helper) {
// A dummy test to ensure the server starts properly
helper.succeed();
}

}

0 comments on commit f57ce14

Please sign in to comment.