From d940a99c05a2556354f6a700fdb4496a32e70808 Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Sun, 21 Dec 2025 10:17:15 +0900 Subject: [PATCH 1/2] test(TestRunner): Handle file reading and exceptions better --- src/nu/validator/client/TestRunner.java | 35 +++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/nu/validator/client/TestRunner.java b/src/nu/validator/client/TestRunner.java index d19cf23c3..9a6ecb198 100644 --- a/src/nu/validator/client/TestRunner.java +++ b/src/nu/validator/client/TestRunner.java @@ -26,7 +26,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; @@ -34,7 +33,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.regex.Pattern; @@ -56,7 +54,6 @@ import nu.validator.messages.MessageEmitterAdapter; import nu.validator.validation.SimpleDocumentValidator; -@SuppressWarnings("unchecked") public class TestRunner extends MessageEmitterAdapter { private boolean inError = false; @@ -218,6 +215,14 @@ private void checkFiles(List files) throws IOException { checkHtmlFile(file); } } catch (IOException | SAXException e) { + if (verbose) { + out.println(String.format( + "\"%s\": error: Exception while processing file: %s", + this.getFileURL(file), e.getMessage())); + e.printStackTrace(out); + out.flush(); + } + failed = true; } if (inError) { failed = true; @@ -233,7 +238,7 @@ private boolean messageMatches(String testFilename) { "?"); String messageExpected = expectedMessages.get(testFilename).getString().replaceAll( "\\p{C}", "?"); - // FIXME: The string replacements below are a hack to "normalize" + // NOTE: The string replacements below are a hack to "normalize" // error messages reported for bad values of the ins/del datetime // attribute, to work around the fact that in Java 8, parts of // those error messages don't always get emitted in the same order @@ -260,6 +265,11 @@ private void checkInvalidFiles(List files) throws IOException { checkHtmlFile(file); } } catch (IOException | SAXException e) { + err.println(String.format( + "\"%s\": error: Exception while processing file: %s", + file.getPath(), + e.getMessage())); + err.flush(); } if (exception != null) { testFilename = this.getRelativePathname(file, baseDir); @@ -322,6 +332,16 @@ private void checkHasWarningFiles(List files) throws IOException { checkHtmlFile(file); } } catch (IOException | SAXException e) { + failed = true; + try { + err.println(String.format( + "\"%s\": error: Exception while checking file: %s", + this.getFileURL(file), + e.getMessage())); + err.flush(); + } catch (MalformedURLException e1) { + throw new RuntimeException(e1); + } } if (exception != null) { testFilename = this.getRelativePathname(file, baseDir); @@ -463,7 +483,12 @@ public boolean runTestSuite() throws SAXException, Exception { baseDir = messagesFile.getCanonicalFile().getParentFile(); FileInputStream fis = new FileInputStream(messagesFile); JsonReader reader = Json.createReader(fis); - expectedMessages = (Map)reader.readObject(); + javax.json.JsonObject jsonObject = reader.readObject(); + final Map expectedMessagesMap = new HashMap(); + for (Map.Entry entry : jsonObject.entrySet()) { + expectedMessagesMap.put(entry.getKey(), entry.getValue()); + } + expectedMessages = (Map) expectedMessagesMap; } else { baseDir = new File(System.getProperty("user.dir")); } From 1e96cfbd87b2155c4514598dc242e3131abc037d Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Sun, 21 Dec 2025 10:30:30 +0900 Subject: [PATCH 2/2] chore(Java): Update .settings/org.eclipse.jdt.core.prefs --- .settings/org.eclipse.jdt.core.prefs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 194132e5b..1a3ed0024 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -2,7 +2,7 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.comparingIdentical=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.forbiddenReference=error org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error @@ -11,7 +11,8 @@ org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=error +org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error