Skip to content

Commit 9ec5766

Browse files
rybakmarcphilipp
authored andcommitted
Unify messages about exit codes in StandaloneTests
Some tests in StandaloneTests provide concatenation of standard output and standard error as a message for the assertion about exit code, while other tests provide only standard output. Some use method de.sormuras.bartholdy.Result#getOutput while others use method de.sormuras.bartholdy.Result#getOutputLines. Unify these approaches by replacing the messages with a supplier that gives a) a human-readable message about exit codes, and b) both standard output and standard error. (cherry picked from commit 3184a6e)
1 parent 2efacd3 commit 9ec5766

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 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");
@@ -98,7 +98,7 @@ void compile() throws Exception {
9898
.addArguments(workspace.resolve("src/standalone/VintageIntegration.java")).build() //
9999
.run();
100100

101-
assertEquals(0, result.getExitCode(), result.getOutput("out") + result.getOutput("err"));
101+
assertEquals(0, result.getExitCode(), () -> getExitCodeMessage(result));
102102
assertTrue(result.getOutput("out").isEmpty());
103103
assertTrue(result.getOutput("err").isEmpty());
104104

@@ -327,7 +327,7 @@ private static Result discover(String... args) {
327327
.build() //
328328
.run(false);
329329

330-
assertEquals(0, result.getExitCode(), String.join("\n", result.getOutputLines("out")));
330+
assertEquals(0, result.getExitCode(), () -> getExitCodeMessage(result));
331331
return result;
332332
}
333333

@@ -349,7 +349,7 @@ void execute() throws IOException {
349349
.addArguments("--classpath", "bin").build() //
350350
.run(false);
351351

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

354354
var workspace = Request.WORKSPACE.resolve("standalone");
355355
var expectedOutLines = Files.readAllLines(workspace.resolve("expected-out.txt"));
@@ -384,7 +384,7 @@ void executeOnJava8() throws IOException {
384384
.addArguments("--classpath", "bin").build() //
385385
.run(false);
386386

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

389389
var workspace = Request.WORKSPACE.resolve("standalone");
390390
var expectedOutLines = Files.readAllLines(workspace.resolve("expected-out.txt"));
@@ -420,7 +420,7 @@ void executeOnJava8SelectPackage() throws IOException {
420420
.addArguments("--classpath", "bin").build() //
421421
.run(false);
422422

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

425425
var workspace = Request.WORKSPACE.resolve("standalone");
426426
var expectedOutLines = Files.readAllLines(workspace.resolve("expected-out.txt"));
@@ -461,6 +461,11 @@ void executeWithJarredTestClasses() {
461461
.build() //
462462
.run(false);
463463

464-
assertEquals(1, result.getExitCode(), String.join("\n", result.getOutputLines("out")));
464+
assertEquals(1, result.getExitCode(), () -> getExitCodeMessage(result));
465+
}
466+
467+
private static String getExitCodeMessage(Result result) {
468+
return "Exit codes don't match. Stdout:\n" + result.getOutput("out") + //
469+
"\n\nStderr:\n" + result.getOutput("err") + "\n";
465470
}
466471
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy