Class: Megatest::Selector::List
- Inherits:
-
Object
- Object
- Megatest::Selector::List
- Defined in:
- lib/megatest/selector.rb
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 Method Details
#main_paths ⇒ Object
16 17 18 19 20 21 |
# File 'lib/megatest/selector.rb', line 16 def main_paths paths = @loaders.map(&:path) paths.compact! paths.uniq! paths end |
#paths(random:) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/megatest/selector.rb', line 23 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
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/megatest/selector.rb', line 34 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 |