From f83984402946549ccd8230825c83dec9e468e926 Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 29 Dec 2024 22:08:52 +0000 Subject: [PATCH] Wip client gametests --- .gitignore | 1 + build.gradle | 46 ++- gradle.properties | 2 +- .../gametest/BannedActionGametest.java | 356 ++++++++++++++++++ src/clientGametest/resources/fabric.mod.json | 14 + .../mixin/rngevents/LivingEntityMixin.java | 2 +- .../util/MultiVersionCompat.java | 32 ++ 7 files changed, 450 insertions(+), 3 deletions(-) create mode 100644 src/clientGametest/java/net/earthcomputer/clientcommands/gametest/BannedActionGametest.java create mode 100644 src/clientGametest/resources/fabric.mod.json diff --git a/.gitignore b/.gitignore index a51657876..9fdceaf90 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ bin/ # fabric run/ +runGametest/ logs/ /changelog.txt diff --git a/build.gradle b/build.gradle index 0b57d410e..985285b5b 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,15 @@ base { } sourceSets { - codeGen + clientGametest { + compileClasspath += main.compileClasspath + runtimeClasspath += main.runtimeClasspath + } + + codeGen { + compileClasspath += main.compileClasspath + runtimeClasspath += main.runtimeClasspath + } } configurations { @@ -42,6 +50,22 @@ repositories { loom { accessWidenerPath = file('src/main/resources/clientcommands.aw') + + runs { + clientGametest { + client() + ideConfigGenerated true + name 'Client Gametest' + property 'fabric.client.gametest' + programArgs '--username', 'GametestUser' + runDir 'runGametest' + source sourceSets.clientGametest + } + } + + mods.register('clientcommands-gametest') { + sourceSet sourceSets.clientGametest + } } dependencies { @@ -74,6 +98,7 @@ dependencies { include api('net.fabricmc:mapping-io:0.5.1') + clientGametestImplementation sourceSets.main.output codeGenImplementation sourceSets.main.output testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}" @@ -125,6 +150,25 @@ tasks.register('sourcesJar', Jar) { from sourceSets.main.allSource } +tasks.register('cleanGametestRunDir', Delete) { + delete 'runGametest' + doLast { + mkdir('runGametest') + } +} + +// hack to make sure run directory is cleaned before the gametests are run +ideaSyncTask.doLast { + def gametestXml = file('.idea/runConfigurations/Client_Gametest.xml').readLines() + def index = gametestXml.findIndexOf { it.endsWith '' } + assert index >= 0 + def endIndex = gametestXml.findIndexOf(index) { it.endsWith('') } + gametestXml.add(endIndex, '