diff --git a/lib/retest/command.rb b/lib/retest/command.rb index 375cdb1..a73e4fe 100644 --- a/lib/retest/command.rb +++ b/lib/retest/command.rb @@ -28,7 +28,9 @@ def command end def options_command - return params[:command] if params[:command] + if params[:command] + return hardcoded_command(params[:command]) + end if params[:rspec] then rspec_command elsif params[:rails] then rails_command @@ -59,6 +61,10 @@ def log(message) @stdout&.puts(message) end + def hardcoded_command(command) + Hardcoded.new(command: command) + end + def rspec_command Rspec.new(all: full_suite?) end diff --git a/lib/retest/runners/runner.rb b/lib/retest/runners/runner.rb index 1bfdb8d..d6822dc 100644 --- a/lib/retest/runners/runner.rb +++ b/lib/retest/runners/runner.rb @@ -4,9 +4,10 @@ class Runner include Observable attr_accessor :command, :stdout - def initialize(command, stdout: $stdout) + def initialize(command, stdout: $stdout, command2: nil) @stdout = stdout @command = command + @command2 = command2 end def ==(obj) diff --git a/lib/retest/runners/test_runner.rb b/lib/retest/runners/test_runner.rb index 65e7a6f..0395f70 100644 --- a/lib/retest/runners/test_runner.rb +++ b/lib/retest/runners/test_runner.rb @@ -7,8 +7,9 @@ class TestRunner < Runner def run(changed_file, repository:) self.cached_test_file = repository.find_test(changed_file) - - return print_file_not_found unless cached_test_file + unless cached_test_file + return print_file_not_found + end log("Test File Selected: #{cached_test_file}") system_run command.gsub('', cached_test_file) diff --git a/test/retest/program_test.rb b/test/retest/program_test.rb index 78314bf..f63cf11 100644 --- a/test/retest/program_test.rb +++ b/test/retest/program_test.rb @@ -24,5 +24,19 @@ def test_no_run_when_paused @subject.run('file_path') end end + + class SwitchRunnerTest < MiniTest::Test + def setup + @default_runner = Runners::Runner.new("echo 'default runner'") + @subject = Program.new(runner: @default_runner) + end + + def test_dfs + # @new_runner = + # @program.switch_to(test_files, runner: ) + + # assert_equal @program.runner + end + end end end diff --git a/test/retest/runners/test_runner_test.rb b/test/retest/runners/test_runner_test.rb index 07fd420..992701a 100644 --- a/test/retest/runners/test_runner_test.rb +++ b/test/retest/runners/test_runner_test.rb @@ -6,6 +6,7 @@ module Retest module Runners class TestRunnerInterfaceTests < MiniTest::Test def setup + @command = Command::Rails.new(all: false) @repository = Repository.new(files: ['file_path_test.rb']) @subject = TestRunner.new("echo 'touch '") end