Skip to content

Commit

Permalink
Improve debug mode detection in JUnit Jupiter (#2973)
Browse files Browse the repository at this point in the history
Co-authored-by: Marc Philipp <mail@marcphilipp.de>
  • Loading branch information
cj81499 and marcphilipp authored Jul 26, 2022
1 parent be55668 commit 2aaf24c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,8 @@ JUnit Jupiter supports the `junit.jupiter.execution.timeout.mode` configuration
to configure when timeouts are applied. There are three modes: `enabled`, `disabled`,
and `disabled_on_debug`. The default mode is `enabled`.
A VM runtime is considered to run in debug mode when one of its input parameters starts
with `-agentlib:jdwp`. This heuristic is queried by the `disabled_on_debug` mode.
with `-agentlib:jdwp` or `-Xrunjdwp`.
This heuristic is queried by the `disabled_on_debug` mode.


[[writing-tests-parallel-execution]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,10 @@ private RuntimeUtils() {
* Try to determine whether the VM was started in debug mode or not.
*/
public static boolean isDebugMode() {
Optional<List<String>> optionalArguments = getInputArguments();
if (!optionalArguments.isPresent()) {
return false;
}
for (String argument : optionalArguments.get()) {
if (argument.startsWith("-agentlib:jdwp")) {
return true;
}
}
return false;
return getInputArguments() //
.map(args -> args.stream().anyMatch(
arg -> arg.startsWith("-agentlib:jdwp") || arg.startsWith("-Xrunjdwp"))) //
.orElse(false);
}

/**
Expand Down

0 comments on commit 2aaf24c

Please sign in to comment.