class Assert::AssertRunner
Constants
- LOCAL_SETTINGS_FILE
- USER_SETTINGS_FILE
Attributes
config[R]
Public Class Methods
new(config, test_paths, test_options)
click to toggle source
# File lib/assert/assert_runner.rb, line 12 def initialize(config, test_paths, test_options) @config = config Assert::CLI.bench("Applying settings") do apply_user_settings apply_local_settings apply_env_settings apply_option_settings(test_options) end paths = test_paths.empty? ? [*self.config.test_dir] : test_paths files = lookup_test_files(paths) init(files, path_of(self.config.test_dir, files.first)) end
Public Instance Methods
init(test_files, test_dir)
click to toggle source
# File lib/assert/assert_runner.rb, line 26 def init(test_files, test_dir) # load any test helper file if ( test_dir && (h = File.join(test_dir, config.test_helper)) && File.exist?(h) ) Assert::CLI.bench("Requiring test helper"){ require h } end if config.list $stdout.puts test_files halt end # load the test files runner, suite, view = config.runner, config.suite, config.view runner.before_load(test_files) suite.before_load(test_files) view.before_load(test_files) Assert::CLI.bench("Requiring #{test_files.size} test files") do test_files.each{ |p| require p } end if config.debug puts Assert::CLI.debug_msg("Test files:") test_files.each{ |f| puts Assert::CLI.debug_msg(" #{f}") } end runner.after_load suite.after_load view.after_load end
run()
click to toggle source
# File lib/assert/assert_runner.rb, line 59 def run config.runner.run end
Private Instance Methods
apply_env_settings()
click to toggle source
# File lib/assert/assert_runner.rb, line 80 def apply_env_settings if ENV["ASSERT_RUNNER_SEED"] config.runner_seed ENV["ASSERT_RUNNER_SEED"].to_i end end
apply_local_settings()
click to toggle source
# File lib/assert/assert_runner.rb, line 73 def apply_local_settings safe_require( ENV["ASSERT_LOCALFILE"] || path_of(LOCAL_SETTINGS_FILE, Dir.pwd), ) end
apply_option_settings(options)
click to toggle source
# File lib/assert/assert_runner.rb, line 86 def apply_option_settings(options) config.apply(options) end
apply_user_settings()
click to toggle source
# File lib/assert/assert_runner.rb, line 69 def apply_user_settings safe_require("#{ENV["HOME"]}/#{USER_SETTINGS_FILE}") if ENV["HOME"] end
changed_test_files(test_paths)
click to toggle source
# File lib/assert/assert_runner.rb, line 103 def changed_test_files(test_paths) globbed_test_files(config.changed_proc.call(config, test_paths)) end
globbed_test_files(test_paths)
click to toggle source
# File lib/assert/assert_runner.rb, line 107 def globbed_test_files(test_paths) test_paths.reduce(Set.new) do |paths, path| p = File.expand_path(path, Dir.pwd) paths + Dir.glob("#{p}*") + Dir.glob("#{p}*/**/*") end end
halt()
click to toggle source
# File lib/assert/assert_runner.rb, line 65 def halt throw(:halt) end
is_test_file?(path)
click to toggle source
# File lib/assert/assert_runner.rb, line 114 def is_test_file?(path) config.test_file_suffixes.reduce(false) do |result, suffix| result || path =~ /#{suffix}$/ end end
lookup_test_files(test_paths)
click to toggle source
# File lib/assert/assert_runner.rb, line 90 def lookup_test_files(test_paths) file_paths = if config.changed_only changed_test_files(test_paths) elsif config.single_test? globbed_test_files([config.single_test_file_path]) else globbed_test_files(test_paths) end file_paths.select{ |p| is_test_file?(p) }.sort end
path_of(segment, a_path)
click to toggle source
# File lib/assert/assert_runner.rb, line 124 def path_of(segment, a_path) # this method inspects a test path and finds the test dir path. full_path = File.expand_path(a_path || ".", Dir.pwd) seg_pos = full_path.index(segment_regex(segment)) File.join( if seg_pos && (seg_pos > 0) full_path[0..(seg_pos - 1)] else full_path end, segment, ) end
safe_require(settings_file)
click to toggle source
# File lib/assert/assert_runner.rb, line 120 def safe_require(settings_file) require settings_file if File.exist?(settings_file) end
segment_regex(seg)
click to toggle source
# File lib/assert/assert_runner.rb, line 138 def segment_regex(seg) %r{^#{seg}$|^#{seg}/|/#{seg}/|/#{seg}$} end