Skip to content

Commit 0314724

Browse files
authored
Merge pull request rails#54736 from rails/revert-54647-ec-test-root
Revert "Modify the Test Runner to allow running test at root:"
2 parents dc4f4e0 + a7539d8 commit 0314724

File tree

2 files changed

+5
-59
lines changed

2 files changed

+5
-59
lines changed

railties/lib/rails/test_unit/runner.rb

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,12 @@ def compose_filter(runnable, filter)
9191

9292
private
9393
def extract_filters(argv)
94-
previous_arg_was_a_flag = false
9594
# Extract absolute and relative paths but skip -n /.*/ regexp filters.
9695
argv.filter_map do |path|
97-
current_arg_is_a_flag = /^-{1,2}[a-zA-Z0-9\-_.]+=?.*\Z/.match?(path)
98-
99-
if previous_arg_was_a_flag && !current_arg_is_a_flag
100-
# Handle the case where a flag is followed by another flag (e.g. --fail-fast --seed ...)
101-
previous_arg_was_a_flag = false
102-
next
103-
end
96+
next unless path_argument?(path)
10497

10598
path = path.tr("\\", "/")
10699
case
107-
when current_arg_is_a_flag
108-
previous_arg_was_a_flag = true unless path.include?("=") # Handle the case when "--foo=bar" is used.
109-
next
110100
when /(:\d+(-\d+)?)+$/.match?(path)
111101
file, *lines = path.split(":")
112102
filters << [ file, lines ]
@@ -132,6 +122,10 @@ def regexp_filter?(arg)
132122
arg.start_with?("/") && arg.end_with?("/")
133123
end
134124

125+
def path_argument?(arg)
126+
PATH_ARGUMENT_PATTERN.match?(arg)
127+
end
128+
135129
def list_tests(patterns)
136130
tests = Rake::FileList[patterns.any? ? patterns : default_test_glob]
137131
tests.exclude(default_test_exclude_glob) if patterns.empty?

railties/test/application/test_runner_test.rb

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -222,54 +222,6 @@ def test_sanae
222222
end
223223
end
224224

225-
def test_run_test_at_root
226-
app_file "my_test.rb", <<-RUBY
227-
require "test_helper"
228-
229-
class MyTest < ActiveSupport::TestCase
230-
def test_rikka
231-
puts 'Rikka'
232-
end
233-
end
234-
RUBY
235-
236-
run_test_command("my_test.rb").tap do |output|
237-
assert_match "Rikka", output
238-
end
239-
end
240-
241-
def test_run_test_having_a_slash_in_its_name
242-
app_file "my_test.rb", <<-RUBY
243-
require "test_helper"
244-
245-
class MyTest < ActiveSupport::TestCase
246-
test "foo/foo" do
247-
puts 'Rikka'
248-
end
249-
end
250-
RUBY
251-
252-
run_test_command("my_test.rb -n foo\/foo").tap do |output|
253-
assert_match "Rikka", output
254-
end
255-
end
256-
257-
def test_run_test_with_flags_unordered
258-
app_file "my_test.rb", <<-RUBY
259-
require "test_helper"
260-
261-
class MyTest < ActiveSupport::TestCase
262-
test "foo/foo" do
263-
puts 'Rikka'
264-
end
265-
end
266-
RUBY
267-
268-
run_test_command("--seed 344 my_test.rb --fail-fast -n foo\/foo").tap do |output|
269-
assert_match "Rikka", output
270-
end
271-
end
272-
273225
def test_run_matched_test
274226
app_file "test/unit/chu_2_koi_test.rb", <<-RUBY
275227
require "test_helper"

0 commit comments

Comments
 (0)