Skip to content

Commit fcb0ca9

Browse files
committed
fix stdin inputs on diff
1 parent acd696b commit fcb0ca9

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

exe/retest

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ runner = Retest::Runners.runner_for(command.to_s, command_stdin: runner_rd)
3232
sounds = Retest::Sounds.for(options)
3333

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

3939
sounds.play(:start)
@@ -47,6 +47,8 @@ program = Retest::Program.new(
4747
)
4848

4949
if options.params[:diff]
50+
prompt.input = $stdin
51+
runner.command_stdin = $stdin
5052
program.diff(options.params[:diff])
5153
return
5254
end
@@ -85,8 +87,8 @@ loop do
8587

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

88-
if runner.running?
89-
runner_wr.puts input
90+
if prompt.question_asked?
91+
prompt_wr.puts input
9092
next
9193
end
9294

lib/retest/options.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,9 @@ def force_polling?
158158
def extension
159159
Regexp.new(params[:ext])
160160
end
161+
162+
def merge(options = [])
163+
self.class.new(@args.dup.concat(options))
164+
end
161165
end
162166
end

test/retest/options_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,14 @@ def test_notify?
4848
@subject.args = ["--notify"]
4949
assert @subject.notify?
5050
end
51+
52+
def test_all_version_copy
53+
@subject.args = %w[--notify --rake]
54+
55+
copy = @subject.merge(%w[--all])
56+
57+
assert_equal %w[--notify --rake --all], copy.args
58+
refute_equal copy.object_id, @subject.object_id
59+
end
5160
end
5261
end

0 commit comments

Comments
 (0)