Skip to content

Commit bee6fd9

Browse files
Add Sodium compatibility test
1 parent bcd7f3f commit bee6fd9

File tree

6 files changed

+68
-8
lines changed

6 files changed

+68
-8
lines changed

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
- name: Run client gametests
9191
env:
9292
IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }}
93-
run: xvfb-run --auto-servernum ./gradlew runClientGameTest --stacktrace --warning-mode=fail
93+
run: xvfb-run --auto-servernum ./gradlew runClientGameTest runClientGameTestWithMods --stacktrace --warning-mode=fail
9494

9595
- name: Upload screenshots
9696
uses: actions/upload-artifact@v5

build.gradle

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ repositories {
2424
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
2525
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
2626
// for more information about repositories.
27+
exclusiveContent {
28+
forRepository {
29+
maven {
30+
name = "Modrinth"
31+
url = "https://api.modrinth.com/maven"
32+
}
33+
}
34+
filter {
35+
includeGroup "maven.modrinth"
36+
}
37+
}
2738
}
2839

2940
dependencies {
@@ -55,6 +66,43 @@ fabricApi.configureTests {
5566

5667
loom {
5768
accessWidenerPath = file("src/main/resources/wurst.accesswidener")
69+
70+
runs {
71+
clientGameTestWithMods {
72+
inherit client
73+
source = sourceSets.gametest
74+
runDir = "build/run/clientGameTestWithMods"
75+
vmArgs.add("-Dfabric.client.gametest")
76+
vmArgs.add("-Dwurst.test.withMods=true")
77+
programArgs.add("--username=Wurst-Bot")
78+
}
79+
}
80+
}
81+
82+
configurations {
83+
testMods {
84+
transitive = false
85+
}
86+
}
87+
88+
dependencies {
89+
testMods "maven.modrinth:sodium:${project.sodium_version}"
90+
}
91+
92+
def cleanClientGameTestWithMods = tasks.register("cleanClientGameTestWithMods", Delete) {
93+
delete layout.buildDirectory.dir("run/clientGameTestWithMods")
94+
}
95+
96+
def prepareClientGameTestWithMods = tasks.register("prepareClientGameTestWithMods", Sync) {
97+
dependsOn cleanClientGameTestWithMods
98+
from configurations.testMods
99+
into layout.buildDirectory.dir("run/clientGameTestWithMods/mods")
100+
}
101+
102+
def doModCompatTest = providers.gradleProperty("do_mod_compat_test").map { it.toBoolean() }.orElse(false)
103+
tasks.named("runClientGameTestWithMods") {
104+
onlyIf { doModCompatTest.get() }
105+
dependsOn prepareClientGameTestWithMods
58106
}
59107

60108
processResources {

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ gh_repo_id=Wurst-Imperium/Wurst7
2525
mcx_repo_id=Wurst-Imperium/Wurst-MCX2
2626

2727
# Dependencies
28+
sodium_version=mc1.21.10-0.7.2-fabric
29+
do_mod_compat_test=true

src/gametest/java/net/wurstclient/gametest/WurstTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public class WurstTest implements FabricClientGameTest
3636
{
3737
public static final Logger LOGGER = LoggerFactory.getLogger("Wurst Test");
3838

39+
public static final boolean IS_MOD_COMPAT_TEST =
40+
System.getProperty("wurst.test.withMods") != null;
41+
3942
@Override
4043
public void runTest(ClientGameTestContext context)
4144
{
@@ -86,7 +89,8 @@ private void testInWorld(ClientGameTestContext context,
8689
world.waitForChunksRender();
8790

8891
assertScreenshotEquals(context, "in_game",
89-
"https://i.imgur.com/EfzN9Cd.png");
92+
IS_MOD_COMPAT_TEST ? "https://i.imgur.com/VxbGFrb.png"
93+
: "https://i.imgur.com/EfzN9Cd.png");
9094

9195
LOGGER.info("Recording debug menu");
9296
input.pressKey(GLFW.GLFW_KEY_F3);

src/gametest/java/net/wurstclient/gametest/tests/FreecamHackTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ public static void testFreecamHack(ClientGameTestContext context,
4141
input.holdKeyFor(GLFW.GLFW_KEY_S, 2);
4242
input.holdKeyFor(GLFW.GLFW_KEY_SPACE, 1);
4343
assertScreenshotEquals(context, "freecam_moved",
44-
"https://i.imgur.com/pZDlYfH.png");
44+
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/oZUpI8c.png"
45+
: "https://i.imgur.com/pZDlYfH.png");
4546
clearChat(context);
4647

4748
// Enable tracer
4849
runWurstCommand(context, "setcheckbox Freecam tracer on");
4950
context.waitTick();
5051
assertScreenshotEquals(context, "freecam_tracer",
51-
"https://i.imgur.com/jYqDFzE.png");
52+
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/teKaxAK.png"
53+
: "https://i.imgur.com/jYqDFzE.png");
5254
clearChat(context);
5355

5456
// Clean up

src/gametest/java/net/wurstclient/gametest/tests/XRayHackTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public static void testXRayHack(ClientGameTestContext context,
4040
context.waitTick();
4141
world.waitForChunksRender();
4242
assertScreenshotEquals(context, "xray_default",
43-
"https://i.imgur.com/Dftamqv.png");
43+
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/02KZHLm.png"
44+
: "https://i.imgur.com/Dftamqv.png");
4445
input.pressKey(GLFW.GLFW_KEY_X);
4546
clearChat(context);
4647

@@ -51,7 +52,8 @@ public static void testXRayHack(ClientGameTestContext context,
5152
context.waitTick();
5253
world.waitForChunksRender();
5354
assertScreenshotEquals(context, "xray_exposed_only",
54-
"https://i.imgur.com/QlEpQTu.png");
55+
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/xplrJwM.png"
56+
: "https://i.imgur.com/QlEpQTu.png");
5557
input.pressKey(GLFW.GLFW_KEY_X);
5658
clearChat(context);
5759

@@ -62,7 +64,8 @@ public static void testXRayHack(ClientGameTestContext context,
6264
context.waitTick();
6365
world.waitForChunksRender();
6466
assertScreenshotEquals(context, "xray_opacity",
65-
"https://i.imgur.com/0nLulJn.png");
67+
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/MFc821z.png"
68+
: "https://i.imgur.com/0nLulJn.png");
6669
input.pressKey(GLFW.GLFW_KEY_X);
6770
clearChat(context);
6871

@@ -73,7 +76,8 @@ public static void testXRayHack(ClientGameTestContext context,
7376
context.waitTick();
7477
world.waitForChunksRender();
7578
assertScreenshotEquals(context, "xray_exposed_only_opacity",
76-
"https://i.imgur.com/noPWDUl.png");
79+
WurstTest.IS_MOD_COMPAT_TEST ? "https://i.imgur.com/GRHgW6P.png"
80+
: "https://i.imgur.com/noPWDUl.png");
7781
input.pressKey(GLFW.GLFW_KEY_X);
7882
clearChat(context);
7983

0 commit comments

Comments
 (0)