lib/assert/assert_runner.rb in assert-2.15.0 vs lib/assert/assert_runner.rb in assert-2.15.1

- old
+ new

@@ -11,15 +11,16 @@ def initialize(config, test_paths, test_options) @config = config Assert::CLI.bench('Apply settings') do apply_user_settings apply_local_settings - apply_option_settings(test_options) apply_env_settings + apply_option_settings(test_options) end - files = test_files(test_paths.empty? ? [*self.config.test_dir] : test_paths) + 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 def init(test_files, test_dir) # load any test helper file @@ -31,19 +32,24 @@ $stdout.puts test_files halt end # load the test files - self.config.view.fire(:before_load, test_files) - Assert::CLI.bench("Require #{test_files.count} test files") do + runner, suite, view = self.config.runner, self.config.suite, self.config.view + runner.before_load(test_files) + suite.before_load(test_files) + view.before_load(test_files) + Assert::CLI.bench("Require #{test_files.size} test files") do test_files.each{ |p| require p } end if self.config.debug puts Assert::CLI.debug_msg("Test files:") test_files.each{ |f| puts Assert::CLI.debug_msg(" #{f}") } end - self.config.view.fire(:after_load) + runner.after_load + suite.after_load + view.after_load end def run self.config.runner.run end @@ -60,21 +66,23 @@ def apply_local_settings safe_require(ENV['ASSERT_LOCALFILE'] || path_of(LOCAL_SETTINGS_FILE, Dir.pwd)) end - def apply_option_settings(options) - self.config.apply(options) - end - def apply_env_settings self.config.runner_seed ENV['ASSERT_RUNNER_SEED'].to_i if ENV['ASSERT_RUNNER_SEED'] end - def test_files(test_paths) + def apply_option_settings(options) + self.config.apply(options) + end + + def lookup_test_files(test_paths) file_paths = if self.config.changed_only changed_test_files(test_paths) + elsif self.config.single_test? + globbed_test_files(self.config.single_test_file_path) else globbed_test_files(test_paths) end file_paths.select{ |p| is_test_file?(p) }.sort @@ -99,12 +107,11 @@ def safe_require(settings_file) require settings_file if File.exists?(settings_file) end - # this method inspects a test path and finds the test dir path. - 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(seg_pos && (seg_pos > 0) ? full_path[0..(seg_pos-1)] : full_path, segment) end