-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better logging and smarter behaviour for drop invalid mappings (#233)
* improve logging for drop invalid mappings * add a simple test for drop invalid mappings * fix empty mappings test * fix drop invalid mappings test * remove debug print * add another out of bounds parameter * write some docs * suggestions! Co-authored-by: Iota <[email protected]> * fix method name * update description * add a test to run the help command --------- Co-authored-by: Iota <[email protected]>
- Loading branch information
Showing
10 changed files
with
182 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
enigma-cli/src/test/java/org/quiltmc/enigma/command/DropInvalidMappingsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.quiltmc.enigma.command; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.quiltmc.enigma.TestUtil; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
public class DropInvalidMappingsTest extends CommandTest { | ||
private static final Path JAR = TestUtil.obfJar("lone_class"); | ||
private static final Path INPUT_DIR = getResource("/drop_invalid_mappings/input/"); | ||
private static final Path EXPECTED_DIR = getResource("/drop_invalid_mappings/expected/"); | ||
private static final Path INVALID_MAPPINGS_INPUT = INPUT_DIR.resolve("InvalidMappings.mapping"); | ||
private static final Path INVALID_MAPPINGS_EXPECTED = EXPECTED_DIR.resolve("InvalidMappings.mapping"); | ||
private static final Path EMPTY_MAPPINGS_INPUT = INPUT_DIR.resolve("EmptyMappings.mapping"); | ||
private static final Path EMPTY_MAPPINGS_EXPECTED = EXPECTED_DIR.resolve("EmptyMappings.mapping"); | ||
|
||
@Test | ||
public void testInvalidMappings() throws Exception { | ||
Path resultFile = Files.createTempFile("invalidMappingsResult", ".mapping"); | ||
|
||
DropInvalidMappingsCommand.run(JAR, INVALID_MAPPINGS_INPUT, resultFile); | ||
|
||
String expectedLines = Files.readString(INVALID_MAPPINGS_EXPECTED); | ||
String actualLines = Files.readString(resultFile); | ||
|
||
Assertions.assertEquals(expectedLines, actualLines); | ||
} | ||
|
||
@Test | ||
public void testEmptyMappings() throws Exception { | ||
Path resultFile = Files.createTempFile("emptyMappingsResult", ".mapping"); | ||
|
||
DropInvalidMappingsCommand.run(JAR, EMPTY_MAPPINGS_INPUT, resultFile); | ||
|
||
String expectedLines = Files.readString(EMPTY_MAPPINGS_EXPECTED); | ||
String actualLines = Files.readString(resultFile); | ||
|
||
Assertions.assertEquals(expectedLines, actualLines); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
enigma-cli/src/test/java/org/quiltmc/enigma/command/HelpCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.quiltmc.enigma.command; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class HelpCommandTest { | ||
@Test | ||
void test() throws Exception { | ||
// for manually verifying output | ||
new HelpCommand().run(); | ||
} | ||
} |
Empty file.
5 changes: 5 additions & 0 deletions
5
enigma-cli/src/test/resources/drop_invalid_mappings/expected/InvalidMappings.mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CLASS a InvalidMappings | ||
FIELD a slayField Ljava/lang/String; | ||
METHOD <init> (Ljava/lang/String;)V | ||
ARG 1 coolParameter | ||
METHOD a slayMethod ()Ljava/lang/String; |
5 changes: 5 additions & 0 deletions
5
enigma-cli/src/test/resources/drop_invalid_mappings/input/EmptyMappings.mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CLASS a | ||
FIELD a Ljava/lang/String; | ||
METHOD <init> (Ljava/lang/String;)V | ||
ARG 1 | ||
METHOD a ()Ljava/lang/String; |
12 changes: 12 additions & 0 deletions
12
enigma-cli/src/test/resources/drop_invalid_mappings/input/InvalidMappings.mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CLASS a InvalidMappings | ||
FIELD a slayField Ljava/lang/String; | ||
FIELD b fakeField I | ||
METHOD <init> (Ljava/lang/String;)V | ||
ARG 0 outOfBoundsParameter1 | ||
ARG 1 coolParameter | ||
ARG 2 outOfBoundsParameter2 | ||
ARG 3 outOfBoundsParameter3 | ||
METHOD a slayMethod ()Ljava/lang/String; | ||
ARG 1 fakeParameter | ||
METHOD b fakeMethod ()V | ||
CLASS b NonExistentClass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters