mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add fail-fast to config
This commit is contained in:
parent
fe81586527
commit
9e63c20df2
4 changed files with 24 additions and 1 deletions
|
@ -2,7 +2,9 @@ require "./spec_helper"
|
||||||
|
|
||||||
# Creates a `Config` for Spectator that is suited for testing it.
|
# Creates a `Config` for Spectator that is suited for testing it.
|
||||||
def spectator_test_config(formatter : Spectator::Formatting::Formatter? = nil)
|
def spectator_test_config(formatter : Spectator::Formatting::Formatter? = nil)
|
||||||
Spectator::Config.new(formatter || Spectator::Formatting::SilentFormatter.new)
|
builder = Spectator::ConfigBuilder.new
|
||||||
|
builder.formatter = formatter || Spectator::Formatting::SilentFormatter.new
|
||||||
|
builder.build
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_test_suite
|
def new_test_suite
|
||||||
|
|
|
@ -14,6 +14,7 @@ module Spectator
|
||||||
def apply_to(builder : ConfigBuilder) : Nil
|
def apply_to(builder : ConfigBuilder) : Nil
|
||||||
OptionParser.parse(@args) do |parser|
|
OptionParser.parse(@args) do |parser|
|
||||||
parser.on("-v", "--verbose", "Verbose output using document formatter") { builder.formatter = Formatting::DocumentFormatter.new }
|
parser.on("-v", "--verbose", "Verbose output using document formatter") { builder.formatter = Formatting::DocumentFormatter.new }
|
||||||
|
parser.on("-f", "--fail-fast", "Stop testing on first failure") { builder.fail_fast }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,9 +4,13 @@ module Spectator
|
||||||
# Used to report test progress and results.
|
# Used to report test progress and results.
|
||||||
getter formatter : Formatting::Formatter
|
getter formatter : Formatting::Formatter
|
||||||
|
|
||||||
|
# Indicates whether the test should abort on first failure.
|
||||||
|
getter? fail_fast : Bool
|
||||||
|
|
||||||
# Creates a new configuration.
|
# Creates a new configuration.
|
||||||
def initialize(builder)
|
def initialize(builder)
|
||||||
@formatter = builder.formatter
|
@formatter = builder.formatter
|
||||||
|
@fail_fast = builder.fail_fast?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
@formatter : Formatting::Formatter? = nil
|
@formatter : Formatting::Formatter? = nil
|
||||||
|
@fail_fast = false
|
||||||
|
|
||||||
# Sets the formatter to use for reporting test progress and results.
|
# Sets the formatter to use for reporting test progress and results.
|
||||||
def formatter=(formatter : Formatting::Formatter)
|
def formatter=(formatter : Formatting::Formatter)
|
||||||
|
@ -28,6 +29,21 @@ module Spectator
|
||||||
Formatting::DotsFormatter.new
|
Formatting::DotsFormatter.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Enables fail-fast mode.
|
||||||
|
def fail_fast
|
||||||
|
self.fail_fast = true
|
||||||
|
end
|
||||||
|
|
||||||
|
# Sets the fail-fast flag.
|
||||||
|
def fail_fast=(flag)
|
||||||
|
@fail_fast = flag
|
||||||
|
end
|
||||||
|
|
||||||
|
# Indicates whether fail-fast mode is enabled.
|
||||||
|
def fail_fast?
|
||||||
|
@fail_fast
|
||||||
|
end
|
||||||
|
|
||||||
# Creates a configuration.
|
# Creates a configuration.
|
||||||
def build : Config
|
def build : Config
|
||||||
Config.new(self)
|
Config.new(self)
|
||||||
|
|
Loading…
Reference in a new issue