From 07d84b7c8db5b85f7521cfc5d2028ed973d9a14b Mon Sep 17 00:00:00 2001 From: Pawan Dubey Date: Mon, 24 Jul 2017 21:53:01 -0400 Subject: Allow bin/rails test task to take absolute paths as arguments Solves #29923 This regression was caused due to a wrong regex to filter out paths, introduced in commit 796a1cf0e The regex was /^\w+\// which did not accept paths with a leading slash and hence all absolute paths were filtered out. This change introduces a change in regex which allows for a leading slash and acts on the matched term accordingly. While cascading through the case block, the paths are checked for line number specification, existence of a directory at that path and if none of those match, then it is considered to be a path to the file. The regex matchers specified are filtered out via the call to `Array#compact` since they do not match any of these conditions. --- railties/lib/rails/test_unit/runner.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/test_unit/runner.rb b/railties/lib/rails/test_unit/runner.rb index 8018ef9d02..33ba2788b4 100644 --- a/railties/lib/rails/test_unit/runner.rb +++ b/railties/lib/rails/test_unit/runner.rb @@ -58,7 +58,7 @@ module Rails private def extract_filters(argv) - argv.select { |arg| arg =~ /^\w+\// }.map do |path| + argv.select { |arg| arg =~ %r{^/?\w+/} }.map do |path| case when path =~ /(:\d+)+$/ file, *lines = path.split(":") @@ -66,11 +66,11 @@ module Rails file when Dir.exist?(path) "#{path}/**/*_test.rb" - else + when path !~ /\/$/ filters << [ path, [] ] path end - end + end.compact end end end -- cgit v1.2.3