mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Store random seed
This commit is contained in:
parent
f7d7e2440e
commit
a8e2e5c021
4 changed files with 14 additions and 2 deletions
|
@ -19,6 +19,9 @@ module Spectator
|
|||
# Indicates whether tests are run in a random order.
|
||||
getter? randomize : Bool
|
||||
|
||||
# Random seed used for number generation.
|
||||
getter! random_seed : UInt64?
|
||||
|
||||
# Indicates whether profiling information should be displayed.
|
||||
getter? profile : Bool
|
||||
|
||||
|
@ -33,6 +36,7 @@ module Spectator
|
|||
@dry_run = builder.dry_run?
|
||||
@random = builder.random
|
||||
@randomize = builder.randomize?
|
||||
@random_seed = builder.seed?
|
||||
@profile = builder.profile?
|
||||
@example_filter = builder.example_filter
|
||||
end
|
||||
|
|
|
@ -90,8 +90,12 @@ module Spectator
|
|||
@dry_run
|
||||
end
|
||||
|
||||
# Seed used for random number generation.
|
||||
getter! seed : UInt64?
|
||||
|
||||
# Sets the seed for the random number generator.
|
||||
def seed=(seed)
|
||||
@seed = seed
|
||||
@random = Random.new(seed)
|
||||
end
|
||||
|
||||
|
|
|
@ -25,12 +25,16 @@ module Spectator
|
|||
# This will be greater than zero only in fail-fast mode.
|
||||
getter remaining_count
|
||||
|
||||
# Random seed used to determine test ordering.
|
||||
getter! random_seed : UInt64?
|
||||
|
||||
# Creates the report.
|
||||
# The *results* are from running the examples in the test suite.
|
||||
# The *runtime* is the total time it took to execute the suite.
|
||||
# The *remaining_count* is the number of tests skipped due to fail-fast.
|
||||
# The *fail_blank* flag indicates whether it is a failure if there were no tests run.
|
||||
def initialize(@results : Array(Result), @runtime, @remaining_count = 0, @fail_blank = false)
|
||||
# The *random_seed* is the seed used for random number generation.
|
||||
def initialize(@results : Array(Result), @runtime, @remaining_count = 0, @fail_blank = false, @random_seed = nil)
|
||||
@results.each do |result|
|
||||
case result
|
||||
when SuccessfulResult
|
||||
|
|
|
@ -25,7 +25,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?)
|
||||
report = Report.new(results, elapsed, remaining, @config.fail_blank?, @config.random_seed?)
|
||||
@config.each_formatter(&.end_suite(report, profile(report)))
|
||||
|
||||
!report.failed?
|
||||
|
|
Loading…
Reference in a new issue