Class: TLDR::Planner

Inherits:
Object
  • Object
show all
Defined in:
lib/tldr/planner.rb

Instance Method Summary collapse

Constructor Details

#initializePlanner

Returns a new instance of Planner.



5
6
7
# File 'lib/tldr/planner.rb', line 5

def initialize
  @strategizer = Strategizer.new
end

Instance Method Details

#plan(config) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tldr/planner.rb', line 9

def plan config
  $VERBOSE = config.warnings
  search_locations = PathUtil.expand_paths(config.paths, globs: false)

  prepend_load_paths(config)
  require_test_helper(config)
  require_tests(search_locations)

  tests = gather_tests
  config.update_after_gathering_tests!(tests)
  tests_to_run = prepend(
    shuffle(
      exclude_by_path(
        exclude_by_name(
          (
            filter_by_name(tests, config.names),
            search_locations
          ),
          config.exclude_names
        ),
        config.exclude_paths
      ),
      config.seed
    ),
    config
  )

  strategy = @strategizer.strategize(
    tests_to_run,
    GROUPED_TESTS,
    THREAD_UNSAFE_TESTS,
    config
  )

  Plan.new(tests_to_run, strategy)
end