-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8295239: Refactor java/util/Formatter/Basic script into a Java native test launcher #10715
8295239: Refactor java/util/Formatter/Basic script into a Java native test launcher #10715
Conversation
👋 Welcome back justin-curtis-lu! A progress list of the required criteria for merging this PR into |
@justin-curtis-lu 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 /label pull request command. |
Webrevs
|
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.
Hi Justin,
A few comments on a quick pass through your changes
@@ -101,6 +90,6 @@ public static void main(String[] args) { | |||
throw new RuntimeException((fail + pass) + " tests: " | |||
+ fail + " failure(s), first", first); | |||
else | |||
out.println("all " + (fail + pass) + " tests passed"); | |||
System.out.println("all " + (fail + pass) + " tests passed"); |
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.
Perhaps use System.out.printf vs println and "fail" should not be needed as all tests passed
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.
Thank you Lance, will take a look at this and the rest of the comments
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.
Careful. I suspect that "fail" is the number of tests that are expected to fail.
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.
Thanks Iris,
It got hidden in the code snippet, but line 89 is if (fail != 0)
,
so I do believe fail is redundant in 93.
|
||
|
||
@Test | ||
public void testUsPac() throws IOException{ |
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.
You could use a DataProvider
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.
I had the same thought
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.
Thanks Lance and Brent, replaced it with a JUnit parametrized test (DataProvider equivalent)
.reportDiagnosticSummary(); | ||
}catch(RuntimeException err){ | ||
throw new RuntimeException(String.format("$$$ %s: Test(s) failed or TestJVM did not build correctly." + | ||
" Check stderr output from diagnostics summary above%n", err.getMessage())); |
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.
Do you need to catch the RuntimeException and then throw a new RuntimeException? I think you might want to consider reworking this
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.
Thank you Lance, I dropped the catch altogether as there is already enough info in the test log output
@@ -101,6 +90,6 @@ public static void main(String[] args) { | |||
throw new RuntimeException((fail + pass) + " tests: " | |||
+ fail + " failure(s), first", first); | |||
else | |||
out.println("all " + (fail + pass) + " tests passed"); | |||
System.out.printf("all " + pass + " tests passed"); |
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.
This line is missing a newline; add a \n, or use println().
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.
I would suggest rewriting as System.out.printf("all %s tests passed%n", pass);
You could make a similar change to line 90 using String.format as done in the line 98 which was deleted
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.
I dropped the new line since when the output comes out of the sub process log
Without the newline it looks like
[ ... ]
vs
[...
]
private static final String TZ_UP = "US/Pacific"; | ||
// Asia/Novosibirsk time zone | ||
private static final String TZ_AN = "Asia/Novosibirsk"; |
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.
IMO it's not necessary to create constants if they'll only be used as a ValueSource
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.
True, but really a personal choice as it makes the ValueSource less wordy ;-)
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.
Also, when reading through a ValueSource / DataProvider, it's nice to see the actual values (vs variable/constant names) when practical/possible.
// Asia/Novosibirsk time zone | ||
private static final String TZ_AN = "Asia/Novosibirsk"; | ||
// Locale flag for testJVM | ||
private static final String LOCALE_PROV = "-Djava.locale.providers=CLDR"; |
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.
A name like "JAVA_OPTS" would better express how this value is used.
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.
agree
// Locale flag for testJVM | ||
private static final String LOCALE_PROV = "-Djava.locale.providers=CLDR"; | ||
// Test class | ||
private static final String SOURCE_CLASS = "Basic"; |
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.
This is the name of a compiled class to be run, not a source file, so perhaps, "TEST_CLASS"?
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.
agree
/* @test | ||
* @summary Unit tests for formatter | ||
* @library /test/lib | ||
* @compile Basic.java |
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.
For the record, I've not deduced how/why the rest of the .java files in the test get compiled to .class files...
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.
I suspect because the other classes are in the test.src directory they are being compiled which can be verified by Justin looking at the jtr log for the test
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.
Hi Justin,
We are getting close ;-)
Please see below
@@ -101,6 +90,6 @@ public static void main(String[] args) { | |||
throw new RuntimeException((fail + pass) + " tests: " | |||
+ fail + " failure(s), first", first); | |||
else | |||
out.println("all " + (fail + pass) + " tests passed"); | |||
System.out.printf("all " + pass + " tests passed"); |
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.
I would suggest rewriting as System.out.printf("all %s tests passed%n", pass);
You could make a similar change to line 90 using String.format as done in the line 98 which was deleted
// Locale flag for testJVM | ||
private static final String LOCALE_PROV = "-Djava.locale.providers=CLDR"; | ||
// Test class | ||
private static final String SOURCE_CLASS = "Basic"; |
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.
agree
else | ||
out.println("all " + (fail + pass) + " tests passed"); | ||
System.out.printf("All %s tests passed", pass); |
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.
%d, yes?
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.
Right, will change that
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.
And one on the previous line
else | ||
out.println("all " + (fail + pass) + " tests passed"); | ||
System.out.printf("All %s tests passed", pass); |
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.
And one on the previous line
else | ||
out.println("all " + (fail + pass) + " tests passed"); | ||
if (fail != 0) { | ||
throw new RuntimeException(String.format("%d tests: %d failure(s)" + |
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.
You might consider including ", first"
with the rest of the message string, instead of concatenating it. That line might end up slightly long, but it may be worth it.
Also, use %s
forfirst
, as it's a Throwable
;)
(You could also perhaps change first
-> first.toString()
in the final argument to format, to clarify.)
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.
Good point, will reassign it to one line.
"Also, use %s forfirst, as it's a Throwable",
I believe I am assigning %d to pass+fail and fail. I pass first as a Throwable to the runtime exception constructor.
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.
Oh, right. Carry on.
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.
Instead of using String.format() static method, using "...".formatted() is slightly shorter/concise.
// Build and run Basic class with correct configuration | ||
ProcessBuilder pb = ProcessTools.createTestJvm(JAVA_OPTS, TEST_CLASS); | ||
pb.environment().put("TZ", timeZone); | ||
Process process = pb.start(); |
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.
Nit: indentation
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, thanks!
output.shouldHaveExitValue(0) | ||
.reportDiagnosticSummary(); |
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.
Nit: indentation
@justin-curtis-lu 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 141 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 (@LanceAndersen, @bchristi-git, @naotoj) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
if (fail != 0) { | ||
var tests_message = "%d tests: %d failure(s)%n".formatted(fail + pass, fail); | ||
var trace_message = "Traceback of the first error located"; | ||
String message = "%s %s".formatted(tests_message, trace_message); |
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.
could use "var" as the previous statements ;-)
/integrate |
@justin-curtis-lu |
/sponsor |
Going to push as commit 902162c.
Your commit was automatically rebased without conflicts. |
@bchristi-git @justin-curtis-lu Pushed as commit 902162c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Issue: Formatter unit tests are launched via basic.sh
Fix: Replace basic.sh with a Java test launcher
Note: Java.internal.math was included in the original configuration of Basic, but I removed it as it was not used within the Basic unit tests
Original output on success

New output on success

Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10715/head:pull/10715
$ git checkout pull/10715
Update a local copy of the PR:
$ git checkout pull/10715
$ git pull https://git.openjdk.org/jdk pull/10715/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10715
View PR using the GUI difftool:
$ git pr show -t 10715
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10715.diff