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`.
|
# Stores all invocatiosn made to `#end_suite`.
|
||||||
# Each element is an invocation and the value is the arguments passed to the method.
|
# 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.
|
# Number of times the `#end_suite` method was called.
|
||||||
def end_suite_call_count
|
def end_suite_call_count
|
||||||
|
|
|
@ -14,8 +14,8 @@ module Spectator::Formatting
|
||||||
|
|
||||||
# Called when a test suite finishes.
|
# Called when a test suite finishes.
|
||||||
# The results from the entire suite are provided.
|
# The results from the entire suite are provided.
|
||||||
# The *profile* flag is set to true when profiling results should be generated.
|
# The *profile* value is not nil when profiling results should be displayed.
|
||||||
abstract def end_suite(report : Report, profile : Bool)
|
abstract def end_suite(report : Report, profile : Profile?)
|
||||||
|
|
||||||
# Called before a test starts.
|
# Called before a test starts.
|
||||||
abstract def start_example(example : Example)
|
abstract def start_example(example : Example)
|
||||||
|
|
|
@ -20,12 +20,12 @@ module Spectator::Formatting
|
||||||
|
|
||||||
# Called when a test suite finishes.
|
# Called when a test suite finishes.
|
||||||
# The results from the entire suite are provided.
|
# The results from the entire suite are provided.
|
||||||
# The *profile* flag is set to true when profiling results should be generated.
|
# The *profile* value is not nil when profiling results should be displayed.
|
||||||
def end_suite(report : Report, profile : Bool)
|
def end_suite(report : Report, profile : Profile?)
|
||||||
@json.end_array # examples
|
@json.end_array # examples
|
||||||
totals(report)
|
totals(report)
|
||||||
timing(report)
|
timing(report)
|
||||||
profile(report) if profile
|
profile(profile) if profile
|
||||||
@json.field("result", report.failed? ? "fail" : "success")
|
@json.field("result", report.failed? ? "fail" : "success")
|
||||||
@json.end_object
|
@json.end_object
|
||||||
end
|
end
|
||||||
|
@ -66,7 +66,7 @@ module Spectator::Formatting
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds the profile information to the document.
|
# Adds the profile information to the document.
|
||||||
private def profile(report)
|
private def profile(profile)
|
||||||
raise NotImplementedError.new("profile")
|
raise NotImplementedError.new("profile")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,8 +24,8 @@ module Spectator::Formatting
|
||||||
|
|
||||||
# Called when a test suite finishes.
|
# Called when a test suite finishes.
|
||||||
# The results from the entire suite are provided.
|
# The results from the entire suite are provided.
|
||||||
# The *profile* flag does nothing for this formatter.
|
# The *profile* value does nothing for this formatter.
|
||||||
def end_suite(report : Report, profile : Bool)
|
def end_suite(report : Report, profile : Profile?)
|
||||||
test_suites_block(report)
|
test_suites_block(report)
|
||||||
@xml.end_document
|
@xml.end_document
|
||||||
@xml.flush
|
@xml.flush
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Spectator::Formatting
|
||||||
|
|
||||||
# Called when a test suite finishes.
|
# Called when a test suite finishes.
|
||||||
# The results from the entire suite are provided.
|
# The results from the entire suite are provided.
|
||||||
def end_suite(report : Report, profile : Bool)
|
def end_suite(report : Report, profile : Profile?)
|
||||||
# ... crickets ...
|
# ... crickets ...
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,14 @@ module Spectator::Formatting
|
||||||
# Produces the summary of test suite from a report.
|
# Produces the summary of test suite from a report.
|
||||||
# A block describing each failure is displayed.
|
# A block describing each failure is displayed.
|
||||||
# At the end, the totals and runtime are printed.
|
# At the end, the totals and runtime are printed.
|
||||||
# The *profile* flag is set to true when profiling results should be generated.
|
# The *profile* value is not nil when profiling results should be displayed.
|
||||||
def end_suite(report, profile : Bool)
|
def end_suite(report, profile : Profile?)
|
||||||
if report.example_count > 0
|
if report.example_count > 0
|
||||||
@io.puts if is_a?(DotsFormatter)
|
@io.puts if is_a?(DotsFormatter)
|
||||||
@io.puts
|
@io.puts
|
||||||
end
|
end
|
||||||
failures(report.failures) if report.failed_count > 0
|
failures(report.failures) if report.failed_count > 0
|
||||||
profile(report) if profile
|
profile(profile) if profile
|
||||||
stats(report)
|
stats(report)
|
||||||
remaining(report) if report.remaining?
|
remaining(report) if report.remaining?
|
||||||
if report.failed?
|
if report.failed?
|
||||||
|
@ -39,7 +39,7 @@ module Spectator::Formatting
|
||||||
end
|
end
|
||||||
|
|
||||||
# Produces the profiling section of the summary.
|
# Produces the profiling section of the summary.
|
||||||
private def profile(report)
|
private def profile(profile)
|
||||||
raise NotImplementedError.new("profile")
|
raise NotImplementedError.new("profile")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,10 @@ module Spectator::Formatting
|
||||||
|
|
||||||
# Called when a test suite finishes.
|
# Called when a test suite finishes.
|
||||||
# The results from the entire suite are provided.
|
# 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?
|
@io.puts "Bail out!" if report.remaining?
|
||||||
profile(report) if profile
|
profile(profile) if profile
|
||||||
end
|
end
|
||||||
|
|
||||||
# Called before a test starts.
|
# Called before a test starts.
|
||||||
|
@ -32,8 +33,8 @@ module Spectator::Formatting
|
||||||
@index += 1
|
@index += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates profiling information for the report.
|
# Displays profiling information.
|
||||||
private def profile(report)
|
private def profile(profile)
|
||||||
raise NotImplementedError.new("profile")
|
raise NotImplementedError.new("profile")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ module Spectator
|
||||||
# Generate a report and pass it along to the formatter.
|
# Generate a report and pass it along to the formatter.
|
||||||
remaining = @suite.size - results.size
|
remaining = @suite.size - results.size
|
||||||
report = Report.new(results, elapsed, remaining, @config.fail_blank?)
|
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?
|
!report.failed?
|
||||||
end
|
end
|
||||||
|
@ -66,5 +66,10 @@ module Spectator
|
||||||
example_expectations = Expectations::ExampleExpectations.new(expectations)
|
example_expectations = Expectations::ExampleExpectations.new(expectations)
|
||||||
SuccessfulResult.new(example, Time::Span.zero, example_expectations)
|
SuccessfulResult.new(example, Time::Span.zero, example_expectations)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Generates and returns a profile if one should be displayed.
|
||||||
|
private def profile(report)
|
||||||
|
Profile.generate(report) if @config.profile?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue