Skip to content

Commit 232cb9a

Browse files
committed
Changed test stacktrace printing
Should now print the line of code throwing the error, as well as the error type and description.
1 parent 2a8f9b7 commit 232cb9a

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

liquidjava-verifier/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
<groupId>org.apache.maven.plugins</groupId>
9494
<artifactId>maven-surefire-plugin</artifactId>
9595
<version>3.2.1</version>
96+
<configuration>
97+
<trimStackTrace>true</trimStackTrace>
98+
</configuration>
9699
</plugin>
97100

98101
<plugin>

liquidjava-verifier/src/test/java/liquidjava/api/tests/TestExamples.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,43 @@ public void testPath(final Path path) {
3535
boolean isDirectory = Files.isDirectory(path);
3636

3737
// run verification
38-
CommandLineLauncher.launch(path.toAbsolutePath().toString());
38+
CommandLineLauncher.launch(path.toFile().toString());
3939

4040
// verification should pass, check if any errors were found
4141
if (shouldPass(pathName) && diagnostics.foundError()) {
42-
System.out.println("Error in: " + pathName + " --- should pass but an error was found");
42+
System.out.println("Error in: " + pathName + " --- should pass but an error was found. \n"
43+
+ diagnostics.getErrorOutput());
4344
fail();
4445
}
4546
// verification should fail, check if it failed as expected (we assume each error test has exactly one error)
4647
else if (shouldFail(pathName)) {
4748
if (!diagnostics.foundError()) {
48-
System.out.println("Error in: " + pathName + " --- should fail but no errors were found");
49+
System.out.println("Error in: " + pathName + " --- should fail but no errors were found. \n"
50+
+ diagnostics.getErrorOutput());
4951
fail();
5052
} else {
5153
// check if expected error was found
5254
Optional<String> expected = isDirectory ? getExpectedErrorFromDirectory(path)
5355
: getExpectedErrorFromFile(path);
5456
if (diagnostics.getErrors().size() > 1) {
55-
System.out.println("Multiple errors found in: " + pathName + " --- expected exactly one error");
57+
System.out.println("Multiple errors found in: " + pathName + " --- expected exactly one error. \n"
58+
+ diagnostics.getErrorOutput());
59+
System.out.println(diagnostics.getErrorOutput());
5660
fail();
5761
}
5862
LJError error = diagnostics.getErrors().iterator().next();
5963
if (error.getPosition() == null) {
60-
System.out.println("Error in: " + pathName + " --- error has no position information");
64+
System.out.println("Error in: " + pathName + " --- error has no position information. \n"
65+
+ diagnostics.getErrorOutput());
66+
System.out.println(diagnostics.getErrorOutput());
6167
fail();
6268
}
6369
if (expected.isPresent()) {
6470
String expectedError = expected.get();
6571
String foundError = error.getTitle();
6672
if (!foundError.equalsIgnoreCase(expectedError)) {
6773
System.out.println("Error in: " + pathName + " --- expected error: " + expectedError
68-
+ ", but found: " + foundError);
74+
+ ", but found: " + foundError + ". \n" + diagnostics.getErrorOutput());
6975
fail();
7076
}
7177
} else {
@@ -115,7 +121,7 @@ public void testMultiplePaths() {
115121
CommandLineLauncher.launch(paths);
116122
// Check if any of the paths that should be correct found an error
117123
if (diagnostics.foundError()) {
118-
System.out.println("Error found in files that should be correct");
124+
System.out.println("Error found in files that should be correct. \n" + diagnostics.getErrorOutput());
119125
fail();
120126
}
121127
}

0 commit comments

Comments
 (0)