Skip to content

Commit 6c20951

Browse files
committed
Merge branch 'fix-standalone-test-java8' into fix-java-22-console-test-failures
Temporary merge to see if new tip of pull request junit-team#3416 fixes issue in the Java 22 pull request.
2 parents a086903 + 140dfa3 commit 6c20951

File tree

5 files changed

+87
-21
lines changed

5 files changed

+87
-21
lines changed

documentation/src/docs/asciidoc/user-guide/appendix.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ artifacts are deployed to Sonatype's {snapshot-repo}[snapshots repository] under
107107
The _Bill of Materials_ POM provided under the following Maven coordinates can be used to
108108
ease dependency management when referencing multiple of the above artifacts using
109109
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies[Maven]
110-
or https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html#sec:bom_import[Gradle].
110+
or https://docs.gradle.org/current/userguide/platforms.html#sub:bom_import[Gradle].
111111

112112
* *Group ID*: `org.junit`
113113
* *Artifact ID*: `junit-bom`

junit-bom/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ This module provides a Bill of Materials POM to ease dependency management using
44
or [Gradle]. Please refer to the [User Guide] for details.
55

66
[Maven]: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies
7-
[Gradle]: https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html#sec:bom_import
7+
[Gradle]: https://docs.gradle.org/current/userguide/platforms.html#sub:bom_import
88
[User Guide]: https://junit.org/junit5/docs/current/user-guide/#dependency-metadata-junit-bom
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
>> JAVA VERSION >>
2+
.+ org.junit.platform.launcher.core.ServiceLoaderRegistry load
3+
.+ Loaded LauncherInterceptor instances: ..
4+
.+ org.junit.platform.launcher.core.ServiceLoaderRegistry load
5+
.+ Loaded LauncherSessionListener instances: ..
6+
.+ org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines
7+
.+ Discovered TestEngines:
8+
- junit-jupiter .+
9+
- junit-vintage .+
10+
- junit-platform-suite .+
11+
.+ org.junit.platform.launcher.core.ServiceLoaderRegistry load
12+
.+ Loaded PostDiscoveryFilter instances: ..
13+
.+ org.junit.platform.launcher.core.ServiceLoaderRegistry load
14+
.+ Loaded LauncherDiscoveryListener instances: ..
15+
.+ org.junit.platform.launcher.core.ServiceLoaderRegistry load
16+
.+ Loaded TestExecutionListener instances: .+
17+
.+ org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines
18+
.+ Discovered TestEngines:
19+
- junit-jupiter .+
20+
- junit-vintage .+
21+
- junit-platform-suite .+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
>> TREE >>
2+
Failures (2):
3+
>> STACKTRACE >>
4+
5+
Test run finished after \d+ ms
6+
[ 11 containers found ]
7+
[ 0 containers skipped ]
8+
[ 11 containers started ]
9+
[ 0 containers aborted ]
10+
[ 11 containers successful ]
11+
[ 0 containers failed ]
12+
[ 10 tests found ]
13+
[ 2 tests skipped ]
14+
[ 8 tests started ]
15+
[ 1 tests aborted ]
16+
[ 5 tests successful ]
17+
[ 2 tests failed ]
18+

platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/StandaloneTests.java

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void listAllObservableEngines() {
6969
.addArguments("engines", "--disable-banner").build() //
7070
.run(false);
7171

72-
assertEquals(0, result.getExitCode(), String.join("\n", result.getOutputLines("out")));
72+
assertEquals(0, result.getExitCode(), () -> getExitCodeMessage(result));
7373

7474
var jupiterVersion = Helper.version("junit-jupiter-engine");
7575
var suiteVersion = Helper.version("junit-platform-suite-engine");
@@ -89,6 +89,8 @@ void compile() throws Exception {
8989
var result = Request.builder() //
9090
.setTool(new Javac()) //
9191
.setProject("standalone") //
92+
.addArguments("-Xlint:-options")
93+
.addArguments("--release", "8")
9294
.addArguments("-proc:none") //
9395
.addArguments("-d", workspace.resolve("bin")) //
9496
.addArguments("--class-path", MavenRepo.jar("junit-platform-console-standalone")) //
@@ -98,7 +100,7 @@ void compile() throws Exception {
98100
.addArguments(workspace.resolve("src/standalone/VintageIntegration.java")).build() //
99101
.run();
100102

101-
assertEquals(0, result.getExitCode(), result.getOutput("out") + result.getOutput("err"));
103+
assertEquals(0, result.getExitCode(), () -> getExitCodeMessage(result));
102104
assertTrue(result.getOutput("out").isEmpty());
103105
assertTrue(result.getOutput("err").isEmpty());
104106

@@ -327,7 +329,7 @@ private static Result discover(String... args) {
327329
.build() //
328330
.run(false);
329331

330-
assertEquals(0, result.getExitCode(), String.join("\n", result.getOutputLines("out")));
332+
assertEquals(0, result.getExitCode(), () -> getExitCodeMessage(result));
331333
return result;
332334
}
333335

@@ -349,13 +351,13 @@ void execute() throws IOException {
349351
.addArguments("--classpath", "bin").build() //
350352
.run(false);
351353

352-
assertEquals(1, result.getExitCode(), String.join("\n", result.getOutputLines("out")));
354+
assertEquals(1, result.getExitCode(), () -> getExitCodeMessage(result));
353355

354356
var workspace = Request.WORKSPACE.resolve("standalone");
355357
var expectedOutLines = Files.readAllLines(workspace.resolve("expected-out.txt"));
356358
var expectedErrLines = Files.readAllLines(workspace.resolve("expected-err.txt"));
357-
assertLinesMatch(expectedOutLines, result.getOutputLines("out"), result.getOutput("out"));
358-
assertLinesMatch(expectedErrLines, result.getOutputLines("err"), result.getOutput("err"));
359+
assertLinesMatch(expectedOutLines, result.getOutputLines("out"));
360+
assertLinesMatch(expectedErrLines, result.getOutputLines("err"));
359361

360362
var jupiterVersion = Helper.version("junit-jupiter-engine");
361363
var vintageVersion = Helper.version("junit-vintage-engine");
@@ -368,11 +370,12 @@ void execute() throws IOException {
368370
@Test
369371
@Order(4)
370372
void executeOnJava8() throws IOException {
373+
Java java8 = getJava8();
371374
var result = Request.builder() //
372-
.setTool(new Java()) //
373-
.setJavaHome(Helper.getJavaHome("8").orElseThrow(TestAbortedException::new)) //
375+
.setTool(java8) //
376+
.setJavaHome(java8.getHome()) //
374377
.setProject("standalone") //
375-
.addArguments("--show-version") //
378+
.addArguments("-showversion") //
376379
.addArguments("-enableassertions") //
377380
.addArguments("-Djava.util.logging.config.file=logging.properties") //
378381
.addArguments("-Djunit.platform.launcher.interceptors.enabled=true") //
@@ -384,11 +387,11 @@ void executeOnJava8() throws IOException {
384387
.addArguments("--classpath", "bin").build() //
385388
.run(false);
386389

387-
assertEquals(1, result.getExitCode(), String.join("\n", result.getOutputLines("out")));
390+
assertEquals(1, result.getExitCode(), () -> getExitCodeMessage(result));
388391

389392
var workspace = Request.WORKSPACE.resolve("standalone");
390-
var expectedOutLines = Files.readAllLines(workspace.resolve("expected-out.txt"));
391-
var expectedErrLines = Files.readAllLines(workspace.resolve("expected-err.txt"));
393+
var expectedOutLines = Files.readAllLines(workspace.resolve("expected-out-java8.txt"));
394+
var expectedErrLines = Files.readAllLines(workspace.resolve("expected-err-java8.txt"));
392395
assertLinesMatch(expectedOutLines, result.getOutputLines("out"));
393396
assertLinesMatch(expectedErrLines, result.getOutputLines("err"));
394397

@@ -404,11 +407,12 @@ void executeOnJava8() throws IOException {
404407
@Order(5)
405408
// https://github.com/junit-team/junit5/issues/2600
406409
void executeOnJava8SelectPackage() throws IOException {
410+
Java java8 = getJava8();
407411
var result = Request.builder() //
408-
.setTool(new Java()) //
409-
.setJavaHome(Helper.getJavaHome("8").orElseThrow(TestAbortedException::new)) //
412+
.setTool(java8) //
413+
.setJavaHome(java8.getHome()) //
410414
.setProject("standalone") //
411-
.addArguments("--show-version") //
415+
.addArguments("-showversion") //
412416
.addArguments("-enableassertions") //
413417
.addArguments("-Djava.util.logging.config.file=logging.properties") //
414418
.addArguments("-Djunit.platform.launcher.interceptors.enabled=true") //
@@ -420,11 +424,11 @@ void executeOnJava8SelectPackage() throws IOException {
420424
.addArguments("--classpath", "bin").build() //
421425
.run(false);
422426

423-
assertEquals(1, result.getExitCode(), String.join("\n", result.getOutputLines("out")));
427+
assertEquals(1, result.getExitCode(), () -> getExitCodeMessage(result));
424428

425429
var workspace = Request.WORKSPACE.resolve("standalone");
426-
var expectedOutLines = Files.readAllLines(workspace.resolve("expected-out.txt"));
427-
var expectedErrLines = Files.readAllLines(workspace.resolve("expected-err.txt"));
430+
var expectedOutLines = Files.readAllLines(workspace.resolve("expected-out-java8.txt"));
431+
var expectedErrLines = Files.readAllLines(workspace.resolve("expected-err-java8.txt"));
428432
assertLinesMatch(expectedOutLines, result.getOutputLines("out"));
429433
assertLinesMatch(expectedErrLines, result.getOutputLines("err"));
430434

@@ -461,6 +465,29 @@ void executeWithJarredTestClasses() {
461465
.build() //
462466
.run(false);
463467

464-
assertEquals(1, result.getExitCode(), String.join("\n", result.getOutputLines("out")));
468+
assertEquals(1, result.getExitCode(), () -> getExitCodeMessage(result));
469+
}
470+
471+
private static String getExitCodeMessage(Result result) {
472+
return "Exit codes don't match. Stdout:\n" +
473+
result.getOutput("out") + "\n\nStderr:\n" + result.getOutput("err") + "\n";
474+
}
475+
476+
/**
477+
* Speicial override of class {@link Java} to resolve against a different {@code JAVA_HOME}.
478+
*/
479+
private static Java getJava8() {
480+
Path java8Home = Helper.getJavaHome("8").orElseThrow(TestAbortedException::new);
481+
return new Java() {
482+
@Override
483+
public Path getHome() {
484+
return java8Home;
485+
}
486+
487+
@Override
488+
public String getVersion() {
489+
return "8";
490+
}
491+
};
465492
}
466493
}

0 commit comments

Comments
 (0)