Skip to content

Commit 5436ae5

Browse files
Merge branch 'client_gametest_api/1.21.8-neoforge' into 1.21.8-neoforge
2 parents 5c87513 + 99537fd commit 5436ae5

File tree

78 files changed

+7909
-776
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+7909
-776
lines changed

.github/workflows/gradle.yml

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -104,51 +104,14 @@ jobs:
104104
done
105105
echo "</details>" >> $GITHUB_STEP_SUMMARY
106106
107-
- name: Run the mod and take screenshots
107+
- name: Run client gametest
108108
uses: GabrielBB/[email protected]
109109
with:
110-
run: ./gradlew runEndToEndTest --stacktrace --warning-mode=fail
110+
run: ./gradlew runClientGameTest --stacktrace --warning-mode=fail
111111

112-
# Needed because the screenshot gallery won't be created on pull requests.
113-
# Also useful if Imgur uploads fail.
114112
- name: Upload Test Screenshots.zip artifact
115113
uses: actions/upload-artifact@v4
116114
if: always()
117115
with:
118116
name: Test Screenshots
119-
path: runs/client/screenshots
120-
121-
- name: Create test screenshot gallery
122-
if: ${{ env.IMGUR_CLIENT_ID && (success() || failure()) }}
123-
# Imgur uploads randomly fail sometimes, probably because of the low rate limit.
124-
# TODO: Find a better place to upload the screenshots.
125-
continue-on-error: true
126-
run: |
127-
echo "<details open>" >> $GITHUB_STEP_SUMMARY
128-
echo "<summary>📸 Test Screenshots</summary>" >> $GITHUB_STEP_SUMMARY
129-
echo "" >> $GITHUB_STEP_SUMMARY
130-
131-
for img in runs/client/screenshots/*.png; do
132-
if [ -f "$img" ]; then
133-
filename=$(basename "$img")
134-
name_without_ext="${filename%.*}"
135-
# Upload to Imgur
136-
response=$(curl -s -X POST \
137-
-H "Authorization: Client-ID $IMGUR_CLIENT_ID" \
138-
-F "image=@$img" \
139-
https://api.imgur.com/3/image)
140-
# Extract the URL from the response
141-
url=$(echo $response | grep -o '"link":"[^"]*"' | cut -d'"' -f4)
142-
if [ ! -z "$url" ]; then
143-
# Convert underscores to spaces and capitalize first letter of each word
144-
title=$(echo "$name_without_ext" | tr '_' ' ' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
145-
echo "### $title" >> $GITHUB_STEP_SUMMARY
146-
echo "![${name_without_ext}]($url)" >> $GITHUB_STEP_SUMMARY
147-
echo "" >> $GITHUB_STEP_SUMMARY
148-
else
149-
echo "Failed to upload $filename" >> $GITHUB_STEP_SUMMARY
150-
echo "Imgur upload response for $filename: $response"
151-
fi
152-
fi
153-
done
154-
echo "</details>" >> $GITHUB_STEP_SUMMARY
117+
path: build/run/clientGameTest/screenshots

build.gradle

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,18 @@ tasks.named("build").configure {
5959
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
6060

6161
mixin {
62-
config 'chestesp.mixins.json'
62+
config "chestesp.mixins.json"
6363
}
6464

6565
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
6666
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
6767

68+
sourceSets {
69+
gametest {
70+
depends.on sourceSets.main
71+
}
72+
}
73+
6874
// Default run configurations.
6975
// These can be tweaked, removed, or duplicated as needed.
7076
runs {
@@ -109,6 +115,30 @@ runs {
109115
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
110116
arguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
111117
}
118+
119+
clientGameTest {
120+
runType("client")
121+
jvmArguments("-Dchestesp.e2eTest", "-Dmixin.debug.verify=true", "-Dmixin.debug.countInjections=true")
122+
systemProperties("fabric.client.gametest.disableNetworkSynchronizer": "true")
123+
arguments("--username", "Wurst-Bot")
124+
workingDirectory(file("build/run/clientGameTest"))
125+
modSource project.sourceSets.gametest
126+
mixin {
127+
config "fabric_api.mixins.json"
128+
config "client_gametest.mixins.json"
129+
}
130+
}
131+
}
132+
133+
tasks.withType(JavaExec).configureEach {
134+
doFirst {
135+
if (name == "runClientGameTest") {
136+
def runDir = file("build/run/clientGameTest")
137+
if(runDir.exists())
138+
delete runDir
139+
runDir.mkdirs()
140+
}
141+
}
112142
}
113143

114144
// Include resources generated by data generators.
@@ -209,27 +239,6 @@ tasks.withType(ProcessResources).configureEach {
209239
}
210240
}
211241

212-
tasks.register('runEndToEndTest') {
213-
group = 'NeoGradle/Runs'
214-
description = 'Runs the game with end-to-end tests enabled'
215-
dependsOn 'runClient'
216-
}
217-
218-
// Modify runClient if it's running as a dependency of runEndToEndTest.
219-
// Since NeoGradle doesn't allow custom run types yet, this is the only way to
220-
// make runEndToEndTest work for now.
221-
tasks.withType(JavaExec).configureEach {
222-
doFirst {
223-
if (gradle.startParameter.taskNames.contains('runEndToEndTest')) {
224-
jvmArgs += [
225-
'-Dchestesp.e2eTest',
226-
'-Dmixin.debug.verify=true',
227-
'-Dmixin.debug.countInjections=true'
228-
]
229-
}
230-
}
231-
}
232-
233242
tasks.withType(JavaCompile).configureEach {
234243
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
235244
}
@@ -256,7 +265,7 @@ spotless {
256265
eclipse().configFile(file("codestyle/formatter.xml"))
257266
}
258267
format("licenseHeader") {
259-
target("src/*/java/**/*.java", "src/test/java/**/*.java")
268+
target("src/main/java/**/*.java", "src/test/java/**/*.java", "src/gametest/java/net/wimods/**/*.java")
260269
def header_file = file("codestyle/license_header.txt")
261270
def delimiter = LicenseHeaderStep.DEFAULT_JAVA_HEADER_DELIMITER
262271
licenseHeaderFile(header_file, delimiter).updateYearWithLatest(true)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package net.fabricmc.fabric.api.client.gametest.v1;
18+
19+
import net.fabricmc.fabric.api.client.gametest.v1.context.ClientGameTestContext;
20+
21+
/**
22+
* The {@code fabric-client-gametest} entrypoint interface. See the package
23+
* documentation.
24+
*/
25+
public interface FabricClientGameTest
26+
{
27+
/**
28+
* Runs the gametest.
29+
*/
30+
void runTest(ClientGameTestContext context);
31+
}

0 commit comments

Comments
 (0)