mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Integrate report and summary events
This commit is contained in:
parent
ceb368a7f4
commit
0ed684afbc
4 changed files with 37 additions and 11 deletions
|
@ -96,17 +96,20 @@ module Spectator::Formatting
|
||||||
# Invoked after testing completes with a list of pending examples.
|
# Invoked after testing completes with a list of pending examples.
|
||||||
# This method will be called with an empty list if there were no pending (skipped) examples.
|
# This method will be called with an empty list if there were no pending (skipped) examples.
|
||||||
# Called after `#start_dump` and before `#dump_failures`.
|
# Called after `#start_dump` and before `#dump_failures`.
|
||||||
|
# The *notification* will be an `ExampleSummaryNotification` type of object.
|
||||||
def dump_pending(_notification)
|
def dump_pending(_notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Invoked after testing completes with a list of failed examples.
|
# Invoked after testing completes with a list of failed examples.
|
||||||
# This method will be called with an empty list if there were no failures.
|
# This method will be called with an empty list if there were no failures.
|
||||||
# Called after `#dump_pending` and before `#dump_summary`.
|
# Called after `#dump_pending` and before `#dump_summary`.
|
||||||
|
# The *notification* will be an `ExampleSummaryNotification` type of object.
|
||||||
def dump_failures(_notification)
|
def dump_failures(_notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Invoked after testing completes with summarized information from the test suite.
|
# Invoked after testing completes with summarized information from the test suite.
|
||||||
# Called after `#dump_failures` and before `#dump_profile`.
|
# Called after `#dump_failures` and before `#dump_profile`.
|
||||||
|
# The *notification* will be an `SummaryNotification` type of object.
|
||||||
def dump_summary(_notification)
|
def dump_summary(_notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
require "../example"
|
require "../example"
|
||||||
|
|
||||||
module Spectator::Formatting
|
module Spectator::Formatting
|
||||||
|
# Structure indicating the test suite has started.
|
||||||
record StartNotification, example_count : Int32
|
record StartNotification, example_count : Int32
|
||||||
|
|
||||||
|
# Structure indicating an event occurred with an example.
|
||||||
record ExampleNotification, example : Example
|
record ExampleNotification, example : Example
|
||||||
|
|
||||||
|
# Structure containing a subset of examples from the test suite.
|
||||||
|
record ExampleSummaryNotification, examples : Enumerable(Example)
|
||||||
|
|
||||||
|
# Structure containing summarized information from the outcome of the test suite.
|
||||||
|
record SummaryNotification, report : Report
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,6 +35,22 @@ module Spectator
|
||||||
formatter.stop(nil)
|
formatter.stop(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Triggers the 'dump' events.
|
||||||
|
private def summarize(report)
|
||||||
|
formatter.start_dump
|
||||||
|
|
||||||
|
notification = Formatting::ExampleSummaryNotification.new(report.pending)
|
||||||
|
formatter.dump_pending(notification)
|
||||||
|
|
||||||
|
notification = Formatting::ExampleSummaryNotification.new(report.failures)
|
||||||
|
formatter.dump_failures(notification)
|
||||||
|
|
||||||
|
notification = Formatting::SummaryNotification.new(report)
|
||||||
|
formatter.dump_summary(notification)
|
||||||
|
|
||||||
|
formatter.dump_profile(nil)
|
||||||
|
end
|
||||||
|
|
||||||
# Triggers the 'close' event.
|
# Triggers the 'close' event.
|
||||||
# See `Formatting::Formatter#close`
|
# See `Formatting::Formatter#close`
|
||||||
private def close
|
private def close
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require "../example"
|
require "../example"
|
||||||
|
require "../report"
|
||||||
require "../run_flags"
|
require "../run_flags"
|
||||||
require "./events"
|
require "./events"
|
||||||
|
|
||||||
|
@ -26,11 +27,11 @@ module Spectator
|
||||||
# or false if there was at least one failure.
|
# or false if there was at least one failure.
|
||||||
def run : Bool
|
def run : Bool
|
||||||
start
|
start
|
||||||
executed = [] of Example
|
elapsed = Time.measure { run_examples }
|
||||||
elapsed = Time.measure { executed = run_examples }
|
|
||||||
stop
|
stop
|
||||||
|
|
||||||
# TODO: Generate a report and pass it along to the formatter.
|
report = Report.generate(@examples, elapsed, nil) # TODO: Provide random seed.
|
||||||
|
summarize(report)
|
||||||
|
|
||||||
false # TODO: Report real result
|
false # TODO: Report real result
|
||||||
|
|
||||||
|
@ -41,15 +42,12 @@ module Spectator
|
||||||
# Attempts to run all examples.
|
# Attempts to run all examples.
|
||||||
# Returns a list of examples that ran.
|
# Returns a list of examples that ran.
|
||||||
private def run_examples
|
private def run_examples
|
||||||
Array(Example).new(example_count).tap do |executed|
|
@examples.each do |example|
|
||||||
@examples.each do |example|
|
result = run_example(example)
|
||||||
result = run_example(example)
|
|
||||||
executed << example
|
|
||||||
|
|
||||||
# Bail out if the example failed
|
# Bail out if the example failed
|
||||||
# and configured to stop after the first failure.
|
# and configured to stop after the first failure.
|
||||||
break fail_fast if fail_fast? && result.fail?
|
break fail_fast if fail_fast? && result.fail?
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,6 +56,7 @@ module Spectator
|
||||||
private def run_example(example)
|
private def run_example(example)
|
||||||
example_started(example)
|
example_started(example)
|
||||||
result = if dry_run?
|
result = if dry_run?
|
||||||
|
# TODO: Pending examples return a pending result instead of pass in RSpec dry-run.
|
||||||
dry_run_result
|
dry_run_result
|
||||||
else
|
else
|
||||||
example.run
|
example.run
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue