Skip to content

Commit 2c704f3

Browse files
authored
Merge branch 'v2.0' into 2.0/stdin
2 parents 00c4be1 + 9b86f2b commit 2c704f3

File tree

10 files changed

+40
-23
lines changed

10 files changed

+40
-23
lines changed

exe/retest

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ loop do
8383
print_interactive_message
8484

8585
puts "waiting for input"
86-
input = $stdin.gets.chomp
86+
input = $stdin.gets.to_s.chomp
8787

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

@@ -128,12 +128,13 @@ loop do
128128
when 'h', 'help'
129129
puts <<~HELP
130130
131-
* 'h' or 'help' -> Prints help
132-
* 'p' or 'pause' -> Pauses Retest. Tests aren't run until unpaused.
133-
* 'u' or 'unpause' -> Unpauses Retest
134-
* <Enter> -> Runs last changed triggered command
135-
* 'ra', 'run all' -> Runs all tests
136-
* 'e' or 'exit' -> Exits Retest
131+
* 'h', 'help' # Prints help
132+
* 'p', 'pause' # Pauses Retest. Tests aren't run until unpaused.
133+
* 'u', 'unpause' # Unpauses Retest
134+
* <ENTER> # Runs last changed triggered command
135+
* 'ra, 'run all' # Runs all tests
136+
* 'd', 'diff' [GIT BRANCH] # Run matching specs that changed from a target branch
137+
* 'e', 'exit' # Exits Retest
137138
HELP
138139
else
139140
puts "Unknown interactive command #{input}\n"

features/ruby-bare/retest/flags/version.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ def teardown
66
def test_version
77
launch_retest 'retest --version'
88

9-
assert_match /^1\.\d+\.\d+/, @output.read
9+
assert_match /^2\.\d+\.\d+/, @output.read
1010
end
1111

1212
def test_version_short_flag
1313
launch_retest 'retest -v'
1414

15-
assert_match /^1\.\d+\.\d+/, @output.read
15+
assert_match /^2\.\d+\.\d+/, @output.read
1616
end
1717
end

lib/retest/prompt.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def ask_which_test_to_use(path, files)
2828
Enter the file number now:
2929
QUESTION
3030
output.print("> ")
31-
options.values[input.gets.chomp.to_i]
31+
options.values[input.gets.to_s.chomp.to_i]
3232
end
3333
end
3434

lib/retest/runners.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
module Retest
77
module Runners
8+
class NotSupportedError < StandardError; end
9+
810
module_function
911

1012
def runner_for(command, **opts)

lib/retest/runners/runner.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def run(changed_file = nil, repository: nil)
1919
end
2020

2121
def run_all_tests(tests_string)
22-
log("Test File Selected: #{tests_string}")
23-
system_run command.gsub('<test>', tests_string)
22+
raise NotSupportedError, 'cannot run multiple test files against this command'
2423
end
2524

2625
def sync(added:, removed:)

lib/retest/runners/test_runner.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ def run(changed_file, repository:)
1414
system_run command.gsub('<test>', cached_test_file)
1515
end
1616

17+
def run_all_tests(tests_string)
18+
log("Test File Selected: #{tests_string}")
19+
system_run command.gsub('<test>', tests_string)
20+
end
21+
1722
def sync(added:, removed:)
1823
purge_test_file(removed)
1924
end

test/retest/runners/change_runner_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def test_run_with_a_file_found
4242

4343
assert_match "touch file_path.rb", out
4444
end
45+
46+
def test_run_all_tests
47+
assert_raises(NotSupportedError) { @subject.run_all_tests('file_path.rb file_path_two.rb') }
48+
end
4549
end
4650
end
4751
end

test/retest/runners/runner_test.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,7 @@ def test_run
3535
end
3636

3737
def test_run_all_tests
38-
runner = Runner.new("echo '<test>'", stdout: StringIO.new)
39-
40-
out, _ = capture_subprocess_io { runner.run_all_tests('file_path.rb file_path_two.rb') }
41-
42-
assert_equal(<<~EXPECATIONS, runner.stdout.string)
43-
Test File Selected: file_path.rb file_path_two.rb
44-
EXPECATIONS
45-
46-
assert_equal(<<~EXPECATIONS, out)
47-
file_path.rb file_path_two.rb
48-
EXPECATIONS
38+
assert_raises(NotSupportedError) { @subject.run_all_tests('file_path.rb file_path_two.rb') }
4939
end
5040
end
5141
end

test/retest/runners/test_runner_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ def test_sync_files
7474
@subject.sync(added: 'a.rb', removed:'file_path_test.rb')
7575
assert_nil @subject.cached_test_file
7676
end
77+
78+
def test_run_all_tests
79+
out, _ = capture_subprocess_io { @subject.run_all_tests('file_path.rb file_path_two.rb') }
80+
81+
assert_equal(<<~EXPECATIONS, @subject.stdout.string)
82+
Test File Selected: file_path.rb file_path_two.rb
83+
EXPECATIONS
84+
85+
assert_equal(<<~EXPECATIONS, out)
86+
touch file_path.rb file_path_two.rb
87+
EXPECATIONS
88+
end
7789
end
7890
end
7991
end

test/retest/runners/variable_runner_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ def test_sync_files
8585
@subject.sync(added: 'a.rb', removed:'file_path_test.rb')
8686
assert_nil @subject.cached_test_file
8787
end
88+
89+
def test_run_all_tests
90+
assert_raises(NotSupportedError) { @subject.run_all_tests('file_path.rb file_path_two.rb') }
91+
end
8892
end
8993
end
9094
end

0 commit comments

Comments
 (0)