Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a test to make sure broken unpick definitions error #659

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading