GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improve debug mode detection in JUnit Jupiter by cj81499 · Pull Request #2973 · junit-team/junit-framework

Conversation

@cj81499

@cj81499 cj81499 commented Jul 8, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Overview

I'm handling an upgrade from JUnit 4 to JUnit 5 and noticed that disabling our timeouts with -Djunit.jupiter.execution.timeout.mode=disabled_on_debug is not working as expected.

We use VSCode as our editor/IDE. When using the Debugger for Java extension to debug tests.

When ran in my project, the following "test" prints [-ea, -Djunit.jupiter.execution.timeout.mode=disabled_on_debug, -XX:+ShowCodeDetailsInExceptionMessages, -Dfile.encoding=UTF-8]

When ran with the debugger in my project, the following "test" prints [-Xdebug, -Xnoagent, -Djava.compiler=NONE, -Xrunjdwp:transport=dt_socket,address=localhost:34399,server=n,suspend=y, -ea, -Djunit.jupiter.execution.timeout.mode=disabled_on_debug, -XX:+ShowCodeDetailsInExceptionMessages, -Dfile.encoding=UTF-8]

@Test
void test() {
  System.out.println(ManagementFactory.getRuntimeMXBean().getInputArguments());
}

Notably, the first 4 argument of the output from the run using the debugger are not present from the run without the debugger.

JUnit 4 detected -Xdebug as a sign of debugging, but (prior to this change) JUnit 5 does not, leading to the unexpected timeouts while debugging (and regression, compared to JUnit 4). Since JUnit 4 used it, I figured -Xdebug was the best thing to detect.

I'm not really sure how to test this kind of thing, but I'm open to suggestions.


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

  • There are no TODOs left in the code
  • Method preconditions are checked and documented in the method's Javadoc
  • Coding conventions (e.g. for logging) have been followed
  • Change is covered by automated tests including corner cases, errors, and exception handling
  • Public API has Javadoc and @API annotations
  • Change is documented in the User Guide and Release Notes
  • All continuous integration builds pass

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cj81499
cj81499 marked this pull request as ready for review July 8, 2022 21:03
@sbrannen

sbrannen commented Jul 9, 2022

Copy link
Copy Markdown
Member

Since JUnit 4 used it, I figured -Xdebug was the best thing to detect.

I don't recall the details, but I believe that was not picked for a reason.

It might be better to just check if one of the arguments contains jdwp (see Java Debug Wire Protocol.

That would then work for -Xrunjdwp as well as -agentlib:jdwp.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sbrannen sbrannen changed the title fix debug detection Improve debug mode detection in JUnit Jupiter Jul 9, 2022
@sbrannen sbrannen added type: enhancement component: Jupiter status: new labels Jul 9, 2022
@sbrannen

sbrannen commented Jul 9, 2022

Copy link
Copy Markdown
Member

related discussion in #2026 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cj81499

cj81499 commented Jul 9, 2022

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. I expect I'll have time to fix this up on Monday.

Any input on writing tests? Or are you comfortable without?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sbrannen

sbrannen commented Jul 10, 2022

Copy link
Copy Markdown
Member

Any input on writing tests? Or are you comfortable without?

It appears we don't have any tests for that (at least not with the initial commit ddb8c61), so I guess it will be OK without additional tests for this particular feature.

cj81499 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

marcphilipp
marcphilipp requested changes Jul 22, 2022
View reviewed changes
Comment thread junit-platform-commons/src/main/java/org/junit/platform/commons/util/RuntimeUtils.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@marcphilipp marcphilipp added this to the 5.9 GA milestone Jul 22, 2022
cj81499 added 3 commits July 22, 2022 16:30
@cj81499
fix debug detection
1944513
@cj81499
apply feedback from @sbrannen
d731f62
@cj81499
apply feedback from @marcphilipp
e79c59b
@cj81499
cj81499 requested a review from marcphilipp July 22, 2022 16:32
@marcphilipp marcphilipp added status: in progress status: new and removed status: new labels Jul 26, 2022
@marcphilipp
Improve formatting
d50f0df
@marcphilipp marcphilipp removed the status: new label Jul 26, 2022
marcphilipp
marcphilipp approved these changes Jul 26, 2022
View reviewed changes
@marcphilipp
marcphilipp merged commit 2aaf24c into junit-team:main Jul 26, 2022
@marcphilipp

marcphilipp commented Jul 26, 2022

Copy link
Copy Markdown
Member

@cj81499 Thanks for your contribution! 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@marcphilipp marcphilipp removed the status: in progress label Jul 26, 2022
@cj81499

cj81499 commented Jul 26, 2022

Copy link
Copy Markdown
Contributor Author

@marcphilipp thanks for your help getting it merged!
Selfishly, I'm happy to have it fixed :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@marcphilipp marcphilipp marcphilipp approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

component: Jupiter type: enhancement

Projects

None yet

Milestone

5.9 GA

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@cj81499 @sbrannen @marcphilipp
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.