mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Change formatters to take nillable profile
This commit is contained in:
parent
6dd4c4bc2f
commit
aabc25ad4f
8 changed files with 25 additions and 19 deletions
|
@ -28,7 +28,7 @@ class SpyFormatter < Spectator::Formatting::Formatter
|
|||
|
||||
# Stores all invocatiosn made to `#end_suite`.
|
||||
# Each element is an invocation and the value is the arguments passed to the method.
|
||||
getter end_suite_calls = [] of NamedTuple(report: Spectator::Report, profile: Bool)
|
||||
getter end_suite_calls = [] of NamedTuple(report: Spectator::Report, profile: Spectator::Profile?)
|
||||
|
||||
# Number of times the `#end_suite` method was called.
|
||||
def end_suite_call_count
|
||||
|
|
|
@ -14,8 +14,8 @@ module Spectator::Formatting
|
|||
|
||||
# Called when a test suite finishes.
|
||||
# The results from the entire suite are provided.
|
||||
# The *profile* flag is set to true when profiling results should be generated.
|
||||
abstract def end_suite(report : Report, profile : Bool)
|
||||
# The *profile* value is not nil when profiling results should be displayed.
|
||||
abstract def end_suite(report : Report, profile : Profile?)
|
||||
|
||||
# Called before a test starts.
|
||||
abstract def start_example(example : Example)
|
||||
|
|
|
@ -20,12 +20,12 @@ module Spectator::Formatting
|
|||
|
||||
# Called when a test suite finishes.
|
||||
# The results from the entire suite are provided.
|
||||
# The *profile* flag is set to true when profiling results should be generated.
|
||||
def end_suite(report : Report, profile : Bool)
|
||||
# The *profile* value is not nil when profiling results should be displayed.
|
||||
def end_suite(report : Report, profile : Profile?)
|
||||
@json.end_array # examples
|
||||
totals(report)
|
||||
timing(report)
|
||||
profile(report) if profile
|
||||
profile(profile) if profile
|
||||
@json.field("result", report.failed? ? "fail" : "success")
|
||||
@json.end_object
|
||||
end
|
||||
|
@ -66,7 +66,7 @@ module Spectator::Formatting
|
|||
end
|
||||
|
||||
# Adds the profile information to the document.
|
||||
private def profile(report)
|
||||
private def profile(profile)
|
||||
raise NotImplementedError.new("profile")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,8 +24,8 @@ module Spectator::Formatting
|
|||
|
||||
# Called when a test suite finishes.
|
||||
# The results from the entire suite are provided.
|
||||
# The *profile* flag does nothing for this formatter.
|
||||
def end_suite(report : Report, profile : Bool)
|
||||
# The *profile* value does nothing for this formatter.
|
||||
def end_suite(report : Report, profile : Profile?)
|
||||
test_suites_block(report)
|
||||
@xml.end_document
|
||||
@xml.flush
|
||||
|
|
|
@ -9,7 +9,7 @@ module Spectator::Formatting
|
|||
|
||||
# Called when a test suite finishes.
|
||||
# The results from the entire suite are provided.
|
||||
def end_suite(report : Report, profile : Bool)
|
||||
def end_suite(report : Report, profile : Profile?)
|
||||
# ... crickets ...
|
||||
end
|
||||
|
||||
|
|
|
@ -9,14 +9,14 @@ module Spectator::Formatting
|
|||
# Produces the summary of test suite from a report.
|
||||
# A block describing each failure is displayed.
|
||||
# At the end, the totals and runtime are printed.
|
||||
# The *profile* flag is set to true when profiling results should be generated.
|
||||
def end_suite(report, profile : Bool)
|
||||
# The *profile* value is not nil when profiling results should be displayed.
|
||||
def end_suite(report, profile : Profile?)
|
||||
if report.example_count > 0
|
||||
@io.puts if is_a?(DotsFormatter)
|
||||
@io.puts
|
||||
end
|
||||
failures(report.failures) if report.failed_count > 0
|
||||
profile(report) if profile
|
||||
profile(profile) if profile
|
||||
stats(report)
|
||||
remaining(report) if report.remaining?
|
||||
if report.failed?
|
||||
|
@ -39,7 +39,7 @@ module Spectator::Formatting
|
|||
end
|
||||
|
||||
# Produces the profiling section of the summary.
|
||||
private def profile(report)
|
||||
private def profile(profile)
|
||||
raise NotImplementedError.new("profile")
|
||||
end
|
||||
|
||||
|
|
|
@ -16,9 +16,10 @@ module Spectator::Formatting
|
|||
|
||||
# Called when a test suite finishes.
|
||||
# The results from the entire suite are provided.
|
||||
def end_suite(report : Report, profile : Bool)
|
||||
# The *profile* value is not nil when profiling results should be displayed.
|
||||
def end_suite(report : Report, profile : Profile?)
|
||||
@io.puts "Bail out!" if report.remaining?
|
||||
profile(report) if profile
|
||||
profile(profile) if profile
|
||||
end
|
||||
|
||||
# Called before a test starts.
|
||||
|
@ -32,8 +33,8 @@ module Spectator::Formatting
|
|||
@index += 1
|
||||
end
|
||||
|
||||
# Generates profiling information for the report.
|
||||
private def profile(report)
|
||||
# Displays profiling information.
|
||||
private def profile(profile)
|
||||
raise NotImplementedError.new("profile")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ module Spectator
|
|||
# Generate a report and pass it along to the formatter.
|
||||
remaining = @suite.size - results.size
|
||||
report = Report.new(results, elapsed, remaining, @config.fail_blank?)
|
||||
@config.each_formatter(&.end_suite(report, @config.profile?))
|
||||
@config.each_formatter(&.end_suite(report, profile(report)))
|
||||
|
||||
!report.failed?
|
||||
end
|
||||
|
@ -66,5 +66,10 @@ module Spectator
|
|||
example_expectations = Expectations::ExampleExpectations.new(expectations)
|
||||
SuccessfulResult.new(example, Time::Span.zero, example_expectations)
|
||||
end
|
||||
|
||||
# Generates and returns a profile if one should be displayed.
|
||||
private def profile(report)
|
||||
Profile.generate(report) if @config.profile?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue