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 "./totals"
|
||||
|
||||
|
@ -10,6 +11,9 @@ module Spectator::Formatting::Components
|
|||
def to_s(io)
|
||||
runtime(io)
|
||||
totals(io)
|
||||
if seed = @report.random_seed?
|
||||
random(io, seed)
|
||||
end
|
||||
end
|
||||
|
||||
private def runtime(io)
|
||||
|
@ -20,5 +24,9 @@ module Spectator::Formatting::Components
|
|||
private def totals(io)
|
||||
io.puts Totals.colorize(@report.counts)
|
||||
end
|
||||
|
||||
private def random(io, seed)
|
||||
io.puts "Randomized with seed: #{seed}".colorize(:cyan)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Spectator
|
|||
# True will be returned if the spec ran successfully,
|
||||
# or false if there was at least one failure.
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ module Spectator
|
|||
# The collection of *examples* should be pre-filtered and shuffled.
|
||||
# This runner will run each example in the order provided.
|
||||
# The *formatter* will be called for various events.
|
||||
def initialize(@examples : Array(Example),
|
||||
@formatter : Formatting::Formatter, @run_flags = RunFlags::None)
|
||||
def initialize(@examples : Array(Example), @formatter : Formatting::Formatter,
|
||||
@run_flags = RunFlags::None, @random_seed : UInt64? = nil)
|
||||
end
|
||||
|
||||
# Runs the spec.
|
||||
|
@ -30,7 +30,7 @@ module Spectator
|
|||
elapsed = Time.measure { run_examples }
|
||||
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
|
||||
summarize(report, profile)
|
||||
|
||||
|
|
Loading…
Reference in a new issue