Module: Mutineer::MinitestIntegration::FileOrder
- Defined in:
- lib/mutineer/minitest_integration/file_order.rb
Overview
Extends the list of test classes. shuffle orders files by FileOrder.rank and
shuffles each file on its own.
Class Attribute Summary collapse
-
.rank ⇒ Hash{Class => Integer}?
Each test class's file position.
Instance Method Summary collapse
-
#reject ⇒ Array<Class>
Minitest 5.15 and older drop empty classes before the shuffle, so the filtered list keeps the file order too.
-
#shuffle ⇒ Array<Class>
Files in rank order.
Class Attribute Details
.rank ⇒ Hash{Class => Integer}?
Each test class's file position.
28 29 30 |
# File 'lib/mutineer/minitest_integration/file_order.rb', line 28 def rank @rank end |
Instance Method Details
#reject ⇒ Array<Class>
Minitest 5.15 and older drop empty classes before the shuffle, so the filtered list keeps the file order too.
51 52 53 |
# File 'lib/mutineer/minitest_integration/file_order.rb', line 51 def reject(...) super.extend(FileOrder) end |
#shuffle ⇒ Array<Class>
Files in rank order. Classes that share a file are shuffled with
Random.new(Minitest.seed), so their order does not depend on the
other files in the run. A nil seed keeps load order.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mutineer/minitest_integration/file_order.rb', line 36 def shuffle(*) rank = FileOrder.rank || {} seed = ::Minitest.seed grouped = group_by { |klass| rank.fetch(klass, rank.size) } grouped.sort.flat_map do |_index, classes| next classes if classes.size < 2 || seed.nil? classes.shuffle(random: Random.new(seed.to_i)) end end |