1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-24 06:03:28 +00:00

Fix client tests not running on Forge

This was introduced by the FG6 update - the cctest.client property
didn't get set, and so tests never started!
This commit is contained in:
Jonathan Coates 2023-07-22 19:40:50 +01:00
parent 90ed0b24e7
commit dd08d1ec8e
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
2 changed files with 26 additions and 8 deletions

View File

@ -4,6 +4,7 @@
package cc.tweaked.gradle
import net.minecraftforge.gradle.common.util.RunConfig
import org.gradle.api.GradleException
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.invocation.Gradle
@ -53,6 +54,25 @@ val useFramebuffer get() = !clientDebug && !project.hasProperty("clientNoFramebu
@get:OutputFile
val testResults = project.layout.buildDirectory.file("test-results/$name.xml")
private fun setTestProperties() {
if (!clientDebug) systemProperty("cctest.client", "")
if (renderdoc) environment("LD_PRELOAD", "/usr/lib/librenderdoc.so")
systemProperty("cctest.gametest-report", testResults.get().asFile.absoluteFile)
workingDir(project.buildDir.resolve("gametest").resolve(name))
}
init {
setTestProperties()
}
/**
* Set this task to run a given [RunConfig].
*/
fun setRunConfig(config: RunConfig) {
(this as JavaExec).setRunConfig(config)
setTestProperties() // setRunConfig may clobber some properties, ensure everything is set.
}
/**
* Copy configuration from a task with the given name.
*/
@ -64,11 +84,7 @@ fun copyFrom(path: String) = copyFrom(project.tasks.getByName(path, JavaExec::cl
fun copyFrom(task: JavaExec) {
for (dep in task.dependsOn) dependsOn(dep)
task.copyToFull(this)
if (!clientDebug) systemProperty("cctest.client", "")
if (renderdoc) environment("LD_PRELOAD", "/usr/lib/librenderdoc.so")
systemProperty("cctest.gametest-report", testResults.get().asFile.absoluteFile)
workingDir(project.buildDir.resolve("gametest").resolve(name))
setTestProperties() // copyToFull may clobber some properties, ensure everything is set.
}
/**

View File

@ -114,10 +114,12 @@ def main():
images: list[Image] = []
for project, dir in {
"Forge": "projects/forge",
"Fabric": "projects/fabric",
"Forge": "projects/forge/build/gametest/runGametestClient",
"Fabric": "projects/fabric/build/gametest/runGametestClient",
"Fabric (+Sodium)": "projects/fabric/build/gametest/runGametestClientWithSodium",
"Fabric (+Iris)": "projects/fabric/build/gametest/runGametestClientWithIris",
}.items():
for file in sorted(pathlib.Path(dir).glob("build/gametest/*/screenshots/*.png")):
for file in sorted(pathlib.Path(dir).glob("screenshots/*.png")):
name = [project, *(_normalise_id(x) for x in file.stem.split("."))]
mtime = datetime.fromtimestamp(file.stat().st_mtime, tz=timezone.utc)