Skip to content

Commit f33ae26

Browse files
committed
Let GameTest harness own benchmark shutdown
1 parent f220a3e commit f33ae26

11 files changed

Lines changed: 66 additions & 18 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ jobs:
132132
if-no-files-found: error
133133
retention-days: 30
134134
path: |
135-
build/libs/OreSpawn-4.0.15.120011.jar
136-
build/libs/OreSpawn-4.0.15.120011-sources.jar
137-
build/libs/OreSpawn-4.0.15.120011-javadoc.jar
135+
build/libs/OreSpawn-4.0.16.120011.jar
136+
build/libs/OreSpawn-4.0.16.120011-sources.jar
137+
build/libs/OreSpawn-4.0.16.120011-javadoc.jar
138138
build/release/SHA256SUMS
139139
CHANGELOG.txt
140140

CHANGELOG.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Version 4.0.16.120011
2+
3+
* Leave benchmark shutdown to the GameTest harness when a benchmark is run
4+
through Forge's GameTest server, preventing a null test-tracker crash and
5+
allowing the harness to report its real test result.
6+
* Ordinary dedicated benchmark servers still stop automatically when requested.
7+
18
Version 4.0.15.120011
29

310
* Classify generated geology and public geology samples through the same

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ End" policy used by mods such as Base Metals.
1717
This is not the unrelated mod that adds mobs and dimensions under the same
1818
name.
1919

20-
This branch builds target-qualified version `4.0.15.120011`: the OreSpawn 4.0.15
20+
This branch builds target-qualified version `4.0.16.120011`: the OreSpawn 4.0.16
2121
feature set for Minecraft 1.20.1 and Forge. See the
2222
[versioning policy](docs/VERSIONS.md) for the encoding and release convention.
2323

