diff --git a/lib/retest/runners.rb b/lib/retest/runners.rb index 14cefc71..d3538cc8 100644 --- a/lib/retest/runners.rb +++ b/lib/retest/runners.rb @@ -5,6 +5,8 @@ module Retest module Runners + class NotSupportedError < StandardError; end + module_function def runner_for(command) diff --git a/lib/retest/runners/runner.rb b/lib/retest/runners/runner.rb index 6dfb4b55..8e1353f0 100644 --- a/lib/retest/runners/runner.rb +++ b/lib/retest/runners/runner.rb @@ -18,8 +18,7 @@ def run(changed_file = nil, repository: nil) end def run_all_tests(tests_string) - log("Test File Selected: #{tests_string}") - system_run command.gsub('', tests_string) + raise NotSupportedError, 'cannot run multiple test files against this command' end def sync(added:, removed:) diff --git a/lib/retest/runners/test_runner.rb b/lib/retest/runners/test_runner.rb index 03283c71..29ee0773 100644 --- a/lib/retest/runners/test_runner.rb +++ b/lib/retest/runners/test_runner.rb @@ -14,6 +14,11 @@ def run(changed_file, repository:) system_run command.gsub('', cached_test_file) end + def run_all_tests(tests_string) + log("Test File Selected: #{tests_string}") + system_run command.gsub('', tests_string) + end + def sync(added:, removed:) purge_test_file(removed) end diff --git a/test/retest/runners/change_runner_test.rb b/test/retest/runners/change_runner_test.rb index b6105ae2..1db4e82c 100644 --- a/test/retest/runners/change_runner_test.rb +++ b/test/retest/runners/change_runner_test.rb @@ -42,6 +42,10 @@ def test_run_with_a_file_found assert_match "touch file_path.rb", out end + + def test_run_all_tests + assert_raises(NotSupportedError) { @subject.run_all_tests('file_path.rb file_path_two.rb') } + end end end end \ No newline at end of file diff --git a/test/retest/runners/runner_test.rb b/test/retest/runners/runner_test.rb index 64b36378..ead003ff 100644 --- a/test/retest/runners/runner_test.rb +++ b/test/retest/runners/runner_test.rb @@ -35,17 +35,7 @@ def test_run end def test_run_all_tests - runner = Runner.new("echo ''", stdout: StringIO.new) - - out, _ = capture_subprocess_io { runner.run_all_tests('file_path.rb file_path_two.rb') } - - assert_equal(<<~EXPECATIONS, runner.stdout.string) - Test File Selected: file_path.rb file_path_two.rb - EXPECATIONS - - assert_equal(<<~EXPECATIONS, out) - file_path.rb file_path_two.rb - EXPECATIONS + assert_raises(NotSupportedError) { @subject.run_all_tests('file_path.rb file_path_two.rb') } end end end diff --git a/test/retest/runners/test_runner_test.rb b/test/retest/runners/test_runner_test.rb index e73341c6..c2bb8849 100644 --- a/test/retest/runners/test_runner_test.rb +++ b/test/retest/runners/test_runner_test.rb @@ -74,6 +74,18 @@ def test_sync_files @subject.sync(added: 'a.rb', removed:'file_path_test.rb') assert_nil @subject.cached_test_file end + + def test_run_all_tests + out, _ = capture_subprocess_io { @subject.run_all_tests('file_path.rb file_path_two.rb') } + + assert_equal(<<~EXPECATIONS, @subject.stdout.string) + Test File Selected: file_path.rb file_path_two.rb + EXPECATIONS + + assert_equal(<<~EXPECATIONS, out) + touch file_path.rb file_path_two.rb + EXPECATIONS + end end end end \ No newline at end of file diff --git a/test/retest/runners/variable_runner_test.rb b/test/retest/runners/variable_runner_test.rb index 01c2fcde..bf766fda 100644 --- a/test/retest/runners/variable_runner_test.rb +++ b/test/retest/runners/variable_runner_test.rb @@ -85,6 +85,10 @@ def test_sync_files @subject.sync(added: 'a.rb', removed:'file_path_test.rb') assert_nil @subject.cached_test_file end + + def test_run_all_tests + assert_raises(NotSupportedError) { @subject.run_all_tests('file_path.rb file_path_two.rb') } + end end end end \ No newline at end of file