Skip to content

Commit

Permalink
fix stdin inputs on diff
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexB52 committed Oct 20, 2024
1 parent acd696b commit fcb0ca9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
10 changes: 6 additions & 4 deletions exe/retest
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ runner = Retest::Runners.runner_for(command.to_s, command_stdin: runner_rd)
sounds = Retest::Sounds.for(options)

# All test runner
all_test_runner = Retest::Runners.runner_for(
Retest::Command.for_options(options.dup.tap { |opts| opts.params[:all] = true }).to_s)
all_test_command = Retest::Command.for_options(options.merge(%w[--all]))
all_test_runner = Retest::Runners.runner_for(all_test_command.to_s)
all_test_runner.add_observer(sounds)

sounds.play(:start)
Expand All @@ -47,6 +47,8 @@ program = Retest::Program.new(
)

if options.params[:diff]
prompt.input = $stdin
runner.command_stdin = $stdin
program.diff(options.params[:diff])
return
end
Expand Down Expand Up @@ -85,8 +87,8 @@ loop do

puts "input is: #{input.inspect}"

if runner.running?
runner_wr.puts input
if prompt.question_asked?
prompt_wr.puts input
next
end

Expand Down
4 changes: 4 additions & 0 deletions lib/retest/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,9 @@ def force_polling?
def extension
Regexp.new(params[:ext])
end

def merge(options = [])
self.class.new(@args.dup.concat(options))
end
end
end
9 changes: 9 additions & 0 deletions test/retest/options_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,14 @@ def test_notify?
@subject.args = ["--notify"]
assert @subject.notify?
end

def test_all_version_copy
@subject.args = %w[--notify --rake]

copy = @subject.merge(%w[--all])

assert_equal %w[--notify --rake --all], copy.args
refute_equal copy.object_id, @subject.object_id
end
end
end

0 comments on commit fcb0ca9

Please sign in to comment.