mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Extend self in Spectator module
This commit is contained in:
parent
5481c3d431
commit
ca92fbb29f
1 changed files with 8 additions and 6 deletions
|
@ -2,6 +2,8 @@ require "./spectator/includes"
|
||||||
|
|
||||||
# Module that contains all functionality related to Spectator.
|
# Module that contains all functionality related to Spectator.
|
||||||
module Spectator
|
module Spectator
|
||||||
|
extend self
|
||||||
|
|
||||||
# Current version of the Spectator library.
|
# Current version of the Spectator library.
|
||||||
VERSION = "0.1.0"
|
VERSION = "0.1.0"
|
||||||
|
|
||||||
|
@ -85,7 +87,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds the tests and runs the framework.
|
# Builds the tests and runs the framework.
|
||||||
private def self.run
|
private def run
|
||||||
# Build the test suite and run it.
|
# Build the test suite and run it.
|
||||||
suite = ::Spectator::DSL::Builder.build
|
suite = ::Spectator::DSL::Builder.build
|
||||||
Runner.new(suite, config).run
|
Runner.new(suite, config).run
|
||||||
|
@ -100,7 +102,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Processes and builds up a configuration to use for running tests.
|
# Processes and builds up a configuration to use for running tests.
|
||||||
private def self.config
|
private def config
|
||||||
# Build up the configuration from various sources.
|
# Build up the configuration from various sources.
|
||||||
# The sources that take priority are later in the list.
|
# The sources that take priority are later in the list.
|
||||||
apply_config_file
|
apply_config_file
|
||||||
|
@ -120,21 +122,21 @@ module Spectator
|
||||||
# one argument per line.
|
# one argument per line.
|
||||||
# The arguments are identical to those
|
# The arguments are identical to those
|
||||||
# that would be passed on the command-line.
|
# that would be passed on the command-line.
|
||||||
private def self.apply_config_file(file_path = CONFIG_FILE_PATH) : Nil
|
private def apply_config_file(file_path = CONFIG_FILE_PATH) : Nil
|
||||||
return unless File.exists?(file_path)
|
return unless File.exists?(file_path)
|
||||||
args = File.read(file_path).lines
|
args = File.read(file_path).lines
|
||||||
CommandLineArgumentsConfigSource.new(args).apply_to(@@config_builder)
|
CommandLineArgumentsConfigSource.new(args).apply_to(@@config_builder)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Applies configuration options from the command-line arguments
|
# Applies configuration options from the command-line arguments
|
||||||
private def self.apply_command_line_args : Nil
|
private def apply_command_line_args : Nil
|
||||||
CommandLineArgumentsConfigSource.new.apply_to(@@config_builder)
|
CommandLineArgumentsConfigSource.new.apply_to(@@config_builder)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Displays a complete error stack.
|
# Displays a complete error stack.
|
||||||
# Prints an error and everything that caused it.
|
# Prints an error and everything that caused it.
|
||||||
# Stacktrace is included.
|
# Stacktrace is included.
|
||||||
private def self.display_error_stack(error) : Nil
|
private def display_error_stack(error) : Nil
|
||||||
puts
|
puts
|
||||||
puts "Encountered an unexpected error in framework"
|
puts "Encountered an unexpected error in framework"
|
||||||
# Loop while there's a cause for the error.
|
# Loop while there's a cause for the error.
|
||||||
|
@ -147,7 +149,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Display a single error and its stacktrace.
|
# Display a single error and its stacktrace.
|
||||||
private def self.display_error(error) : Nil
|
private def display_error(error) : Nil
|
||||||
puts
|
puts
|
||||||
puts "Caused by: #{error.message}"
|
puts "Caused by: #{error.message}"
|
||||||
puts error.backtrace.join("\n")
|
puts error.backtrace.join("\n")
|
||||||
|
|
Loading…
Reference in a new issue