Skip to content

Commit

Permalink
cleanup pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Feb 7, 2019
1 parent 4f0b5ee commit 8509890
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/parallel_tests/test/runner.rb
Expand Up @@ -209,23 +209,20 @@ def sort_by_filesize(tests)
end

def find_tests(tests, options = {})
files_list = (tests || []).map do |file_or_folder|
suffix_pattern = options[:suffix] || test_suffix
include_pattern = options[:pattern] || //
exclude_pattern = options[:exclude_pattern]

(tests || []).flat_map do |file_or_folder|
if File.directory?(file_or_folder)
files = files_in_folder(file_or_folder, options)
files.grep(options[:suffix] || test_suffix)
.grep(options[:pattern] || //)
files = files.grep(suffix_pattern).grep(include_pattern)
files.reject! { |f| f =~ exclude_pattern } if exclude_pattern # use grep_v if we are on ruby 2.3+
files
else
file_or_folder
end
end

flat_files_list = files_list.uniq.flat_map { |i| i }

if regex = options[:exclude_pattern]
flat_files_list.reject! { |file| file =~ regex }
end

flat_files_list
end.uniq
end

def files_in_folder(folder, options={})
Expand Down

0 comments on commit 8509890

Please sign in to comment.