Class: TLDR::Strategizer
- Inherits:
-
Object
- Object
- TLDR::Strategizer
- Defined in:
- lib/tldr/strategizer.rb
Defined Under Namespace
Classes: Strategy
Instance Method Summary collapse
-
#strategize(all_tests, run_these_together_groups, thread_unsafe_test_groups, config) ⇒ Object
Combine all discovered test methods with any methods grouped by run_these_together!.
Instance Method Details
#strategize(all_tests, run_these_together_groups, thread_unsafe_test_groups, config) ⇒ Object
Combine all discovered test methods with any methods grouped by run_these_together!
Priorities:
- Map over tests to build out groups in order to retain shuffle order
(group will run in position of first test in the group)
- If a test is in multiple groups, only run it once
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 |
# File 'lib/tldr/strategizer.rb', line 13 def strategize all_tests, run_these_together_groups, thread_unsafe_test_groups, config return Strategy.new(parallel?: false) if run_sequentially?(all_tests, config) thread_unsafe_tests, thread_safe_tests = partition_unsafe(all_tests, thread_unsafe_test_groups) prepend_sequential_tests, append_sequential_tests = partition_prepend(thread_unsafe_tests, config) grouped_tests = prepare_run_together_groups(run_these_together_groups, thread_safe_tests, append_sequential_tests) already_included_groups = [] parallel_tests_and_groups = thread_safe_tests.map { |test| if (group = grouped_tests.find { |group| group.tests.include?(test) }) if already_included_groups.include?(group) next elsif (other = already_included_groups.find { |other| (group.tests & other.tests).any? }) other.tests |= group.tests next else already_included_groups << group group end else test end }.compact Strategy.new( parallel?: true, prepend_sequential_tests:, parallel_tests_and_groups:, append_sequential_tests: ) end |