Skip to content

Commit

Permalink
Use hardcoded command
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexB52 committed Nov 23, 2024
1 parent b0d7906 commit 4c951af
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
8 changes: 7 additions & 1 deletion lib/retest/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/retest/runners/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lib/retest/runners/test_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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('<test>', cached_test_file)
Expand Down
14 changes: 14 additions & 0 deletions test/retest/program_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions test/retest/runners/test_runner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 <test>'")
end
Expand Down

0 comments on commit 4c951af

Please sign in to comment.