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

Improve debug mode detection in JUnit Jupiter #2973

Merged
merged 4 commits into from Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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