Class: Minitest::Distributed::TestSelector
- Inherits:
-
Object
- Object
- Minitest::Distributed::TestSelector
- Extended by:
- T::Sig
- Defined in:
- lib/minitest/distributed/test_selector.rb
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #discover_tests ⇒ Object
-
#initialize(options) ⇒ TestSelector
constructor
A new instance of TestSelector.
- #initialize_filters ⇒ Object
- #runnables ⇒ Object
- #select_tests(tests) ⇒ Object
- #tests ⇒ Object
Constructor Details
#initialize(options) ⇒ TestSelector
Returns a new instance of TestSelector.
18 19 20 21 22 23 |
# File 'lib/minitest/distributed/test_selector.rb', line 18 def initialize() @options = @filters = T.let([], T::Array[Filters::FilterInterface]) initialize_filters end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
15 16 17 |
# File 'lib/minitest/distributed/test_selector.rb', line 15 def filters @filters end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/minitest/distributed/test_selector.rb', line 12 def @options end |
Instance Method Details
#discover_tests ⇒ Object
38 39 40 41 42 |
# File 'lib/minitest/distributed/test_selector.rb', line 38 def discover_tests runnables.flat_map do |runnable| runnable.runnable_methods.map { |method_name| runnable.new(method_name) } end end |
#initialize_filters ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/minitest/distributed/test_selector.rb', line 26 def initialize_filters @filters << Filters::IncludeFilter.new([:filter]) if [:filter] @filters << Filters::ExcludeFilter.new([:exclude]) if [:exclude] exclude_file = [:distributed].exclude_file @filters << Filters::ExcludeFileFilter.new(Pathname.new(exclude_file)) if exclude_file include_file = [:distributed].include_file @filters << Filters::IncludeFileFilter.new(Pathname.new(include_file)) if include_file end |
#runnables ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/minitest/distributed/test_selector.rb', line 45 def runnables if [:distributed].shuffle_suites srand(Minitest.seed) Minitest::Runnable.runnables.shuffle else Minitest::Runnable.runnables end end |
#select_tests(tests) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/minitest/distributed/test_selector.rb', line 55 def select_tests(tests) return tests if filters.empty? tests.flat_map do |runnable_method| filters.flat_map do |filter| filter.call(runnable_method) end end.compact end |
#tests ⇒ Object
66 67 68 |
# File 'lib/minitest/distributed/test_selector.rb', line 66 def tests select_tests(discover_tests) end |