Class: Megatest::Selector::List
- Inherits:
-
Object
- Object
- Megatest::Selector::List
- Defined in:
- lib/megatest/selector.rb
Instance Attribute Summary collapse
-
#loaders ⇒ Object
Returns the value of attribute loaders.
Instance Method Summary collapse
-
#initialize(config, loaders, filters) ⇒ List
constructor
A new instance of List.
- #main_paths ⇒ Object
- #paths(random:) ⇒ Object
- #select(registry, random:) ⇒ Object
Constructor Details
Instance Attribute Details
#loaders ⇒ Object
Returns the value of attribute loaders.
8 9 10 |
# File 'lib/megatest/selector.rb', line 8 def loaders @loaders end |
Instance Method Details
#main_paths ⇒ Object
18 19 20 21 22 23 |
# File 'lib/megatest/selector.rb', line 18 def main_paths paths = @loaders.map(&:path) paths.compact! paths.uniq! paths end |
#paths(random:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/megatest/selector.rb', line 25 def paths(random:) paths = @loaders.reduce([]) do |paths_to_load, loader| loader.append_paths(paths_to_load) end paths.uniq! paths.sort! paths.shuffle!(random: random) if random paths end |
#select(registry, random:) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/megatest/selector.rb', line 36 def select(registry, random:) # If any of the selector points to an exact test or a subset of a suite, # then each selector is responsible for shuffling the group of tests it selects, # so that tests are shuffled inside groups, but groups are ordered. test_cases = if @loaders.any?(&:partial?) @loaders.reduce([]) do |tests_to_run, loader| loader.append_tests(tests_to_run, registry, random: random) end else # Otherwise, we do one big shuffle at the end, all groups are mixed. test_cases = registry.test_cases test_cases.sort! test_cases.shuffle!(random: random) if random test_cases end @filters.reduce(test_cases) do |cases, filter| filter.select(cases) end end |