Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public static class ConsoleOutputOptions {
@Option(names = "--details", paramLabel = "MODE", defaultValue = DEFAULT_DETAILS_NAME, description = "Select an output details mode for when tests are executed. " //
+ "Use one of: ${COMPLETION-CANDIDATES}. If 'none' is selected, " //
+ "then only the summary and test failures are shown. Default: ${DEFAULT-VALUE}.")
private final Details details = DEFAULT_DETAILS;
private Details details = DEFAULT_DETAILS;

@Option(names = "--details-theme", paramLabel = "THEME", description = "Select an output details tree theme for when tests are executed. "
+ "Use one of: ${COMPLETION-CANDIDATES}. Default is detected based on default character encoding.")
private final Theme theme = DEFAULT_THEME;
private Theme theme = DEFAULT_THEME;

@Option(names = "--redirect-stdout", paramLabel = "FILE", description = "Redirect test output to stdout to a file.")
private @Nullable Path stdout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,55 +68,55 @@ public static class SelectorOptions {

@Option(names = { "-u",
"--select-uri" }, paramLabel = "URI", arity = "1..*", converter = SelectorConverter.Uri.class, description = "Select a URI for test discovery. This option can be repeated.")
private final List<UriSelector> selectedUris = new ArrayList<>();
private List<UriSelector> selectedUris = new ArrayList<>();

@Option(names = { "-f",
"--select-file" }, paramLabel = "FILE", arity = "1..*", converter = SelectorConverter.File.class, //
description = "Select a file for test discovery. "
+ "The line and column numbers can be provided as URI query parameters (e.g. foo.txt?line=12&column=34). "
+ "This option can be repeated.")
private final List<FileSelector> selectedFiles = new ArrayList<>();
private List<FileSelector> selectedFiles = new ArrayList<>();

@Option(names = { "-d",
"--select-directory" }, paramLabel = "DIR", arity = "1..*", converter = SelectorConverter.Directory.class, description = "Select a directory for test discovery. This option can be repeated.")
private final List<DirectorySelector> selectedDirectories = new ArrayList<>();
private List<DirectorySelector> selectedDirectories = new ArrayList<>();

@Option(names = { "-o",
"--select-module" }, paramLabel = "NAME", arity = "1..*", converter = SelectorConverter.Module.class, description = "Select single module for test discovery. This option can be repeated.")
private final List<ModuleSelector> selectedModules = new ArrayList<>();
private List<ModuleSelector> selectedModules = new ArrayList<>();

@Option(names = { "-p",
"--select-package" }, paramLabel = "PKG", arity = "1..*", converter = SelectorConverter.Package.class, description = "Select a package for test discovery. This option can be repeated.")
private final List<PackageSelector> selectedPackages = new ArrayList<>();
private List<PackageSelector> selectedPackages = new ArrayList<>();

@Option(names = { "-c",
"--select-class" }, paramLabel = "CLASS", arity = "1..*", converter = SelectorConverter.Class.class, description = "Select a class for test discovery. This option can be repeated.")
private final List<ClassSelector> selectedClasses = new ArrayList<>();
private List<ClassSelector> selectedClasses = new ArrayList<>();

@Option(names = { "-m",
"--select-method" }, paramLabel = "NAME", arity = "1..*", converter = SelectorConverter.Method.class, description = "Select a method for test discovery. This option can be repeated.")
private final List<MethodSelector> selectedMethods = new ArrayList<>();
private List<MethodSelector> selectedMethods = new ArrayList<>();

@Option(names = { "-r",
"--select-resource" }, paramLabel = "RESOURCE", arity = "1..*", converter = SelectorConverter.ClasspathResource.class, description = "Select a classpath resource for test discovery. This option can be repeated.")
private final List<ClasspathResourceSelector> selectedClasspathResources = new ArrayList<>();
private List<ClasspathResourceSelector> selectedClasspathResources = new ArrayList<>();

@Option(names = { "-i",
"--select-iteration" }, paramLabel = "PREFIX:VALUE[INDEX(..INDEX)?(,INDEX(..INDEX)?)*]", arity = "1..*", converter = SelectorConverter.Iteration.class, //
description = "Select iterations for test discovery via a prefixed identifier and a list of indexes or index ranges "
+ "(e.g. method:com.acme.Foo#m()[1..2] selects the first and second iteration of the m() method in the com.acme.Foo class). "
+ "This option can be repeated.")
private final List<IterationSelector> selectedIterations = new ArrayList<>();
private List<IterationSelector> selectedIterations = new ArrayList<>();

@Option(names = { "--select-unique-id",
"--uid" }, paramLabel = "UNIQUE-ID", arity = "1..*", converter = SelectorConverter.UniqueId.class, //
description = "Select a unique id for test discovery. This option can be repeated.")
private final List<UniqueIdSelector> selectedUniqueIds = new ArrayList<>();
private List<UniqueIdSelector> selectedUniqueIds = new ArrayList<>();

@Option(names = "--select", paramLabel = "PREFIX:VALUE", arity = "1..*", converter = SelectorConverter.Identifier.class, //
description = "Select via a prefixed identifier (e.g. method:com.acme.Foo#m selects the m() method in the com.acme.Foo class). "
+ "This option can be repeated.")
private final List<DiscoverySelectorIdentifier> selectorIdentifiers = new ArrayList<>();
private List<DiscoverySelectorIdentifier> selectorIdentifiers = new ArrayList<>();

SelectorOptions() {
}
Expand Down Expand Up @@ -147,46 +147,46 @@ public static class FilterOptions {
+ "names that begin with \"Test\" or end with \"Test\" or \"Tests\". " //
+ "When this option is repeated, all patterns will be combined using OR semantics. " //
+ "Default: ${DEFAULT-VALUE}")
private final List<String> includeClassNamePatterns = new ArrayList<>();
private List<String> includeClassNamePatterns = new ArrayList<>();

@Option(names = { "-N",
"--exclude-classname" }, paramLabel = "PATTERN", arity = "1", description = "Provide a regular expression to exclude those classes whose fully qualified names match. " //
+ "When this option is repeated, all patterns will be combined using OR semantics.")
private final List<String> excludeClassNamePatterns = new ArrayList<>();
private List<String> excludeClassNamePatterns = new ArrayList<>();

@Option(names = "--include-package", paramLabel = "PKG", arity = "1", description = "?Provide a package to be included in the test run. This option can be repeated.")
private final List<String> includePackages = new ArrayList<>();
private List<String> includePackages = new ArrayList<>();

@Option(names = "--exclude-package", paramLabel = "PKG", arity = "1", description = "Provide a package to be excluded from the test run. This option can be repeated.")
private final List<String> excludePackages = new ArrayList<>();
private List<String> excludePackages = new ArrayList<>();

@Option(names = "--include-methodname", paramLabel = "PATTERN", arity = "1", description = "Provide a regular expression to include only methods whose fully qualified names without parameters match. " //
+ "When this option is repeated, all patterns will be combined using OR semantics.")
private final List<String> includeMethodNamePatterns = new ArrayList<>();
private List<String> includeMethodNamePatterns = new ArrayList<>();

@Option(names = "--exclude-methodname", paramLabel = "PATTERN", arity = "1", description = "Provide a regular expression to exclude those methods whose fully qualified names without parameters match. " //
+ "When this option is repeated, all patterns will be combined using OR semantics.")
private final List<String> excludeMethodNamePatterns = new ArrayList<>();
private List<String> excludeMethodNamePatterns = new ArrayList<>();

@Option(names = { "-t",
"--include-tag" }, paramLabel = "TAG", arity = "1", description = "Provide a tag or tag expression to include only tests whose tags match. "
+ //
"When this option is repeated, all patterns will be combined using OR semantics.")
private final List<String> includedTags = new ArrayList<>();
private List<String> includedTags = new ArrayList<>();

@Option(names = { "-T",
"--exclude-tag" }, paramLabel = "TAG", arity = "1", description = "Provide a tag or tag expression to exclude those tests whose tags match. "
+ //
"When this option is repeated, all patterns will be combined using OR semantics.")
private final List<String> excludedTags = new ArrayList<>();
private List<String> excludedTags = new ArrayList<>();

@Option(names = { "-e",
"--include-engine" }, paramLabel = "ID", arity = "1", description = "Provide the ID of an engine to be included in the test run. This option can be repeated.")
private final List<String> includedEngines = new ArrayList<>();
private List<String> includedEngines = new ArrayList<>();

@Option(names = { "-E",
"--exclude-engine" }, paramLabel = "ID", arity = "1", description = "Provide the ID of an engine to be excluded from the test run. This option can be repeated.")
private final List<String> excludedEngines = new ArrayList<>();
private List<String> excludedEngines = new ArrayList<>();

private void applyTo(TestDiscoveryOptions result) {
result.setIncludedClassNamePatterns(this.includeClassNamePatterns);
Expand All @@ -207,10 +207,10 @@ public static class RuntimeConfigurationOptions {
@Option(names = { "-" + CP_OPTION, "--classpath",
"--class-path" }, converter = ClasspathEntriesConverter.class, paramLabel = "PATH", arity = "1", description = "Provide additional classpath entries "
+ "-- for example, for adding engines and their dependencies. This option can be repeated.")
private final List<Path> additionalClasspathEntries = new ArrayList<>();
private List<Path> additionalClasspathEntries = new ArrayList<>();

// Implementation note: the @Option annotation is on a setter method to allow validation.
private final Map<String, String> configurationParameters = new LinkedHashMap<>();
private Map<String, String> configurationParameters = new LinkedHashMap<>();

@Option(names = "--config-resource", paramLabel = "PATH", arity = "1", description = "Set configuration parameters for test discovery and execution via a classpath resource. This option can be repeated.")
private List<String> configurationParametersResources = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ public static ProcessStarter gradlew() {
.addArguments("-PjunitVersion=" + Helper.version());
}

public static ProcessStarter maven() {
return maven(currentJdkHome());
}

public static ProcessStarter maven(Path javaHome) {
return new ProcessStarter() //
.executable(Path.of(System.getProperty("mavenDistribution")).resolve("bin").resolve(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,33 @@

package platform.tooling.support.tests;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.junit.jupiter.api.condition.JRE;

final class MavenEnvVars {

private static final Map<String, String> FOR_JDK24_AND_LATER = Map.of("MAVEN_OPTS", String.join(" ", //
private static final List<String> FOR_JDK24_AND_LATER = List.of( //
"--enable-native-access=ALL-UNNAMED", // https://issues.apache.org/jira/browse/MNG-8248
"--sun-misc-unsafe-memory-access=allow" // https://issues.apache.org/jira/browse/MNG-8399
));
);
private static final List<String> FOR_JDK26_AND_LATER = List.of( //
"--enable-final-field-mutation=ALL-UNNAMED" // https://github.com/junit-team/junit-framework/issues/5173
);

static Map<String, String> forJre(JRE jre) {
return jre.compareTo(JRE.JAVA_24) >= 0 ? FOR_JDK24_AND_LATER : Map.of();
var list = new ArrayList<String>();
if (jre.compareTo(JRE.JAVA_24) >= 0)
list.addAll(FOR_JDK24_AND_LATER);
if (jre.compareTo(JRE.JAVA_26) >= 0) {
// exclude "leyden" and "valhalla" builds
if (Runtime.version().build().orElse(0) >= 25) {
list.addAll(FOR_JDK26_AND_LATER);
}
}
return list.isEmpty() ? Map.of() : Map.of("MAVEN_OPTS", String.join(" ", list));
}

private MavenEnvVars() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ void verifyErrorMessageForUnalignedClasspath(JRE jre, Path javaHome, @TempDir Pa
.workingDir(copyToWorkspace(Projects.JUPITER_STARTER, workspace)) //
.addArguments(localMavenRepo.toCliArgument(), "-Dmaven.repo=" + MavenRepo.dir()) //
.addArguments("-Dsnapshot.repo.url=" + mavenRepoProxy.getBaseUri()) //
.addArguments("-Djunit.platform.commons.version=1.11.4").addArguments("--update-snapshots",
"--batch-mode", "verify") //
.addArguments("-Djunit.platform.commons.version=1.11.4") //
.addArguments("--update-snapshots", "--batch-mode", "verify") //
.putEnvironment(MavenEnvVars.forJre(jre)) //
.redirectOutput(outputFiles);
var result = starter.startAndWait();
Expand Down