From 12d6d5e6eb67799cd72c50ac1770cb77a28cf01f Mon Sep 17 00:00:00 2001 From: ix0rai Date: Mon, 4 Nov 2024 17:28:34 -0600 Subject: [PATCH] [no ci] add a test to make sure broken unpick definitions error (#659) * add a test to make sure broken unpick definitions error * use unpick 3.0.9 * bump unpick to 3.0.10 --- buildSrc/src/test/java/quilt/internal/TasksTest.java | 10 ++++++++++ buildSrc/src/test/java/quilt/internal/TestUtil.java | 8 ++++---- .../broken-unpick-definitions/no_header.unpick | 5 +++++ .../broken-unpick-definitions/working.unpick | 10 ++++++++++ gradle/libs.versions.toml | 2 +- 5 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 buildSrc/src/test/resources/testProject/broken-unpick-definitions/no_header.unpick create mode 100644 buildSrc/src/test/resources/testProject/broken-unpick-definitions/working.unpick diff --git a/buildSrc/src/test/java/quilt/internal/TasksTest.java b/buildSrc/src/test/java/quilt/internal/TasksTest.java index b407cbafd5..a2c2d508b3 100644 --- a/buildSrc/src/test/java/quilt/internal/TasksTest.java +++ b/buildSrc/src/test/java/quilt/internal/TasksTest.java @@ -1,5 +1,6 @@ package quilt.internal; +import daomephsta.unpick.constantmappers.datadriven.parser.UnpickSyntaxException; import net.fabricmc.mappingio.tree.MappingTree; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.MethodOrderer; @@ -48,6 +49,7 @@ public class TasksTest { private static Path mappingsDir; private static Path profilePath; private static Path unpickDefinitions; + private static Path brokenUnpickDefinitions; private static Path perVersionMappingsJar; private static Path outputsDir; @@ -91,6 +93,7 @@ public static void setup() throws Exception { mappingsDir = testProjectDir.resolve("mappings/"); profilePath = testProjectDir.resolve("enigma_profile.json"); unpickDefinitions = testProjectDir.resolve("unpick-definitions/"); + brokenUnpickDefinitions = testProjectDir.resolve("broken-unpick-definitions/"); perVersionMappings = getResource("/test-intermediate.tiny"); perVersionMappingsJar = testProjectDir.resolve("test-hashed.jar"); @@ -263,6 +266,13 @@ public void testCombineUnpickDefinitions() throws Exception { assertEquals("g_type", file.getReturnConstantGroup("com/example/GClass", "toType", "(Ljava/lang/String;)I")); } + @Test + public void testCombineBrokenUnpickDefinitions() { + Path output = outputsDir.resolve("broken-combined-definitions.unpick"); + Collection input = List.of(brokenUnpickDefinitions.toFile().listFiles()); + assertThrows(UnpickSyntaxException.class, () -> CombineUnpickDefinitionsTask.combineUnpickDefinitions(input, output)); + } + @Test @Order(7) public void testRemapUnpickDefinitions() throws Exception { diff --git a/buildSrc/src/test/java/quilt/internal/TestUtil.java b/buildSrc/src/test/java/quilt/internal/TestUtil.java index f5561ba1fc..bd7c84b5be 100644 --- a/buildSrc/src/test/java/quilt/internal/TestUtil.java +++ b/buildSrc/src/test/java/quilt/internal/TestUtil.java @@ -42,19 +42,19 @@ private static void writeTree(Path path, MappingTree tree, MappingFormat format) } public static MemoryMappingTree readTinyV2(Path path) throws IOException { - return readTree(path, MappingFormat.TINY_2); + return readTree(path, MappingFormat.TINY_2_FILE); } public static void writeTinyV2(Path path, MappingTree tree) throws IOException { - writeTree(path, tree, MappingFormat.TINY_2); + writeTree(path, tree, MappingFormat.TINY_2_FILE); } public static MemoryMappingTree readEnigma(Path path) throws IOException { - return readTree(path, MappingFormat.ENIGMA); + return readTree(path, MappingFormat.ENIGMA_DIR); } public static void writeEnigma(Path path, MappingTree tree) throws IOException { - writeTree(path, tree, MappingFormat.ENIGMA); + writeTree(path, tree, MappingFormat.ENIGMA_DIR); } public static UnpickFile readUnpickFile(Path path, Path jar) throws Exception { diff --git a/buildSrc/src/test/resources/testProject/broken-unpick-definitions/no_header.unpick b/buildSrc/src/test/resources/testProject/broken-unpick-definitions/no_header.unpick new file mode 100644 index 0000000000..99c8eea0b1 --- /dev/null +++ b/buildSrc/src/test/resources/testProject/broken-unpick-definitions/no_header.unpick @@ -0,0 +1,5 @@ +flag f_flags com/example/FEnum FLAG_LEFT +flag f_flags com/example/FEnum FLAG_RIGHT + +target_method com/example/FEnum (Ljava/lang/String;II)V + param 0 f_flags diff --git a/buildSrc/src/test/resources/testProject/broken-unpick-definitions/working.unpick b/buildSrc/src/test/resources/testProject/broken-unpick-definitions/working.unpick new file mode 100644 index 0000000000..7c5ca88d86 --- /dev/null +++ b/buildSrc/src/test/resources/testProject/broken-unpick-definitions/working.unpick @@ -0,0 +1,10 @@ +v2 + +flag e_flags com/example/EClass FLAG_A +flag e_flags com/example/EClass FLAG_B +flag e_flags com/example/EClass FLAG_C +flag e_flags com/example/EClass FLAG_D + +# Test comment +target_method com/example/EClass m1 (I)V + param 0 e_flags diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 312896d279..401ba12701 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,7 @@ enigma = "2.5.0" enigma_plugin = "2.2.3" tiny_remapper = "0.7.2" stitch = "0.6.1" -unpick = "3.0.8" +unpick = "3.0.10" mapping_io = "0.6.1" javadoc_draftsman = "1.2.3"