Skip to content

Commit

Permalink
add a test to make sure broken unpick definitions error
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed Oct 25, 2024
1 parent 67c1c3c commit b079d0b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
10 changes: 10 additions & 0 deletions buildSrc/src/test/java/quilt/internal/TasksTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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<File> input = List.of(brokenUnpickDefinitions.toFile().listFiles());
assertThrows(UnpickSyntaxException.class, () -> CombineUnpickDefinitionsTask.combineUnpickDefinitions(input, output));
}

@Test
@Order(7)
public void testRemapUnpickDefinitions() throws Exception {
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/test/java/quilt/internal/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <init> (Ljava/lang/String;II)V
param 0 f_flags
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.8+local"
mapping_io = "0.6.1"
javadoc_draftsman = "1.2.3"

Expand Down

0 comments on commit b079d0b

Please sign in to comment.