build.gradle

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ minecraft {
156156
}
157157
register('client')
158158
register('server') { args '--nogui' }
159+
register('gameTestServer') {
160+
workingDir.convention layout.buildDirectory.dir('gametest-benchmark-run')
161+
}
159162
register('data') {
160163
workingDir.convention layout.projectDirectory.dir('run-data')
161164
args '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/'),
@@ -237,6 +240,7 @@ tasks.withType(JavaExec).configureEach { JavaExec runTask ->
237240
Map<String, String> targets = [
238241
runClient: 'fmluserdevclient',
239242
runServer: 'fmluserdevserver',
243+
runGameTestServer: 'fmluserdevgametestserver',
240244
runData: 'fmluserdevdata',
241245
runSurfaceIntegrationFresh: 'fmluserdevserver',
242246
runSurfaceIntegrationReload: 'fmluserdevserver'
@@ -568,10 +572,26 @@ task verifyMineralogyOracleIsolation {
568572

569573
check.dependsOn verifyMineralogyOracleIsolation
570574

571-
['runClient', 'runServer', 'runData'].each { String taskName ->
575+
['runClient', 'runServer', 'runGameTestServer', 'runData'].each { String taskName ->
572576
tasks.matching { it.name == taskName }.all { JavaExec runTask ->
577+
if (taskName == 'runGameTestServer') {
578+
runTask.workingDir = file("${buildDir}/gametest-benchmark-run")
579+
}
573580
doFirst {
574581
new File(runTask.workingDir, 'mods').mkdirs()
582+
if (taskName == 'runGameTestServer') {
583+
new File(runTask.workingDir, 'server.properties').setText('''\
584+
level-name=gametest-benchmark-world
585+
level-seed=-4965128775892001975
586+
level-type=default
587+
online-mode=false
588+
server-port=0
589+
allow-nether=true
590+
generate-structures=false
591+
spawn-protection=0
592+
max-tick-time=-1
593+
''', 'UTF-8')
594+
}
575595
runTask.ext.oreSpawnCrashSnapshot = runtimeCrashSnapshot(runTask.workingDir)
576596
}
577597
doLast {
@@ -847,7 +867,7 @@ def preparedReleaseDir = providers.gradleProperty('preparedReleaseDir')
847867
tasks.register('verifyReleaseConfiguration') {
848868
group = 'verification'
849869
doLast {
850-
if (project.mod_version != '4.0.15.120011'
870+
if (project.mod_version != '4.0.16.120011'
851871
|| project.mod_group != expectedMavenGroup
852872
|| project.minecraft_version != '1.20.1'
853873
|| project.forge_version != '47.4.10'
@@ -861,9 +881,9 @@ tasks.register('verifyReleaseConfiguration') {
861881
throw new GradleException('Unexpected dispatcher or Java target metadata')
862882
}
863883
List<String> expectedPublicArtifacts = [
864-
'OreSpawn-4.0.15.120011.jar',
865-
'OreSpawn-4.0.15.120011-sources.jar',
866-
'OreSpawn-4.0.15.120011-javadoc.jar'
884+
'OreSpawn-4.0.16.120011.jar',
885+
'OreSpawn-4.0.16.120011-sources.jar',
886+
'OreSpawn-4.0.16.120011-javadoc.jar'
867887
]
868888
if (base.archivesName.get() != expectedMavenArtifact
869889
|| expectedReleaseFiles.get().collect { it.toString() } != expectedPublicArtifacts) {
@@ -880,7 +900,7 @@ tasks.register('verifyReleaseConfiguration') {
880900
'src/main/java/zone/moddev/mc/orespawn/worldgen/LegacyMineralogyProfileMigration.java',
881901
'README.md', 'CHANGELOG.txt'
882902
].each { path ->
883-
if (!file(path).getText('UTF-8').contains('4.0.15.120011')) {
903+
if (!file(path).getText('UTF-8').contains('4.0.16.120011')) {
884904
throw new GradleException("Release identity missing from ${path}")
885905
}
886906
}

docs/VERSIONS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Examples:
5858
| 1.17.1 | Forge | `117011` | `4.0.9.117011` |
5959
| 1.18.2 | Forge | `118021` | `4.0.10.118021` |
6060
| 1.19.4 | Forge | `119041` | `4.0.10.119041` |
61-
| 1.20.1 | Forge | `120011` | `4.0.15.120011` |
61+
| 1.20.1 | Forge | `120011` | `4.0.16.120011` |
6262
| 1.20.6 | Forge | `120061` | `4.0.6.120061` |
6363
| 1.21.11 | Forge | `121111` | `4.0.6.121111` |
6464
| 26.1.2 | Forge | `2601021` | `4.0.6.2601021` |
@@ -165,7 +165,9 @@ restore API biome-filter parity and accept provider-namespaced geomes in the
165165
creation editor, and to `4.0.14.120011` to convert exposed one-layer Snow
166166
without touching buried or authored weather materials. It then advanced to
167167
`4.0.15.120011` so generated geology and public samples use the same stable
168-
quart-biome cell at three-dimensional biome boundaries.
168+
quart-biome cell at three-dimensional biome boundaries, and to
169+
`4.0.16.120011` so GameTest benchmark runs leave shutdown and result reporting
170+
to the test harness.
169171

170172
This provides three useful guarantees:
171173

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mcp_version=20230612.114412
1919
mod_id=orespawn
2020
mod_name=MMD OreSpawn
2121
mod_license=LGPL-2.1
22-
mod_version=4.0.15.120011
22+
mod_version=4.0.16.120011
2323
mod_group=zone.moddev.mc.orespawn
2424
mod_authors=SkyBlade1978, dshadowwolf, the MMD Team
2525
mod_description=Configurable, provider-driven terrain, ore, and deposit generation.

src/clientIntegrationTest/java/zone/moddev/mc/orespawn/clientprobe/ClientProbeTestMod.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ private static void initializeScreen(Screen screen, Minecraft minecraft) {
364364
Class<?>[] parameters = method.getParameterTypes();
365365
if (parameters.length != 3 || parameters[0] != Minecraft.class
366366
|| parameters[1] != int.class || parameters[2] != int.class
367-
|| method.getReturnType() != void.class) continue;
367+
|| method.getReturnType() != void.class
368+
|| !java.lang.reflect.Modifier.isFinal(method.getModifiers())) continue;
368369
try {
369370
method.setAccessible(true);
370371
method.invoke(screen, minecraft, 640, 480);

src/main/java/zone/moddev/mc/orespawn/worldgen/LegacyConfigMigrator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ private static void writeReport(Path config, List<String> lines) {
358358

359359
private static void writeUpgradeReport(Path config, int imported, List<String> detail) {
360360
List<String> lines = new ArrayList<>();
361-
lines.add("OreSpawn 4.0.15.120011 Upgrade Report");
361+
lines.add("OreSpawn 4.0.16.120011 Upgrade Report");
362362
lines.add("================================");
363363
lines.add("");
364364
lines.add("RESULT: Legacy OreSpawn settings were imported into the OS4 profile.");

src/main/java/zone/moddev/mc/orespawn/worldgen/LegacyMineralogyProfileMigration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private static void writeUpgradeReport(Path worldRoot, Path configPath,
204204
Path report = worldRoot.resolve("serverconfig/orespawn-upgrade-report.txt");
205205
List<String> missing = missingBlocks(igneous, metamorphic, sedimentary);
206206
List<String> lines = new ArrayList<>();
207-
lines.add("OreSpawn 4.0.15.120011 Upgrade Report");
207+
lines.add("OreSpawn 4.0.16.120011 Upgrade Report");
208208
lines.add("================================");
209209
lines.add("");
210210
lines.add("RESULT: Existing Mineralogy " + identity.version + " world detected.");

src/main/java/zone/moddev/mc/orespawn/worldgen/WorldgenBenchmark.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import net.minecraft.core.Registry;
1616
import net.minecraft.core.registries.BuiltInRegistries;
1717
import net.minecraft.core.registries.Registries;
18+
import net.minecraft.gametest.framework.GameTestServer;
1819
import net.minecraft.resources.ResourceKey;
1920
import net.minecraft.resources.ResourceLocation;
21+
import net.minecraft.server.MinecraftServer;
2022
import net.minecraft.server.level.ServerLevel;
2123
import net.minecraft.world.level.Level;
2224
import net.minecraft.world.level.block.Block;
@@ -140,11 +142,19 @@ MODE, chunks, repetitions, format(median), format(median / chunks),
140142
throw new IllegalStateException("Benchmark fluid audit found no successful deposits");
141143
}
142144
if (Boolean.getBoolean("orespawn.worldgenBenchmarkStopServer")) {
143-
LOGGER.info("ORESPAWN_BENCHMARK stopping server after completed benchmark");
144-
event.getServer().halt(false);
145+
if (ownsServerShutdown(event.getServer().getClass())) {
146+
LOGGER.info("ORESPAWN_BENCHMARK stopping server after completed benchmark");
147+
event.getServer().halt(false);
148+
} else {
149+
LOGGER.info("ORESPAWN_BENCHMARK leaving shutdown to the GameTest harness");
150+
}
145151
}
146152
}
147153

154+
static boolean ownsServerShutdown(Class<? extends MinecraftServer> serverType) {
155+
return !GameTestServer.class.isAssignableFrom(serverType);
156+
}
157+
148158
static ResourceKey<Level> benchmarkDimensionKey(String configured) {
149159
String dimensionName = configured.trim().toLowerCase(Locale.ROOT);
150160
return switch (dimensionName) {

0 commit comments

Comments
 (0)