mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Pass along and output random seed
This commit is contained in:
parent
36f9f2b434
commit
1525317e2c
3 changed files with 12 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
require "colorize"
|
||||||
require "./runtime"
|
require "./runtime"
|
||||||
require "./totals"
|
require "./totals"
|
||||||
|
|
||||||
|
@ -10,6 +11,9 @@ module Spectator::Formatting::Components
|
||||||
def to_s(io)
|
def to_s(io)
|
||||||
runtime(io)
|
runtime(io)
|
||||||
totals(io)
|
totals(io)
|
||||||
|
if seed = @report.random_seed?
|
||||||
|
random(io, seed)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private def runtime(io)
|
private def runtime(io)
|
||||||
|
@ -20,5 +24,9 @@ module Spectator::Formatting::Components
|
||||||
private def totals(io)
|
private def totals(io)
|
||||||
io.puts Totals.colorize(@report.counts)
|
io.puts Totals.colorize(@report.counts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private def random(io, seed)
|
||||||
|
io.puts "Randomized with seed: #{seed}".colorize(:cyan)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Spectator
|
||||||
# True will be returned if the spec ran successfully,
|
# True will be returned if the spec ran successfully,
|
||||||
# or false if there was at least one failure.
|
# or false if there was at least one failure.
|
||||||
def run : Bool
|
def run : Bool
|
||||||
runner = Runner.new(examples, @config.formatter, @config.run_flags)
|
runner = Runner.new(examples, @config.formatter, @config.run_flags, @config.random_seed)
|
||||||
runner.run
|
runner.run
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@ module Spectator
|
||||||
# The collection of *examples* should be pre-filtered and shuffled.
|
# The collection of *examples* should be pre-filtered and shuffled.
|
||||||
# This runner will run each example in the order provided.
|
# This runner will run each example in the order provided.
|
||||||
# The *formatter* will be called for various events.
|
# The *formatter* will be called for various events.
|
||||||
def initialize(@examples : Array(Example),
|
def initialize(@examples : Array(Example), @formatter : Formatting::Formatter,
|
||||||
@formatter : Formatting::Formatter, @run_flags = RunFlags::None)
|
@run_flags = RunFlags::None, @random_seed : UInt64? = nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Runs the spec.
|
# Runs the spec.
|
||||||
|
@ -30,7 +30,7 @@ module Spectator
|
||||||
elapsed = Time.measure { run_examples }
|
elapsed = Time.measure { run_examples }
|
||||||
stop
|
stop
|
||||||
|
|
||||||
report = Report.generate(@examples, elapsed, nil) # TODO: Provide random seed.
|
report = Report.generate(@examples, elapsed, @random_seed)
|
||||||
profile = Profile.generate(@examples) if @run_flags.profile? && report.counts.run > 0
|
profile = Profile.generate(@examples) if @run_flags.profile? && report.counts.run > 0
|
||||||
summarize(report, profile)
|
summarize(report, profile)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue