mutineer 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,7 @@ module Mutineer
44
44
  # silenced here: the fork boundary that calls this method has already
45
45
  # pointed stdout at File::NULL (see ChildStdout).
46
46
  sink = StringIO.new
47
+ keep_file_order(spec_files) if stop_at_first_failure || record_to
47
48
  args = ["--no-color"]
48
49
  args << "--fail-fast" if stop_at_first_failure
49
50
  status = with_fail_fast_off(record_to) do
@@ -56,6 +57,44 @@ module Mutineer
56
57
  KillChannel.write_end(record_to) if record_to && KillFormatter.last&.saw_every_example?
57
58
 
58
59
  status.zero? ? 0 : 1
60
+ ensure
61
+ FileOrder.rank = nil
62
+ end
63
+
64
+ # Runs the top-level example groups in the order of `spec_files` (#203),
65
+ # after RSpec's own ordering, which then decides the order within a file.
66
+ #
67
+ # @api private
68
+ # @param spec_files [String, Array<String>] the files, in run order.
69
+ # @return [void]
70
+ def self.keep_file_order(spec_files)
71
+ FileOrder.rank = Array(spec_files).each_with_index.to_h { |f, i| [File.expand_path(f), i] }
72
+ ::RSpec::Core::World.prepend(FileOrder) unless ::RSpec::Core::World <= FileOrder
73
+ end
74
+
75
+ # Prepended on `RSpec::Core::World`: a stable sort of the ordered
76
+ # top-level groups by their file's position. Does nothing without a rank.
77
+ module FileOrder
78
+ class << self
79
+ # Each spec file's position, keyed by absolute path, or nil.
80
+ #
81
+ # @return [Hash{String => Integer}, nil]
82
+ attr_accessor :rank
83
+ end
84
+
85
+ # The groups RSpec ordered, sorted by file position.
86
+ #
87
+ # @return [Array<RSpec::Core::ExampleGroup>]
88
+ def ordered_example_groups
89
+ groups = super
90
+ rank = FileOrder.rank
91
+ return groups unless rank
92
+
93
+ groups.sort_by.with_index do |group, i|
94
+ file = group.metadata[:absolute_file_path] || File.expand_path(group.file_path)
95
+ [rank.fetch(file, rank.size), i]
96
+ end
97
+ end
59
98
  end
60
99
 
61
100
  # Runs the block with fail-fast forced off when `record_to` is set: a
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mutineer
4
4
  # Current Mutineer release version.
5
- VERSION = "1.5.0"
5
+ VERSION = "1.6.0"
6
6
  end
data/lib/mutineer.rb CHANGED
@@ -36,6 +36,7 @@ require_relative "mutineer/mutators/operator_assignment"
36
36
  require_relative "mutineer/mutator_registry"
37
37
  require_relative "mutineer/worker_pool"
38
38
  require_relative "mutineer/progress"
39
+ require_relative "mutineer/job_plan"
39
40
  require_relative "mutineer/runner"
40
41
  require_relative "mutineer/kill_matrix"
41
42
  require_relative "mutineer/reporter"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutineer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Teren
@@ -64,6 +64,7 @@ files:
64
64
  - lib/mutineer/external_backend.rb
65
65
  - lib/mutineer/file_swap.rb
66
66
  - lib/mutineer/isolation.rb
67
+ - lib/mutineer/job_plan.rb
67
68
  - lib/mutineer/kill_channel.rb
68
69
  - lib/mutineer/kill_matrix.rb
69
70
  - lib/mutineer/minitest_integration.rb
@@ -93,6 +94,7 @@ files:
93
94
  - lib/mutineer/mutators/safe_navigation.rb
94
95
  - lib/mutineer/mutators/statement_removal.rb
95
96
  - lib/mutineer/mutators/string_literal.rb
97
+ - lib/mutineer/orphan_guard.rb
96
98
  - lib/mutineer/pairing.rb
97
99
  - lib/mutineer/parser.rb
98
100
  - lib/mutineer/progress.rb