Return 1 on failure

This commit is contained in:
Michael Miller 2019-02-22 16:54:36 -07:00
parent 487726ea54
commit 87ca825845
2 changed files with 9 additions and 3 deletions

View File

@ -69,7 +69,9 @@ module Spectator
# Crystal doesn't display much information about what happened.
# That issue is handled by putting a begin/rescue block to show a custom error message.
at_exit do
run if autorun?
# Run only if `#autorun?` is true.
# Return 1 on failure.
exit(1) if autorun? && !run
end
@@config_builder = ConfigBuilder.new
@ -94,7 +96,7 @@ module Spectator
# it's likely the fault of the test framework (Spectator).
# So we display a helpful error that could be reported and return non-zero.
display_error_stack(ex)
exit(1)
false
end
# Processes and builds up a configuration to use for running tests.

View File

@ -9,7 +9,9 @@ module Spectator
# Runs the test suite.
# This will run the selected examples
# and invoke the formatter to output results.
def run : Nil
# True will be returned if the test suite ran successfully,
# or false if there was at least one failure.
def run : Bool
# Indicate the suite is starting.
@config.formatter.start_suite(@suite)
@ -24,6 +26,8 @@ module Spectator
# Generate a report and pass it along to the formatter.
report = Report.new(results, elapsed)
@config.formatter.end_suite(report)
!report.failed?
end
# Runs a single example and returns the result.