RFR: 8229186: Improve error messages for TestStringIntrinsics failures

Igor Ignatyev iignatyev at openjdk.java.net
Mon Sep 28 20:03:18 UTC 2020


On Thu, 10 Sep 2020 12:20:05 GMT, Evgeny Nikitin <enikitin at openjdk.org> wrote:

> pre-Skara RFR thread: [link](https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2020-May/038416.html)
> 
> Error reporting was improved by writing a C-style escaped string representations for the variables passed to the
> methods being tested. For array comparisons, a dedicated diff-formatter was implemented.
> Sample output for comparing byte arrays (with artificial failure):
>  ----------System.err:(21/1553)----------
>  Result: (false) of 'arrayEqualsB' is not equal to expected (true)
>  Arrays differ starting from [index: 7]:
>  ... 5, 6,   7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...
>  ... 5, 6, 125, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...
>            ^^^^
>  java.lang.RuntimeException: Result: (false) of 'arrayEqualsB' is not
>  equal to expected (true)
>           at
>  compiler.intrinsics.string.TestStringIntrinsics.invokeAndCheckArrays(TestStringIntrinsics.java:273)
>            at ... stack trace continues - E.N.
>  Sample output for comparing char arrays:
>  ----------System.err:(21/1579)*----------
>  Result: (false) of 'arrayEqualsC' is not equal to expected (true)
>  Arrays differ starting from [index: 7]:
>  ... \\u0005, \\u0006, \\u0007, \\u0008, \\u0009, \\n, ...
>  ... \\u0005, \\u0006,      }, \\u0008, \\u0009, \\n, ...
>                      ^^^^^^^
>  java.lang.RuntimeException: Result: (false) of 'arrayEqualsC' is not
>  equal to expected (true)
>           at
>  compiler.intrinsics.string.TestStringIntrinsics.invokeAndCheckArrays(TestStringIntrinsics.java:280)
>            at
>  ... and so on - E.N.
> 
> testing: open/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsics.java on linux, windows, macosx.

Changes requested by iignatyev (Reviewer).

test/lib-test/jdk/test/lib/format/ArrayDiffTest.java line 106:

> 104:                         "[122]%n" +
> 105:                         "[  7, 8, 9, 10, 125, 12, 13]%n" +
> 106:                         " ^^^");

as far as I remember, the commonly used practice is to align all these lines.

(there are other places w/ the same "problem")

test/lib/jdk/test/lib/format/ArrayCodec.java line 260:

> 258:             if (delta > 0) {
> 259:                 element = Format.paddingForWidth(delta) + element;
> 260:         }

wrong indent

test/lib/jdk/test/lib/format/Format.java line 109:

> 107:      */
> 108:     public static String paddingForWidth(int width) {
> 109:         return new String(" ").repeat(width);

why not just?
Suggestion:

        return " ".repeat(width);

test/lib/jdk/test/lib/format/ArrayDiff.java line 83:

> 81:     public static class Defaults {
> 82:         final static int WIDTH = 80;
> 83:         final static int CONTEXT_BEFORE = 2;

either these constants should be `public`, or `Defaults` class should be `package-private`, otherwise, you get a public
class w/ no public fields.

-------------

PR: https://git.openjdk.java.net/jdk/pull/112


More information about the core-libs-dev mailing list