rspec-conductor 1.0.11 → 1.0.13

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a4f284fb6887972bbd325f6a5d6ce77b3c384d3cc7b8933c19bd04af2aa3ada
4
- data.tar.gz: 733f1d8de0935949b77aa54374f37f97976a007c7dc53381b1dc8d8bb3e6922d
3
+ metadata.gz: b4a0e80c50d64016bdf33f302aca5ecfcf864b1aeb2b731959524a9c69420fe9
4
+ data.tar.gz: f65298df39d7efce1b4122ad1da5a47748d01cd32d5dedde89d687c128007a20
5
5
  SHA512:
6
- metadata.gz: e23c66e05afe4064b4a6062d6f7880429e641c5e2a3eac73f60a50ba5bd4c75ecb2b36a8484405200e9e8102f0cfd24b20fb99a0fbdf959be376e0087cf4006d
7
- data.tar.gz: ebc3ad89f178da346ce4a5aee153e280b8b10b98f2c1d4e55894035237ee9f990e34206f272f35128d0e94da7c01847acd15225ab7a8db0516ceb674618f1887
6
+ metadata.gz: 4f9d0d58104cbd80abdf7eed585215dc25fcb21626caafbc2342db5fd3ef8062fa2f2df25c5aae4941d891ed771c56efe2cd359441ec8dfc5866ca91aced6faf
7
+ data.tar.gz: 4a1b51184dbf8d76c6723143c99e2e3fbc2faf6d374ab2c3de0198a9511d006e68509d709483bfb6c32a93403a1313d90fb625ad9547b941d8cfb91e7091ffac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.0.13] - TBD
2
+
3
+ - Fix stdin echo not being reenabled after the program is terminated
4
+ - When --example-status-persistence flag is set and the status file is available, run slowest spec files first (helpful when you have a mix of super slow and super fast spec files)
5
+
6
+ ## [1.0.12] - 2026-09-12
7
+
8
+ - Add --example-status-persistence option to mimic rspec example status persistence runner config and to support --only-failures on repeat runs
9
+
1
10
  ## [1.0.11] - 2026-08-03
2
11
 
3
12
  - Fix a bug in 2.x that would cause an exception because of the 3.x syntax usage (`_1`) in the formatter base
@@ -16,6 +16,7 @@ module RSpec
16
16
  prefork_require: 'config/application.rb',
17
17
  postfork_require: :spec_helper,
18
18
  print_slowest_count: nil,
19
+ example_status_persistence_path: Conductor.default_example_status_persistence_path,
19
20
  }.freeze
20
21
 
21
22
  def self.run(argv)
@@ -30,7 +31,9 @@ module RSpec
30
31
 
31
32
  def run
32
33
  parse_arguments
33
- start_server
34
+
35
+ $stdout.sync = true
36
+ disabling_stdin_echo { start_server }
34
37
  end
35
38
 
36
39
  private
@@ -102,6 +105,10 @@ module RSpec
102
105
  @conductor_options[:print_slowest_count] = n
103
106
  end
104
107
 
108
+ opts.on("--example-status-persistence-path FILENAME", String, "Persist example statuses to a given file (same as rspec config.example_status_persistence_file_path)") do |filename|
109
+ @conductor_options[:example_status_persistence_path] = filename
110
+ end
111
+
105
112
  opts.on("--verbose", "Enable debug output") do
106
113
  @conductor_options[:verbose] = true
107
114
  end
@@ -126,9 +133,14 @@ module RSpec
126
133
  formatter: @conductor_options[:formatter],
127
134
  display_retry_backtraces: @conductor_options[:display_retry_backtraces],
128
135
  print_slowest_count: @conductor_options[:print_slowest_count],
136
+ example_status_persistence_path: @conductor_options[:example_status_persistence_path],
129
137
  verbose: @conductor_options[:verbose],
130
138
  ).run
131
139
  end
140
+
141
+ def disabling_stdin_echo
142
+ $stdin.tty? ? $stdin.noecho { yield } : yield
143
+ end
132
144
  end
133
145
  end
134
146
  end
