-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8229186: Improve error messages for TestStringIntrinsics failures #112
Conversation
👋 Welcome back enikitin! A progress list of the required criteria for merging this PR into |
@lepestock The following labels will be automatically applied to this pull request: When this pull request is ready to be reviewed, an RFR email will be sent to the corresponding mailing lists. If you would like to change these labels, use the |
Webrevs
|
Responding to the comments from pre-Skara thread:
the invokeAndCheck is very generic, it can be called with different objects and expect any kind of result, not only boolean. Therefore its output format radically differs from what an array-comparator should show.
for Object arrays, one can use that.
I would argue that - I find it useful for printing arrays (and this usage has been utilised in the TestStringIntrinsics.java). In addition, I dont' like the practice of making such huge classes an inner classes as this reduces readability and modularity. Other issues have been fixed. I added support for int, long, Object and String arrays. |
I am not sure I understand what you mean...
you don't need
oki.
|
Well, I think that would make The other method,
Unfortunately, it is used in the ArrayCodec.format (which is used in TestStringIntrinsics.java) - to make it possible to call it with everything and not swamp the code with overloads. |
I think we do, as people tend to first look at exception's messages and only then look thru other logs, so having relative information in the exception is always a good thing. should 10K symbols become a problem (this though would also mean that you can't print the compared values w/
hm, I somehow missed that usage, but you don't need to repeat to the same switch over a component type in |
Ok, I got it. I was blind and stupid, sorry. Fixed, please check the e6fb6d0
<sigh>... I can see no better solution here. The |
I'd use
wouldn't the following patch do? --- a/test/lib/jdk/test/lib/format/ArrayDiff.java
+++ b/test/lib/jdk/test/lib/format/ArrayDiff.java
@@ -123,41 +123,10 @@ public class ArrayDiff<E> implements Diff {
if (!bothAreArrays || !componentTypesAreSame) {
throw new IllegalArgumentException("Both arguments should be arrays of the same type");
}
-
- var type = first.getClass().getComponentType();
- if (type == byte.class) {
- return new ArrayDiff<>(
- ArrayCodec.of((byte[])first),
- ArrayCodec.of((byte[])second),
- width, contextBefore);
- } else if (type == int.class) {
- return new ArrayDiff<>(
- ArrayCodec.of((int[])first),
- ArrayCodec.of((int[])second),
- width, contextBefore);
- } else if (type == long.class) {
- return new ArrayDiff<>(
- ArrayCodec.of((long[])first),
- ArrayCodec.of((long[])second),
- width, contextBefore);
- } else if (type == char.class) {
- return new ArrayDiff<>(
- ArrayCodec.of((char[])first),
- ArrayCodec.of((char[])second),
- width, contextBefore);
- } else if (type == String.class) {
- return new ArrayDiff<>(
- ArrayCodec.of((String[])first),
- ArrayCodec.of((String[])second),
- width, contextBefore);
- } else if (!type.isPrimitive() && !type.isArray()) {
- return new ArrayDiff<>(
- ArrayCodec.of((Object[])first),
- ArrayCodec.of((Object[])second),
- width, contextBefore);
- }
-
- throw new IllegalArgumentException("Unsupported array component type: " + type);
+ return new ArrayDiff(
+ ArrayCodec.of(first),
+ ArrayCodec.of(second),
+ width, contextBefore);
}
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* @library /test/lib | ||
* @run testng jdk.test.lib.format.ArrayDiffTest | ||
*/ | ||
public class ArrayDiffTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be it makes sense to check null values. Also, reversed checks. For example there is first = [1, ..], second = []. But no check for first = [], second = [1, ..] for some cases,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the 39992fc. That ended in finding a minor issue, actually (ArrayDiff.java:180). Sometimes reversing can be valuable, thanks!
@lepestock This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 455 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@iignatev, @lmesnik) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@lepestock |
|
||
} | ||
|
||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be -1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An interesting notice, actually. It should be either -1
or result
depending on whether arrays are equal, or one array is a prefix of another. Fixed in the 174148a.
/integrate |
@lepestock |
/sponsor |
@iignatev @lepestock Since your change was applied there have been 455 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 52e45a3. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Restore looks like this now: ``` 0x0000000106e4dfcc: movk x9, #0x5e4, lsl openjdk#16 0x0000000106e4dfd0: movk x9, #0x1, lsl openjdk#32 0x0000000106e4dfd4: blr x9 0x0000000106e4dfd8: ldp x2, x3, [sp, openjdk#16] 0x0000000106e4dfdc: ldp x4, x5, [sp, openjdk#32] 0x0000000106e4dfe0: ldp x6, x7, [sp, openjdk#48] 0x0000000106e4dfe4: ldp x8, x9, [sp, openjdk#64] 0x0000000106e4dfe8: ldp x10, x11, [sp, openjdk#80] 0x0000000106e4dfec: ldp x12, x13, [sp, openjdk#96] 0x0000000106e4dff0: ldp x14, x15, [sp, openjdk#112] 0x0000000106e4dff4: ldp x16, x17, [sp, openjdk#128] 0x0000000106e4dff8: ldp x0, x1, [sp], openjdk#144 0x0000000106e4dffc: ldp xzr, x19, [sp], openjdk#16 0x0000000106e4e000: ldp x22, x23, [sp, openjdk#16] 0x0000000106e4e004: ldp x24, x25, [sp, openjdk#32] 0x0000000106e4e008: ldp x26, x27, [sp, openjdk#48] 0x0000000106e4e00c: ldp x28, x29, [sp, openjdk#64] 0x0000000106e4e010: ldp x30, xzr, [sp, openjdk#80] 0x0000000106e4e014: ldp x20, x21, [sp], openjdk#96 0x0000000106e4e018: ldur x12, [x29, #-24] 0x0000000106e4e01c: ldr x22, [x12, openjdk#16] 0x0000000106e4e020: add x22, x22, #0x30 0x0000000106e4e024: ldr x8, [x28, openjdk#8] ```
pre-Skara RFR thread: link
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):
Sample output for comparing char arrays:
testing: open/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsics.java on linux, windows, macosx.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/112/head:pull/112
$ git checkout pull/112