@@ -20,20 +20,52 @@ public class TestExamples {
2020 @ MethodSource ("fileNameSource" )
2121 public void testFile (final Path filePath ) {
2222 String fileName = filePath .getFileName ().toString ();
23- ErrorEmitter errorEmitter = CommandLineLauncher .launchTest (filePath .toAbsolutePath ().toString ());
24- System .out .println (
25- errorEmitter .foundError () ? (errorEmitter .getFullMessage ()) : ("Correct! Passed Verification." ));
23+ System .out .println ("Testing file: " + fileName );
2624
27- if (fileName .startsWith ("Correct" ) && errorEmitter .foundError ()) {
28- fail ();
25+ // For Regular Files in the root directory check their name
26+ if (Files .isRegularFile (filePath )) {
27+ ErrorEmitter errorEmitter = CommandLineLauncher .launchTest (filePath .toAbsolutePath ().toString ());
28+ System .out .println (
29+ errorEmitter .foundError () ? (errorEmitter .getFullMessage ()) : ("Correct! Passed Verification." ));
30+
31+ if (fileName .startsWith ("Correct" ) && errorEmitter .foundError ()) {
32+ fail ();
33+ }
34+ if (fileName .startsWith ("Error" ) && !errorEmitter .foundError ()) {
35+ fail ();
36+ }
2937 }
30- if (fileName .startsWith ("Error" ) && !errorEmitter .foundError ()) {
31- fail ();
38+
39+ // For Directories and subdirectories check if they contain "error" or "correct" in their name
40+ if (Files .isDirectory (filePath ) && (fileName .contains ("error" ) || fileName .contains ("correct" ))) {
41+ System .out .println ("Inside directory " + fileName );
42+ ErrorEmitter errorEmitter = CommandLineLauncher .launchTest (filePath .toAbsolutePath ().toString ());
43+ System .out .println (
44+ errorEmitter .foundError () ? (errorEmitter .getFullMessage ()) : ("Correct! Passed Verification." ));
45+
46+ if (fileName .contains ("correct" ) && errorEmitter .foundError ()) {
47+ fail ();
48+ }
49+ if (fileName .contains ("error" ) && !errorEmitter .foundError ()) {
50+ fail ();
51+ }
3252 }
3353 }
3454
3555 private static Stream <Path > fileNameSource () throws IOException {
3656 return Files .find (Paths .get ("../liquidjava-example/src/main/java/testSuite/" ), Integer .MAX_VALUE ,
37- (filePath , fileAttr ) -> fileAttr .isRegularFile ());
57+ (filePath , fileAttr ) -> {
58+ // Get the parent directory path (root directory)
59+ Path rootDir = Paths .get ("../liquidjava-example/src/main/java/testSuite/" );
60+
61+ // 1. Files only in the root directory
62+ boolean isFileInRootDir = fileAttr .isRegularFile () && filePath .getParent ().equals (rootDir );
63+
64+ // 2. Directories and subdirectories (recursive search for directories)
65+ boolean isDirectory = fileAttr .isDirectory ();
66+
67+ // Return true if either condition matches
68+ return isFileInRootDir || isDirectory ;
69+ });
3870 }
3971}
0 commit comments