mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Structure for applying configuration
This commit is contained in:
parent
9527427b45
commit
23368f6183
6 changed files with 84 additions and 5 deletions
16
src/spectator/command_line_arguments_config_source.cr
Normal file
16
src/spectator/command_line_arguments_config_source.cr
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Spectator
|
||||
# Generates configuration from the command-line arguments.
|
||||
class CommandLineArgumentsConfigSource < ConfigSource
|
||||
# Creates the configuration source.
|
||||
# By default, the command-line arguments (ARGV) are used.
|
||||
# But custom arguments can be passed in.
|
||||
def initialize(@args : Array(String) = ARGV)
|
||||
end
|
||||
|
||||
# Applies the specified configuration to a builder.
|
||||
# Calling this method from multiple sources builds up the final configuration.
|
||||
def apply_to(builder : ConfigBuilder) : Nil
|
||||
# ...
|
||||
end
|
||||
end
|
||||
end
|
9
src/spectator/config_builder.cr
Normal file
9
src/spectator/config_builder.cr
Normal file
|
@ -0,0 +1,9 @@
|
|||
module Spectator
|
||||
class ConfigBuilder
|
||||
property formatter : Formatters::Formatter = Formatters::DefaultFormatter.new
|
||||
|
||||
def build
|
||||
Config.new
|
||||
end
|
||||
end
|
||||
end
|
8
src/spectator/config_source.cr
Normal file
8
src/spectator/config_source.cr
Normal file
|
@ -0,0 +1,8 @@
|
|||
module Spectator
|
||||
# Interface for all places that configuration can originate.
|
||||
abstract class ConfigSource
|
||||
# Applies the specified configuration to a builder.
|
||||
# Calling this method from multiple sources builds up the final configuration.
|
||||
abstract def apply_to(builder : ConfigBuilder) : Nil
|
||||
end
|
||||
end
|
|
@ -23,9 +23,13 @@ require "./example_group"
|
|||
require "./nested_example_group"
|
||||
require "./root_example_group"
|
||||
|
||||
require "./config"
|
||||
require "./config_builder"
|
||||
require "./config_source"
|
||||
require "./command_line_arguments_config_source"
|
||||
|
||||
require "./example_failed"
|
||||
require "./expectation_failed"
|
||||
require "./config"
|
||||
require "./test_suite"
|
||||
require "./test_suite_results"
|
||||
require "./runner"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module Spectator
|
||||
# Main driver for executing tests and feeding results to formatters.
|
||||
class Runner
|
||||
def initialize(@suite : TestSuite,
|
||||
@formatter : Formatters::Formatter = Formatters::DefaultFormatter.new)
|
||||
def initialize(@suite : TestSuite, config : Config)
|
||||
@formatter = Formatters::DefaultFormatter.new
|
||||
end
|
||||
|
||||
def run : Nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue