Skip to content

Commit

Permalink
Add experimental Client Game Test API (#4292)
Browse files Browse the repository at this point in the history
* Move client auto tests to new module fabric-client-gametest-api-v1

* Fix run prod Gradle tasks

* Rename remaining references to client auto-tests

* Switch client gametests to using entrypoints

* Disable input and cursor grabbing

* Remove FabricClientTestHelper moving most of it into the context. Add the ability to simulate key and mouse inputs

* Rename and document input methods

* Rename client gametest github action

* Fix tryClickScreenButtonImpl for buttons inside layout widgets

* Address review comments and repackage client gametest test

* Delete wrong reference to TitleScreenAccessor. Thanks mcdev

* Address review comments

* Clean up default game options

* Improve documentation

* Remove module dependencies

---------

Co-authored-by: modmuss50 <[email protected]>
  • Loading branch information
Earthcomputer and modmuss50 authored Dec 16, 2024
1 parent 08f5ef8 commit b47eab6
Show file tree
Hide file tree
Showing 39 changed files with 1,985 additions and 552 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ jobs:
with:
distribution: 'microsoft'
java-version: '21'
- name: Run Auto test Client
- name: Run Client Gametests
uses: modmuss50/xvfb-action@v1
with:
run: ./gradlew runProductionAutoTestClient --stacktrace --warning-mode=fail
run: ./gradlew runProductionClientGametest --stacktrace --warning-mode=fail
- uses: actions/upload-artifact@v4
if: always()
with:
Expand Down
37 changes: 23 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ loom {
name "Auto Test Server"
vmArg "-Dfabric.autoTest"
}
autoTestClient {
clientGametest {
inherit testmodClient
name "Auto Test Client"
vmArg "-Dfabric.autoTest"
name "Client Game Test"
vmArg "-Dfabric.client.gametest"
vmArg "-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail"
vmArg "-Dfabric-tag-conventions-v1.legacyTagWarning=fail"
}
Expand All @@ -432,9 +432,9 @@ loom {
ideConfigGenerated = false
}

autoTestClientCoverage {
inherit autoTestClient
name "Auto Test Client Coverage"
clientGametestCoverage {
inherit clientGametest
name "Client Game Test Coverage"
ideConfigGenerated = false
}
}
Expand All @@ -448,7 +448,7 @@ test.dependsOn runGametest

def coverageTasks = [
runGametestCoverage,
runAutoTestClientCoverage
runClientGametestCoverage
]

jacoco {
Expand Down Expand Up @@ -484,20 +484,26 @@ configurations {
extendsFrom configurations.minecraftRuntimeLibraries
}
productionRuntimeServer
productionMods {
transitive = false
}
}

dependencies {
productionRuntime "net.fabricmc:fabric-loader:${project.loader_version}"
productionRuntime "net.fabricmc:intermediary:${project.minecraft_version}"

productionRuntimeServer "net.fabricmc:fabric-installer:${project.installer_version}:server"
productionMods project(':fabric-client-gametest-api-v1')
}

import net.fabricmc.loom.util.Platform

def productionMods = project.files(configurations.productionMods, remapJar.archiveFile, remapTestmodJar.archiveFile)

// This is very far beyond loom's API if you copy this, you're on your own.
tasks.register('runProductionAutoTestClient', JavaExec) {
dependsOn remapJar, remapTestmodJar, downloadAssets
tasks.register('runProductionClientGametest', JavaExec) {
dependsOn productionMods, downloadAssets
classpath.from configurations.productionRuntime
mainClass = "net.fabricmc.loader.impl.launch.knot.KnotClient"
workingDir = file("run")
Expand All @@ -519,8 +525,8 @@ tasks.register('runProductionAutoTestClient', JavaExec) {
}

jvmArgs(
"-Dfabric.addMods=${remapJar.archiveFile.get().asFile.absolutePath}${File.pathSeparator}${remapTestmodJar.archiveFile.get().asFile.absolutePath}",
"-Dfabric.autoTest",
"-Dfabric.addMods=${productionMods.collect { it.absolutePath }.join(File.pathSeparator)}",
"-Dfabric.client.gametest",
"-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail",
"-Dfabric-tag-conventions-v1.legacyTagWarning=fail"
)
Expand All @@ -544,7 +550,7 @@ tasks.register('serverPropertiesJar', Jar) {
}

tasks.register('runProductionAutoTestServer', JavaExec) {
dependsOn remapJar, remapTestmodJar, serverPropertiesJar
dependsOn productionMods, serverPropertiesJar
classpath.from configurations.productionRuntimeServer, serverPropertiesJar
mainClass = "net.fabricmc.installer.ServerLauncher"
workingDir = file("run")
Expand All @@ -553,7 +559,7 @@ tasks.register('runProductionAutoTestServer', JavaExec) {
workingDir.mkdirs()

jvmArgs(
"-Dfabric.addMods=${remapJar.archiveFile.get().asFile.absolutePath}${File.pathSeparator}${remapTestmodJar.archiveFile.get().asFile.absolutePath}",
"-Dfabric.addMods=${productionMods.collect { it.absolutePath }.join(File.pathSeparator)}",
"-Dfabric.autoTest",
)
jvmArgs(debugArgs)
Expand Down Expand Up @@ -726,7 +732,10 @@ subprojects.each {
}

// These modules are not included in the fat jar, maven will resolve them via the pom.
def devOnlyModules = ["fabric-gametest-api-v1",]
def devOnlyModules = [
"fabric-client-gametest-api-v1",
"fabric-gametest-api-v1",
]

dependencies {
afterEvaluate {
Expand Down
11 changes: 1 addition & 10 deletions fabric-api-base/src/testmod/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,11 @@
"main": [
"net.fabricmc.fabric.test.base.FabricApiBaseTestInit"
],
"client": [
"net.fabricmc.fabric.test.base.client.FabricApiAutoTestClient"
],
"server": [
"net.fabricmc.fabric.test.base.FabricApiAutoTestServer"
],
"fabric-gametest" : [
"net.fabricmc.fabric.test.base.FabricApiBaseGameTest"
]
},
"mixins": [
{
"config": "fabric-api-base-testmod.client.mixins.json",
"environment": "client"
}
]
}
}

This file was deleted.

Loading

0 comments on commit b47eab6

Please sign in to comment.