1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Recognize Windows-style paths in test runner

Previously, a test runner argument had to contain a forward slash to be
recognized as a path.  Now, backslashes will also be considered,
enabling the use of Windows-style paths.

Fixes #38243.
This commit is contained in:
Jonathan Hefner 2020-04-21 00:46:49 -05:00
parent a2c3ef098a
commit 7bf4520292
2 changed files with 13 additions and 1 deletions

View file

@ -62,6 +62,7 @@ module Rails
def extract_filters(argv)
# Extract absolute and relative paths but skip -n /.*/ regexp filters.
argv.select { |arg| path_argument?(arg) && !regexp_filter?(arg) }.map do |path|
path = path.tr("\\", "/")
case
when /(:\d+)+$/.match?(path)
file, *lines = path.split(":")
@ -81,7 +82,7 @@ module Rails
end
def path_argument?(arg)
%r%^/?\w+/%.match?(arg)
%r"^[/\\]?\w+[/\\]".match?(arg)
end
end
end

View file

@ -320,6 +320,17 @@ module ApplicationTests
end
end
def test_run_windows_style_path
create_test_file :models, "account"
create_test_file :controllers, "accounts_controller"
# double-escape backslash -- once for Ruby and again for shelling out
run_test_command("test\\\\models").tap do |output|
assert_match "AccountTest", output
assert_match "1 runs, 1 assertions, 0 failures, 0 errors, 0 skips", output
end
end
def test_run_with_ruby_command
app_file "test/models/post_test.rb", <<-RUBY
require "test_helper"