Skip to content

Commit

Permalink
Wip client gametests
Browse files Browse the repository at this point in the history
  • Loading branch information
Earthcomputer committed Dec 29, 2024
1 parent af0d8f0 commit f839844
Show file tree
Hide file tree
Showing 7 changed files with 450 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bin/
# fabric

run/
runGametest/
logs/

/changelog.txt
46 changes: 45 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ base {
}

sourceSets {
codeGen
clientGametest {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}

codeGen {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
}

configurations {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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 '<method v="2">' }
assert index >= 0
def endIndex = gametestXml.findIndexOf(index) { it.endsWith('</method>') }
gametestXml.add(endIndex, '<option enabled="true" externalProjectPath="$PROJECT_DIR$" name="Gradle.BeforeRunTask" scriptParameters="" tasks="cleanGametestRunDir" vmOptions=""/>')
file('.idea/runConfigurations/Client_Gametest.xml').write(gametestXml.join('\n'))
}

runClientGametest.dependsOn cleanGametestRunDir

tasks.register('codeGen', JavaExec) {
mainClass = 'net.earthcomputer.clientcommands.codegen.CodeGenerator'
classpath = sourceSets.codeGen.runtimeClasspath
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ org.gradle.jvmargs=-Xmx2G

# Dependencies
# also check this on https://fabricmc.net/develop/
fabric_version=0.110.5+1.21.4
fabric_version=0.113.0+1.21.4
clientarguments_version=1.10.1
betterconfig_version=2.1.2
seedfinding_core_version=1.200.1
Expand Down
Loading

0 comments on commit f839844

Please sign in to comment.