Skip to content

Commit

Permalink
Don't exit with number of failures because Java will mod 256 the exit…
Browse files Browse the repository at this point in the history
… code so System.exit(512) == System.exit(256) == System.exit(0)
  • Loading branch information
cheister committed Dec 1, 2016
1 parent e969478 commit 1105c28
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -449,7 +449,7 @@ void run(Collection<String> tests) {
createUnexpectedExitHook(shutdownListener, swappableOut.getOriginal());
Runtime.getRuntime().addShutdownHook(unexpectedExitHook);

int failures = 0;
int failures = 1;
try {
Collection<Spec> parsedTests = new SpecParser(tests).parse();
if (useExperimentalRunner) {
Expand All @@ -458,17 +458,17 @@ void run(Collection<String> tests) {
failures = runLegacy(parsedTests, core);
}
} catch (SpecException e) {
failures = 1;
swappableErr.getOriginal().println("Error parsing specs: " + e.getMessage());
} catch (InitializationError e) {
failures = 1;
swappableErr.getOriginal().println("Error initializing JUnit: " + e.getMessage());
} finally {
// If we're exiting via a thrown exception, we'll get a better message by letting it
// propagate than by halt()ing.
Runtime.getRuntime().removeShutdownHook(unexpectedExitHook);
}
exit(failures);

// We used to exit(failures) but it turns out System.exit(256) == System.exit(0)
exit(failures == 0 ? 0 : 1);
}

/**
Expand Down

0 comments on commit 1105c28

Please sign in to comment.