diff --git a/docs/build.md b/docs/build.md index 4f5b25173..cd7a62971 100644 --- a/docs/build.md +++ b/docs/build.md @@ -550,7 +550,7 @@ We no longer post files to FTP folders, nor publish individual files without con * org.unicode.text.UCD * TestUnicodeInvariants.java 1. Run>Run As... Java Application\ - Will create the following file of results: + Will create the following files of results: ``` {Generated}/UnicodeTestResults.txt ``` @@ -623,6 +623,8 @@ We no longer post files to FTP folders, nor publish individual files without con and what are likely remedies (changing properties, adding to an exceptions list, changing the test case). Improve these comments as needed. +1. Additional tests for UTS #39 data are found in [unicodetools/src/main/resources/org/unicode/text/UCD/SecurityInvariantTest.txt](https://github.com/unicode-org/unicodetools/blob/main/unicodetools/src/main/resources/org/unicode/text/UCD/SecurityInvariantTest.txt). + 1. These are reported in `{Generated}/UnicodeTestResults-security.txt` when running `TestTestUnicodeInvariants`. ### Options diff --git a/unicodetools/src/main/java/org/unicode/text/UCD/TestUnicodeInvariants.java b/unicodetools/src/main/java/org/unicode/text/UCD/TestUnicodeInvariants.java index d122441e5..6bfdc0edf 100644 --- a/unicodetools/src/main/java/org/unicode/text/UCD/TestUnicodeInvariants.java +++ b/unicodetools/src/main/java/org/unicode/text/UCD/TestUnicodeInvariants.java @@ -77,7 +77,7 @@ public static void main(String[] args) throws IOException { System.out.println("HTML?\t" + doHtml); - testInvariants(file, doRange); + testInvariants(file, null, doRange); } static Transliterator toHTML; @@ -124,26 +124,26 @@ enum Expected { /** * Fetch a reader for our input data. * - * @param inputFile if null, read DEFAULT_FILE from classpath + * @param inputFile read from classpath * @return BufferedReader * @throws IOException */ private static BufferedReader getInputReader(String inputFile) throws IOException { - if (inputFile != null) { - return FileUtilities.openUTF8Reader(Settings.SRC_UCD_DIR, inputFile); - } - - // null: read it from resource data - return FileUtilities.openFile(TestUnicodeInvariants.class, DEFAULT_FILE); + return FileUtilities.openFile(TestUnicodeInvariants.class, inputFile); } /** * @param inputFile file to input, defaults to DEFAULT_FILE + * @param suffix Suffix for the test results report file, added after a hyphen if non-null. * @param doRange normally true * @return number of failures (0 is better) * @throws IOException */ - public static int testInvariants(String inputFile, boolean doRange) throws IOException { + public static int testInvariants(String inputFile, String suffix, boolean doRange) + throws IOException { + if (inputFile == null) { + inputFile = DEFAULT_FILE; + } TestUnicodeInvariants.doRange = doRange; parseErrorCount = 0; testFailureCount = 0; @@ -151,7 +151,9 @@ public static int testInvariants(String inputFile, boolean doRange) throws IOExc try (final PrintWriter out2 = FileUtilities.openUTF8Writer( Settings.Output.GEN_DIR, - "UnicodeTestResults." + (doHtml ? "html" : "txt"))) { + "UnicodeTestResults" + + (suffix == null ? "" : "-" + suffix) + + (doHtml ? ".html" : ".txt"))) { final StringWriter writer = new StringWriter(); try (PrintWriter out3 = new PrintWriter(writer)) { out = out3; diff --git a/unicodetools/src/test/java/org/unicode/text/UCD/TestTestUnicodeInvariants.java b/unicodetools/src/test/java/org/unicode/text/UCD/TestTestUnicodeInvariants.java index f74750a59..f8a578325 100644 --- a/unicodetools/src/test/java/org/unicode/text/UCD/TestTestUnicodeInvariants.java +++ b/unicodetools/src/test/java/org/unicode/text/UCD/TestTestUnicodeInvariants.java @@ -31,13 +31,14 @@ void testSRC_UCD_DIR() { @Test void testUnicodeInvariants() throws IOException { - int rc = TestUnicodeInvariants.testInvariants(null, true); + int rc = TestUnicodeInvariants.testInvariants(null, null, true); assertEquals(0, rc, "TestUnicodeInvariants.testInvariants(default) failed"); } @Test void testSecurityInvariants() throws IOException { - int rc = TestUnicodeInvariants.testInvariants("SecurityInvariantTest.txt", true); + int rc = + TestUnicodeInvariants.testInvariants("SecurityInvariantTest.txt", "security", true); assertEquals(0, rc, "TestUnicodeInvariants.testInvariants(security) failed"); } }