@@ -0,0 +1,51 @@
1
+ module RSpec
2
+ module Conductor
3
+ module ExampleStatusPersister
4
+ # RSpec::Core::ExampleStatusPersister is a private api, but it's been fairly stable over the versions
5
+ # we want to support, so I don't expect issues using these stubs.
6
+ ExampleStub = Struct.new(:id, :execution_result)
7
+ ExampleExecutionResultStub = Struct.new(:status, :run_time)
8
+
9
+ def self.persist(example_stats, filename)
10
+ examples = example_stats.map do |stat|
11
+ ExampleStub.new(
12
+ stat[:id],
13
+ ExampleExecutionResultStub.new(stat[:status], stat[:run_time])
14
+ )
15
+ end
16
+ RSpec::Core::ExampleStatusPersister.persist(examples, filename)
17
+ end
18
+
19
+ def self.load(filename)
20
+ return [] unless filename
21
+ return [] unless File.exist?(filename)
22
+
23
+ RSpec::Core::ExampleStatusPersister.load_from(filename).map do |status_hash|
24
+ runtime = status_hash.fetch(:run_time)
25
+ if runtime && (match = runtime.match(/\A(\d+(.\d+)?)/))
26
+ runtime_seconds = match[1].to_f
27
+ else
28
+ runtime_seconds = nil
29
+ end
30
+
31
+ ExampleStub.new(
32
+ status_hash.fetch(:example_id),
33
+ ExampleExecutionResultStub.new(
34
+ status_hash.fetch(:status),
35
+ runtime_seconds
36
+ )
37
+ )
38
+ end
39
+ end
40
+
41
+ def self.example_id_to_full_path(example_id)
42
+ return unless example_id
43
+
44
+ filename = RSpec::Core::Example.parse_id(example_id)[0]
45
+ return unless filename && File.exist?(filename)
46
+
47
+ File.expand_path(filename)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -17,12 +17,14 @@ module RSpec
17
17
  end
18
18
 
19
19
  def example_passed(notification)
20
+ ex = notification.example
20
21
  @socket.send_message(
21
22
  type: :example_passed,
23
+ id: ex.id,
22
24
  file: @file,
23
- description: notification.example.full_description,
24
- location: notification.example.location,
25
- run_time: notification.example.execution_result.run_time
25
+ description: ex.full_description,
26
+ location: ex.location,
27
+ run_time: ex.execution_result.run_time
26
28
  )
27
29
  @shutdown_check.call
28
30
  end
@@ -31,6 +33,7 @@ module RSpec
31
33
  ex = notification.example
32
34
  @socket.send_message(
33
35
  type: :example_failed,
36
+ id: ex.id,
34
37
  file: @file,
35
38
  description: ex.full_description,
36
39
  location: ex.location,
@@ -46,6 +49,7 @@ module RSpec
46
49
  ex = notification.example
47
50
  @socket.send_message(
48
51
  type: :example_pending,
52
+ id: ex.id,
49
53
  file: @file,
50
54
  description: ex.full_description,
51
55
  location: ex.location,
@@ -24,9 +24,10 @@ module RSpec
24
24
  @postfork_require = opts.fetch(:postfork_require, nil)
25
25
  @first_is_1 = opts.fetch(:first_is_1, Conductor.default_first_is_1?)
26
26
  @seed = opts[:seed] || (Random.new_seed % MAX_SEED)
27
- @fail_fast_after = opts[:fail_fast_after]
27
+ @fail_fast_after = opts.fetch(:fail_fast_after, nil)
28
28
  @display_retry_backtraces = opts.fetch(:display_retry_backtraces, false)
29
29
  @print_slowest_count = opts.fetch(:print_slowest_count, nil)
30
+ @example_status_persistence_path = opts.fetch(:example_status_persistence_path, nil)
30
31
  @verbose = opts.fetch(:verbose, false)
31
32
 
32
33
  @rspec_args = rspec_args
@@ -45,8 +46,6 @@ module RSpec
45
46
  @formatter = @formatter_class.new(worker_count: @worker_count)
46
47
  @suite_run = SuiteRun.new
47
48
 
48
- $stdout.sync = true
49
- $stdin.echo = false if $stdin.tty?
50
49
  Dir.chdir(Conductor.root)
51
50
  ENV["PARALLEL_TEST_GROUPS"] = worker_count.to_s # parallel_tests backward-compatibility
52
51
  end
@@ -65,6 +64,7 @@ module RSpec
65
64
 
66
65
  @formatter.print_summary(@suite_run, seed: @seed, success: success?)
67
66
  @formatter.print_slowest(@suite_run, @print_slowest_count) if @print_slowest_count
67
+ Conductor::ExampleStatusPersister.persist(@suite_run.example_stats, @example_status_persistence_path) if @example_status_persistence_path
68
68
  exit_with_status
69
69
  end
70
70
 
@@ -91,10 +91,26 @@ module RSpec
91
91
  config_options.configure(config)
92
92
  debug "RSpec config: #{config.inspect}"
93
93
  debug "Files to run: #{config.files_to_run}"
94
- @spec_queue = config.files_to_run.shuffle(random: Random.new(@seed))
94
+ @spec_queue = ordered_files_to_run(config)
95
95
  @suite_run.spec_files_total = @spec_queue.size
96
96
  end
97
97
 
98
+ def ordered_files_to_run(config)
99
+ slowest_files_sorted = ExampleStatusPersister.load(@example_status_persistence_path)
100
+ .select { |r| r.execution_result.run_time }
101
+ .each_with_object(Hash.new { |h, k| h[k] = 0 }) { |r, h| h[ExampleStatusPersister.example_id_to_full_path(r.id)] += r.execution_result.run_time }
102
+ .select { |fn, _runtime| fn }
103
+ .sort_by { |_fn, runtime| -runtime }
104
+ .map(&:first)
105
+
106
+ all_files_to_run = config.files_to_run
107
+ slowest_to_run = slowest_files_sorted & all_files_to_run
108
+ rest_to_run = (all_files_to_run - slowest_to_run).shuffle(random: Random.new(@seed))
109
+
110
+ debug "Running #{slowest_to_run} files first, the rest are shuffled randomly: #{rest_to_run}"
111
+ slowest_to_run + rest_to_run
112
+ end
113
+
98
114
  def preload_application
99
115
  if !@prefork_require
100
116
  debug "Prefork require not set, skipping..."
@@ -169,7 +185,9 @@ module RSpec
169
185
  initiate_shutdown
170
186
  end
171
187
  when :example_pending
172
- @suite_run.example_pending
188
+ @suite_run.example_pending(message)
189
+ when :example_filtered
190
+ @suite_run.example_filtered(message)
173
191
  when :example_retried
174
192
  @formatter.print_retry_message(message) if @display_retry_backtraces
175
193
  when :spec_complete
@@ -24,20 +24,25 @@ module RSpec
24
24
  end
25
25
 
26
26
  def example_passed(message)
27
- @example_stats << message.slice(:location, :run_time, :description)
27
+ @example_stats << message.slice(:id, :location, :run_time, :description).merge(status: "passed")
28
28
  @examples_passed += 1
29
29
  end
30
30
 
31
31
  def example_failed(message)
32
- @example_stats << message.slice(:location, :run_time, :description)
32
+ @example_stats << message.slice(:id, :location, :run_time, :description).merge(status: "failed")
33
33
  @examples_failed += 1
34
34
  @errors << message
35
35
  end
36
36
 
37
- def example_pending
37
+ def example_pending(message)
38
+ @example_stats << message.slice(:id, :location).merge(status: "pending")
38
39
  @examples_pending += 1
39
40
  end
40
41
 
42
+ def example_filtered(message)
43
+ @example_stats << message.slice(:id, :location).merge(status: nil)
44
+ end
45
+
41
46
  def spec_file_assigned
42
47
  @specs_started_at ||= Time.now
43
48
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Conductor
5
- VERSION = "1.0.11"
5
+ VERSION = "1.0.13"
6
6
  end
7
7
  end
@@ -129,6 +129,16 @@ module RSpec
129
129
  example_groups.each { |g| g.run(reporter) }
130
130
  end
131
131
 
132
+ RSpec.world.all_examples.reject { |e| e.execution_result.status }.each do |e|
133
+ @socket.send_message(
134
+ type: :example_filtered,
135
+ id: e.id,
136
+ file: file,
137
+ description: e.full_description,
138
+ location: e.location
139
+ )
140
+ end
141
+
132
142
  @socket.send_message(
133
143
  type: :spec_complete,
134
144
  file: file,
@@ -24,6 +24,10 @@ module RSpec
24
24
  def self.default_first_is_1?
25
25
  ENV["RSPEC_CONDUCTOR_FIRST_IS_1"] == "1"
26
26
  end
27
+
28
+ def self.default_example_status_persistence_path
29
+ ENV["RSPEC_CONDUCTOR_EXAMPLE_STATUS_PERSISTENCE_PATH"]
30
+ end
27
31
  end
28
32
  end
29
33
 
@@ -43,6 +47,7 @@ require_relative "conductor/formatters/base"
43
47
  require_relative "conductor/formatters/plain"
44
48
  require_relative "conductor/formatters/ci"
45
49
  require_relative "conductor/formatters/fancy"
50
+ require_relative "conductor/example_status_persister"
46
51
 
47
52
  require_relative "conductor/ext/rspec"
48
53
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.11
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Abramov
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2026-08-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rspec-core
@@ -42,6 +41,7 @@ files:
42
41
  - exe/rspec-conductor
43
42
  - lib/rspec/conductor.rb
44
43
  - lib/rspec/conductor/cli.rb
44
+ - lib/rspec/conductor/example_status_persister.rb
45
45
  - lib/rspec/conductor/ext/rspec.rb
46
46
  - lib/rspec/conductor/formatters/base.rb
47
47
  - lib/rspec/conductor/formatters/ci.rb
@@ -69,7 +69,6 @@ metadata:
69
69
  homepage_uri: https://github.com/markiz/rspec-conductor
70
70
  source_code_uri: https://github.com/markiz/rspec-conductor
71
71
  changelog_uri: https://github.com/markiz/rspec-conductor/blob/master/CHANGELOG.md
72
- post_install_message:
73
72
  rdoc_options: []
74
73
  require_paths:
75
74
  - lib
@@ -84,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
83
  - !ruby/object:Gem::Version
85
84
  version: '0'
86
85
  requirements: []
87
- rubygems_version: 3.3.26
88
- signing_key:
86
+ rubygems_version: 4.0.6
89
87
  specification_version: 4
90
88
  summary: Queue-based parallel test runner for rspec
91
89
  test_files: []