Skip to content
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

8288495: [test] Make OutputAnalyzer exception more informative #9247

Closed

Conversation

RogerRiggs
Copy link
Contributor

@RogerRiggs RogerRiggs commented Jun 22, 2022

The RuntimeException from OutputAnalyzer for expected and unexpected exit values should include both the actual and expected values.
The method shouldHaveExitvalue and shouldNotHaveExitValue include the value expected and the value not expected instead of the actual value returned. The values provided in the exception are already known quantities in the code, what is not known is the actual value.
The actual value is printed to stderr but not the expected value and in the logs, the exception report is frequently to stdout and therefor separated in the log from the output of stderr. Including both expected and actual values in the exception makes it easier to understand.

Exception messages should not include newlines.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8288495: [test] Make OutputAnalyzer exception more informative

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9247/head:pull/9247
$ git checkout pull/9247

Update a local copy of the PR:
$ git checkout pull/9247
$ git pull https://git.openjdk.org/jdk pull/9247/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9247

View PR using the GUI difftool:
$ git pr show -t 9247

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9247.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 22, 2022

👋 Welcome back rriggs! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 22, 2022
@openjdk
Copy link

openjdk bot commented Jun 22, 2022

@RogerRiggs The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot-runtime

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.

@openjdk openjdk bot added hotspot-runtime hotspot-runtime-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Jun 22, 2022
@mlbridge
Copy link

mlbridge bot commented Jun 22, 2022

Webrevs

{
try {
// Verify the exception message
OutputAnalyzer out = ProcessTools.executeProcess("true");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Roger, this test seems to run on all OS. Is true available on Windows? If yes, does it require a .exe suffix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Windows CreateProcess API appends ".exe". (if there is no suffix).
(And CI testing succeeded).

@jaikiran
Copy link
Member

The source changes look fine to me. The test file change would need a copyright year update.

@@ -502,7 +502,7 @@ public OutputAnalyzer shouldNotHaveExitValue(int notExpectedExitValue) {
if (getExitValue() == notExpectedExitValue) {
reportDiagnosticSummary();
throw new RuntimeException("Unexpected to get exit value of ["
+ notExpectedExitValue + "]\n");
+ notExpectedExitValue + "], exit value is: [" + getExitValue() + "]");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems redundant to me. "Unexpected to get exit value of [notExpectedExitValue]." should suffice?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this doesn't need changing as there is only one value to report.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, a bit overzealous on the expected vs actual.

Correct OutputAnalyzerTest
@lmesnik
Copy link
Member

lmesnik commented Jun 23, 2022

Please update copyrights in the test file, otherwise, the last version looks good.

@openjdk
Copy link

openjdk bot commented Jun 23, 2022

@RogerRiggs 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:

8288495: [test] Make OutputAnalyzer exception more informative

Reviewed-by: lmesnik, naoto, jpai, dholmes

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 109 new commits pushed to the master branch:

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 23, 2022
Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the change.

@RogerRiggs
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 24, 2022

Going to push as commit fdc8455.
Since your change was applied there have been 111 commits pushed to the master branch:

  • 925084c: 8288976: classfile parser 'wrong name' error message has the names the wrong way around
  • 17aacde: 8288669: compiler/vectorapi/VectorFPtoIntCastTest.java still fails with "IRViolationException: There were one or multiple IR rule failures."
  • 9dc9a64: 8287281: adjust guarantee in Handshake::execute for the case of target thread being current
  • 64782a7: 8288623: Move Continuation classes out of javaClasses.hpp
  • c8cc94a: 8288979: Improve CLDRConverter run time
  • 740169c: 8285521: Minor improvements in java.net.URI
  • 13cbb3a: 8289073: (fs) UnsatisfiedLinkError for sun.nio.fs.UnixCopyFile.bufferedCopy0()
  • b206d2d: 8289006: Cleanup from thread.hpp split
  • 2728770: 8288589: Files.readString ignores encoding errors for UTF-16
  • ef17ee4: 8288515: (ch) Unnecessary use of Math.addExact() in java.nio.channels.FileLock.overlaps()
  • ... and 101 more: https://git.openjdk.org/jdk/compare/6633855ca78ff0f5f1213a2a1424436678a30e55...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 24, 2022
@openjdk openjdk bot closed this Jun 24, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 24, 2022
@openjdk
Copy link

openjdk bot commented Jun 24, 2022

@RogerRiggs Pushed as commit fdc8455.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@RogerRiggs RogerRiggs deleted the 8288495-outputanalyzer-ex branch June 30, 2022 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants