@@ -34,6 +34,7 @@ public static void main(String[] args) throws Exception {
3434 }
3535
3636 void generateConformanceReport () throws Exception {
37+ LOGGER .fine (() -> "Starting conformance report generation" );
3738 TestResults results = runTests ();
3839
3940 System .out .println ("\n === JSON Test Suite Conformance Report ===" );
@@ -59,11 +60,13 @@ void generateConformanceReport() throws Exception {
5960 System .out .printf ("Overall Conformance: %.1f%%%n" , conformance );
6061
6162 if (!results .shouldPassButFailed .isEmpty ()) {
63+ LOGGER .fine (() -> "Valid JSON that failed to parse count=" + results .shouldPassButFailed .size ());
6264 System .out .println ("\n ⚠️ Valid JSON that failed to parse:" );
6365 results .shouldPassButFailed .forEach (f -> System .out .println (" - " + f ));
6466 }
65-
67+
6668 if (!results .shouldFailButPassed .isEmpty ()) {
69+ LOGGER .fine (() -> "Invalid JSON that was incorrectly accepted count=" + results .shouldFailButPassed .size ());
6770 System .out .println ("\n ⚠️ Invalid JSON that was incorrectly accepted:" );
6871 results .shouldFailButPassed .forEach (f -> System .out .println (" - " + f ));
6972 }
@@ -74,12 +77,14 @@ void generateConformanceReport() throws Exception {
7477 }
7578
7679 void generateJsonReport () throws Exception {
80+ LOGGER .fine (() -> "Starting JSON report generation" );
7781 TestResults results = runTests ();
7882 JsonObject report = createJsonReport (results );
7983 System .out .println (Json .toDisplayString (report , 2 ));
8084 }
8185
8286 private TestResults runTests () throws Exception {
87+ LOGGER .fine (() -> "Walking test files under: " + TEST_DIR .toAbsolutePath ());
8388 if (!Files .exists (TEST_DIR )) {
8489 throw new RuntimeException ("Test suite not downloaded. Run: ./mvnw clean compile generate-test-resources -pl json-compatibility-suite" );
8590 }
@@ -92,31 +97,39 @@ private TestResults runTests() throws Exception {
9297 int nPass = 0 , nFail = 0 ;
9398 int iAccept = 0 , iReject = 0 ;
9499
95- var files = Files .walk (TEST_DIR )
96- .filter (p -> p .toString ().endsWith (".json" ))
97- .sorted ()
98- .toList ();
100+ List <Path > files ;
101+ try (var stream = Files .walk (TEST_DIR )) {
102+ files = stream
103+ .filter (p -> p .toString ().endsWith (".json" ))
104+ .sorted ()
105+ .toList ();
106+ }
107+ LOGGER .fine (() -> "Discovered JSON test files: " + files .size ());
99108
100109 for (Path file : files ) {
101110 String filename = file .getFileName ().toString ();
102- String content = null ;
103- char [] charContent = null ;
111+ String content ;
112+ char [] charContent ;
113+ final Path filePathForLog = file ;
114+ LOGGER .fine (() -> "Processing file: " + filePathForLog );
104115
105116 try {
106117 content = Files .readString (file , StandardCharsets .UTF_8 );
107118 charContent = content .toCharArray ();
108119 } catch (MalformedInputException e ) {
109- LOGGER .warning ( "UTF-8 failed for " + filename + ", using robust encoding detection" );
120+ LOGGER .finer (()-> "UTF-8 failed for " + filename + ", using robust encoding detection" );
110121 try {
111122 byte [] rawBytes = Files .readAllBytes (file );
112123 charContent = RobustCharDecoder .decodeToChars (rawBytes , filename );
113124 } catch (Exception ex ) {
114- throw new RuntimeException ("Failed to read test file " + filename + " - this is a fundamental I/O failure, not an encoding issue: " + ex .getMessage (), ex );
125+ skippedFiles .add (filename );
126+ LOGGER .fine (() -> "Skipping unreadable file: " + filename + " due to: " + ex .getClass ().getSimpleName () + ": " + ex .getMessage ());
127+ continue ;
115128 }
116129 }
117130
118131 // Test with char[] API (always available)
119- boolean parseSucceeded = false ;
132+ boolean parseSucceeded ;
120133 try {
121134 Json .parse (charContent );
122135 parseSucceeded = true ;
@@ -126,6 +139,8 @@ private TestResults runTests() throws Exception {
126139 LOGGER .warning ("StackOverflowError on file: " + filename );
127140 parseSucceeded = false ; // Treat as parse failure
128141 }
142+ final boolean parseResultForLog = parseSucceeded ;
143+ LOGGER .fine (() -> "Parsed " + filename + ": " + (parseResultForLog ? "SUCCESS" : "FAIL" ));
129144
130145 // Update counters based on results
131146 if (parseSucceeded ) {
@@ -148,7 +163,13 @@ private TestResults runTests() throws Exception {
148163 }
149164 }
150165 }
151-
166+ final int yPassF = yPass ;
167+ final int yFailF = yFail ;
168+ final int nPassF = nPass ;
169+ final int nFailF = nFail ;
170+ final int iAcceptF = iAccept ;
171+ final int iRejectF = iReject ;
172+ LOGGER .fine (() -> "Finished processing files. yPass=" + yPassF + ", yFail=" + yFailF + ", nPass=" + nPassF + ", nFail=" + nFailF + ", iAccept=" + iAcceptF + ", iReject=" + iRejectF );
152173 return new TestResults (files .size (), skippedFiles .size (),
153174 yPass , yFail , nPass , nFail , iAccept , iReject ,
154175 shouldPassButFailed , shouldFailButPassed , skippedFiles );
0 commit comments