@@ -827,9 +827,9 @@ public void checkFiles(boolean expectedFound, Collection<String> paths) {
827827 Path file = outputDir .resolve (path );
828828 boolean isFound = Files .exists (file );
829829 if (isFound == expectedFound ) {
830- passed (file , "file " + (isFound ? "found:" : "not found:" ) + " \n " );
830+ passed (file , "file " + (isFound ? "found:" : "not found:" ));
831831 } else {
832- failed (file , "file " + (isFound ? "found:" : "not found:" ) + " \n " );
832+ failed (file , "file " + (isFound ? "found:" : "not found:" ));
833833 }
834834 }
835835 }
@@ -946,9 +946,10 @@ protected void checking(String message) {
946946 *
947947 * @param file the file that was the focus of the check
948948 * @param message a short description of the outcome
949+ * @param details optional additional details
949950 */
950- protected void passed (Path file , String message ) {
951- passed (file + ": " + message );
951+ protected void passed (Path file , String message , String ... details ) {
952+ passed (file + ": " + message , details );
952953 }
953954
954955 /**
@@ -957,10 +958,14 @@ protected void passed(Path file, String message) {
957958 * <p>This method should be called after previously calling {@code checking(...)}.
958959 *
959960 * @param message a short description of the outcome
961+ * @param details optional additional details
960962 */
961- protected void passed (String message ) {
963+ protected void passed (String message , String ... details ) {
962964 numTestsPassed ++;
963965 print ("Passed" , message );
966+ for (var detail : details ) {
967+ detail .lines ().forEachOrdered (out ::println );
968+ }
964969 out .println ();
965970 }
966971
@@ -971,9 +976,10 @@ protected void passed(String message) {
971976 *
972977 * @param file the file that was the focus of the check
973978 * @param message a short description of the outcome
979+ * @param details optional additional details
974980 */
975- protected void failed (Path file , String message ) {
976- failed (file + ": " + message );
981+ protected void failed (Path file , String message , String ... details ) {
982+ failed (file + ": " + message , details );
977983 }
978984
979985 /**
@@ -982,8 +988,9 @@ protected void failed(Path file, String message) {
982988 * <p>This method should be called after previously calling {@code checking(...)}.
983989 *
984990 * @param message a short description of the outcome
991+ * @param details optional additional details
985992 */
986- protected void failed (String message ) {
993+ protected void failed (String message , String ... details ) {
987994 print ("FAILED" , message );
988995 StackWalker .getInstance ().walk (s -> {
989996 s .dropWhile (f -> f .getMethodName ().equals ("failed" ))
@@ -993,6 +1000,9 @@ protected void failed(String message) {
9931000 + "(" + f .getFileName () + ":" + f .getLineNumber () + ")" ));
9941001 return null ;
9951002 });
1003+ for (var detail : details ) {
1004+ detail .lines ().forEachOrdered (out ::println );
1005+ }
9961006 out .println ();
9971007 }
9981008
@@ -1002,10 +1012,7 @@ private void print(String prefix, String message) {
10021012 else {
10031013 out .print (prefix );
10041014 out .print (": " );
1005- out .print (message .replace ("\n " , NL ));
1006- if (!(message .endsWith ("\n " ) || message .endsWith (NL ))) {
1007- out .println ();
1008- }
1015+ message .lines ().forEachOrdered (out ::println );
10091016 }
10101017 }
10111018
@@ -1219,25 +1226,28 @@ private void check(Function<Integer, Range> finder, SearchKind kind, String s) {
12191226 boolean isFound = r != null ;
12201227 if (isFound == expectFound ) {
12211228 matches .add (lastMatch = r );
1222- passed (name + ": following " + kind + " " + (isFound ? "found:" : "not found:" ) + " \n "
1223- + s );
1229+ passed (name + ": the following " + kind + " was " + (isFound ? "found:" : "not found:" ),
1230+ s );
12241231 } else {
12251232 // item not found in order, so check if the item is found out of order, to determine the best message
12261233 if (expectFound && expectOrdered && start > 0 ) {
12271234 Range r2 = finder .apply (0 );
12281235 if (r2 != null ) {
1229- failed (name + ": following " + kind + " was found on line "
1236+ failed (name + ": output not as expected" ,
1237+ ">> the following " + kind + " was found on line "
12301238 + getLineNumber (r2 .start )
12311239 + ", but not in order as expected, on or after line "
1232- + getLineNumber (start )
1233- + ": \n "
1234- + s );
1240+ + getLineNumber (start ),
1241+ ">> " + kind + ":" ,
1242+ s );
12351243 return ;
12361244 }
12371245 }
1238- failed (name + ": following " + kind + " "
1239- + (isFound ? "found:" : "not found:" ) + "\n "
1240- + s + '\n' + "found \n " + content );
1246+ failed (name + ": output not as expected" ,
1247+ ">> the following " + kind + " was " + (isFound ? "found:" : "not found:" ),
1248+ s ,
1249+ ">> found" ,
1250+ content );
12411251 }
12421252
12431253 }
@@ -1374,8 +1384,9 @@ public OutputChecker checkComplete() {
13741384 if (uncovered .isEmpty ()) {
13751385 passed ("All output matched" );
13761386 } else {
1377- failed ("The following output was not matched: "
1378- + uncovered .stream ()
1387+ failed ("Output not as expected" ,
1388+ ">> The following output was not matched" ,
1389+ uncovered .stream ()
13791390 .map (Range ::toIntervalString )
13801391 .collect (Collectors .joining (", " )));
13811392 }
@@ -1395,8 +1406,9 @@ public OutputChecker checkEmpty() {
13951406 if (content == null || content .isEmpty ()) {
13961407 passed (name + " is empty, as expected" );
13971408 } else {
1398- failed (name + " is not empty; contains:\n "
1399- + content );
1409+ failed (name + " is not empty" ,
1410+ ">> found:" ,
1411+ content );
14001412 }
14011413 return this ;
14021414 }
@@ -1444,7 +1456,8 @@ private <T> OutputChecker checkAnyOf(SearchKind kind, List<T> items, BiFunction<
14441456 if (count == 0 ) {
14451457 failed ("no match found for any " + kind );
14461458 } else {
1447- passed (count + " matches found; earliest is " + earliest .toIntervalString ());
1459+ passed (count + " matches found" ,
1460+ ">> the earliest is: " + earliest .toIntervalString ());
14481461 }
14491462 return this ;
14501463 }
0 commit comments