Skip to content

Commit 0f5335a

Browse files
committed
Baseline gametest, projector placement tests
1 parent 80697c9 commit 0f5335a

File tree

10 files changed

+197
-201
lines changed

10 files changed

+197
-201
lines changed

1.16.5-tests/test/java/dev/compactmods/crafting/tests/projectors/ProjectorPlacementTests.java

Lines changed: 0 additions & 110 deletions
This file was deleted.
Binary file not shown.

build.gradle

Lines changed: 47 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ buildscript {
22
repositories {
33
maven { url = 'https://maven.minecraftforge.net' }
44
mavenCentral()
5+
mavenLocal()
56
}
67

78
dependencies {
@@ -62,22 +63,15 @@ sourceSets {
6263
test {
6364
java { srcDir "src/main/test" }
6465

66+
resources {
67+
srcDir "src/test/resources"
68+
}
69+
6570
runtimeClasspath += sourceSets.api.output
6671
compileClasspath += sourceSets.api.output
6772
runtimeClasspath += sourceSets.main.output
6873
compileClasspath += sourceSets.main.output
6974
}
70-
71-
// test {
72-
// compileClasspath += sourceSets.api.output
73-
// compileClasspath += sourceSets.main.output
74-
// runtimeClasspath += sourceSets.api.output
75-
// runtimeClasspath += sourceSets.main.output
76-
//
77-
// resources {
78-
// srcDir "src/test/resources"
79-
// }
80-
// }
8175
}
8276

8377
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
@@ -156,71 +150,40 @@ minecraft {
156150
}
157151
}
158152

159-
// unitTests {
160-
// parent runs.server
161-
//
162-
// workingDirectory project.file('run/test')
163-
// main 'com.alcatrazescapee.mcjunitlib.DedicatedTestServerLauncher'
164-
// // The main class which launches a customized server which then runs JUnit tests
165-
// ideaModule "${project.name}.test"
166-
// property 'forge.logging.console.level', 'unittest'
167-
// environment 'MOD_MODULES', String.join(File.pathSeparator, "${mod_id}%%${project.name}.test")
168-
// environment 'target', 'fmltestserver'
169-
// environment 'targetModId', "${mod_id}"
170-
// environment "CC_TEST_RESOURCES", sourceSets.test.resources.srcDirs[0]
171-
// arg '--keepAlive'
172-
// forceExit = false
173-
// mods {
174-
// compactcrafting {
175-
// source sourceSets.main
176-
// source sourceSets.api
177-
// source sourceSets.test
178-
// }
179-
// }
180-
// }
181-
//
182-
// unitTestsCI {
183-
// parent runs.server
184-
//
185-
// workingDirectory project.file('run/test')
186-
// main 'com.alcatrazescapee.mcjunitlib.DedicatedTestServerLauncher'
187-
// // The main class which launches a customized server which then runs JUnit tests
188-
// ideaModule "${project.name}.test"
189-
// property 'forge.logging.console.level', 'unittest'
190-
// environment 'MOD_MODULES', String.join(File.pathSeparator, "${mod_id}%%${project.name}.test")
191-
// environment 'target', 'fmltestserver'
192-
// environment 'targetModId', "${mod_id}"
193-
// environment "CC_TEST_RESOURCES", sourceSets.test.resources.srcDirs[0]
194-
// arg '--crashOnFailedTests'
195-
// forceExit = false
196-
// mods {
197-
// compactcrafting {
198-
// source sourceSets.main
199-
// source sourceSets.api
200-
// source sourceSets.test
201-
// }
202-
// }
203-
// }
204-
}
205-
}
153+
gametestserver {
154+
workingDirectory project.file('run/gametest')
155+
156+
// Recommended logging data for a userdev environment
157+
// The markers can be added/remove as needed separated by commas.
158+
// "SCAN": For mods scan.
159+
// "REGISTRIES": For firing of registry events.
160+
// "REGISTRYDUMP": For getting the contents of all registries.
161+
property 'forge.logging.markers', 'REGISTRIES'
162+
163+
// Recommended logging level for the console
164+
// You can set various levels here.
165+
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
166+
property 'forge.logging.console.level', 'debug'
167+
168+
property 'mixin.env.remapRefMap', 'true'
169+
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
170+
171+
// Only runs gametests which use "examplemod" as the namespace
172+
args '--enableNamespace', mod_id
206173

207-
def format(String jar_name) {
208-
def index = jar_name.lastIndexOf('-')
209-
index = jar_name.substring(0, index).lastIndexOf('-')
210-
def mod_version = jar_name.substring(index).replace(".jar", "")
211-
if (mod_version.startsWith('-')) {
212-
mod_version = mod_version.substring(1);
174+
mods {
175+
compactcrafting {
176+
source sourceSets.api
177+
source sourceSets.main
178+
source sourceSets.test
179+
}
180+
}
181+
}
213182
}
214-
def mod_name = jar_name.substring(0, index)
215-
return mod_name + ":" + mod_name + ":" + mod_version
216183
}
217184

