Skip to content

Commit 9adc69b

Browse files
committed
Add Test for Multiple Paths
1 parent 0a0c021 commit 9adc69b

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

liquidjava-verifier/src/main/java/liquidjava/api/CommandLineLauncher.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public static ErrorEmitter launch(String... paths) {
6262
// launcher.getEnvironment().setSourceClasspath(
6363
// "lib1.jar:lib2.jar".split(":"));
6464
launcher.getEnvironment().setComplianceLevel(8);
65-
6665
launcher.run();
6766

6867
final Factory factory = launcher.getFactory();
@@ -82,13 +81,4 @@ public static ErrorEmitter launch(String... paths) {
8281

8382
return ee;
8483
}
85-
86-
/**
87-
* Launch the LiquidJava verifier on the given file or directory path (for testing purposes)
88-
* @param path Path to to be verified
89-
* @return ErrorEmitter containing any errors found during verification
90-
*/
91-
public static ErrorEmitter launchTest(String path) {
92-
return launch(path);
93-
}
9484
}

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import java.util.stream.Stream;
1010
import liquidjava.api.CommandLineLauncher;
1111
import liquidjava.errors.ErrorEmitter;
12+
13+
import org.junit.Test;
1214
import org.junit.jupiter.params.ParameterizedTest;
1315
import org.junit.jupiter.params.provider.MethodSource;
1416

@@ -27,7 +29,7 @@ public void testFile(final Path filePath) {
2729
String fileName = filePath.getFileName().toString();
2830

2931
// 1. Run the verifier on the file or package
30-
ErrorEmitter errorEmitter = CommandLineLauncher.launchTest(filePath.toAbsolutePath().toString());
32+
ErrorEmitter errorEmitter = CommandLineLauncher.launch(filePath.toAbsolutePath().toString());
3133

3234
// 2. Check if the file is correct or contains an error
3335
if ((fileName.startsWith("Correct") && errorEmitter.foundError())
@@ -68,4 +70,21 @@ private static Stream<Path> fileNameSource() throws IOException {
6870
return isFileStartingWithCorrectOrError || isDirectoryWithCorrectOrError;
6971
});
7072
}
73+
74+
/**
75+
* Test multiple paths at once, including both files and directories. This test ensures that the verifier can handle
76+
* multiple inputs correctly and that no errors are found in files/directories that are expected to be correct.
77+
*/
78+
@Test
79+
public void testMultiplePaths() {
80+
String[] paths = { "../liquidjava-example/src/main/java/testSuite/SimpleTest.java",
81+
"../liquidjava-example/src/main/java/testSuite/classes/arraylist_correct", };
82+
ErrorEmitter errorEmitter = CommandLineLauncher.launch(paths);
83+
84+
// Check if any of the paths that should be correct found an error
85+
if (errorEmitter.foundError()) {
86+
System.out.println("Error found in files that should be correct.");
87+
fail();
88+
}
89+
}
7190
}

0 commit comments

Comments
 (0)