cognitect-labs / test-runner

A test runner for clojure.test
Eclipse Public License 2.0
286 stars 31 forks source link

Return non-zero exit code when tests fail or error #14

Closed mainej closed 6 years ago

mainej commented 6 years ago

Fixes https://github.com/cognitect-labs/test-runner/issues/9. Based on https://github.com/cognitect-labs/test-runner/pull/12, with the following differences:

1) https://stackoverflow.com/questions/65035/does-finally-always-execute-in-java 2) https://stackoverflow.com/questions/1410951/how-does-javas-system-exit-work-with-try-catch-finally-blocks

puredanger commented 6 years ago

Looks good to me but I will leave this to @levand to merge

levand commented 6 years ago

If you call System/exit, I think a finally block will not be called at all.

As such, if we're always calling System/exit explicitly, we don't even need to bother about cleaning up agents. Cleaning up agents is only necessary to allow the JVM to terminate "naturally" after the -main function returns. So I think this can be simplified a bit by taking out the "finally" altogether.

mainej commented 6 years ago

I think the finally block is called, because it is structured to run before the System/exit. But it sounds reasonable that it doesn't need to be called if we're going to System/exit. I'll submit a revision with that change.