218-
def dev_mods_dir = "mods"
219-
220185
repositories {
221-
flatDir {
222-
dirs dev_mods_dir
223-
}
186+
mavenLocal()
224187

225188
maven {
226189
url "https://www.cursemaven.com"
@@ -255,40 +218,37 @@ repositories {
255218
}
256219
}
257220

258-
def dev_mods = fileTree("mods").filter { it -> it.isFile() }.files.name.collect({ format(it) })
259-
260221
dependencies {
261222
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
262223
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
263224
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
264225
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
265226

266-
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
267-
// testImplementation fg.deobf("com.github.alcatrazEscapee:mcjunitlib:${mcunittest_version}")
227+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
228+
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.4.2'
268229

269230
library "io.reactivex.rxjava3:rxjava:3.1.1";
270231

271-
// Deobfuscate each dev mod for runtime
272-
dev_mods.each { implementation fg.deobf(it) }
232+
// Nicephore - Screenshots and Stuff
233+
runtimeOnly(fg.deobf("curse.maven:nicephore-401014:3574658"))
273234

274-
runtimeOnly(fg.deobf("curse.maven:nicephore-401014:3542531"))
235+
// Shut up Experimental Settings - so we don't have to deal with that CONSTANTLY
275236
runtimeOnly(fg.deobf("curse.maven:shutupexperimental-407174:3544525"))
276237

277238
// JEI
278-
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}:api")
279-
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}")
239+
compileOnly fg.deobf("mezz.jei:jei-${jei_mc_version}:${jei_version}:api")
240+
runtimeOnly fg.deobf("mezz.jei:jei-${jei_mc_version}:${jei_version}")
280241

281242
// The One Probe
282-
// compileOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-1.16:${top_version}:api")
283-
// runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-1.16:${top_version}")
243+
implementation(fg.deobf("curse.maven:theoneprobe-245211:3550084"))
284244
}
285245

286246
processResources {
287-
duplicatesStrategy = DuplicatesStrategy.WARN
247+
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
288248
}
289249

290250
processTestResources {
291-
duplicatesStrategy = DuplicatesStrategy.WARN
251+
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
292252
}
293253

294254
assemble {
@@ -397,5 +357,7 @@ publishing {
397357
}
398358

399359
test {
400-
useJUnitPlatform()
360+
useJUnitPlatform {
361+
excludeTags "minecraft"
362+
}
401363
}

gradle.properties

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
org.gradle.jvmargs=-Xmx3G
44
org.gradle.daemon=false
55

6-
minecraft_version=1.18
7-
forge_version=38.0.14
6+
minecraft_version=1.18.1
7+
forge_version=39.0.97-gametest-1.18.x
88

99
mod_id=compactcrafting
1010
mod_version=2.0.0-beta.1
1111

1212
# Dependencies and Libs
13-
jei_version=9.0.0.40
13+
jei_mc_version=1.18.1
14+
jei_version=9.1.0.41
1415
#top_version=1.16-3.1.4-22
1516
#mcunittest_version=1.8.1-1.16.5
1617

src/main/resources/META-INF/mods.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
modLoader="javafml" #mandatory
33

44
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
5-
loaderVersion="[38,39)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
5+
loaderVersion="[39,40)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
66

77
license="MIT"
88

@@ -39,7 +39,7 @@ Based off of the Compact Machines mod pre-1.16.
3939
# Does this dependency have to exist - if not, ordering below must be specified
4040
mandatory=true #mandatory
4141
# The version range of the dependency
42-
versionRange="[38,39)" #mandatory
42+
versionRange="[39,40)" #mandatory
4343
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
4444
ordering="NONE"
4545
# Side this dependency is applied on - BOTH, CLIENT or SERVER
@@ -49,7 +49,7 @@ Based off of the Compact Machines mod pre-1.16.
4949
[[dependencies.compactcrafting]]
5050
modId="minecraft"
5151
mandatory=true
52-
versionRange="[1.18,1.19)"
52+
versionRange="[1.18.1,1.19)"
5353
ordering="NONE"
5454
side="BOTH"
5555

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package dev.compactmods.crafting.tests;
2+
3+
import dev.compactmods.crafting.CompactCrafting;
4+
import dev.compactmods.crafting.tests.projectors.Projectors;
5+
import net.minecraftforge.event.RegisterGameTestsEvent;
6+
import net.minecraftforge.eventbus.api.SubscribeEvent;
7+
import net.minecraftforge.fml.common.Mod;
8+
9+
@Mod.EventBusSubscriber(modid = CompactCrafting.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
10+
public class GameTestsMain {
11+
12+
@SubscribeEvent
13+
public static void registerTests(final RegisterGameTestsEvent game) {
14+
CompactCrafting.LOGGER.debug("Registering game tests.");
15+
16+
game.register(Projectors.class);
17+
}
18+
}

0 commit comments

Comments
 (0)