rspec-conductor 1.0.12 → 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: 2adf2982f4c0054337c9cc8b405231af7584e34d424286dea68099592a467618
4
- data.tar.gz: e583031bf5ce03f04e462f1b74037cdf6ea7b495c3c0cbe15a0eb1cec4d0e699
3
+ metadata.gz: b4a0e80c50d64016bdf33f302aca5ecfcf864b1aeb2b731959524a9c69420fe9
4
+ data.tar.gz: f65298df39d7efce1b4122ad1da5a47748d01cd32d5dedde89d687c128007a20
5
5
  SHA512:
6
- metadata.gz: 4308277ebb07fb4aa16a67a833d518c7f2d8a0479aa3a13050fcb067f91222def4a206ba7b23a147a2f17f7c76df7ca42d7b04b0a19193f5bc875f1196a44d95
7
- data.tar.gz: bb41bf5812b8d7b5dcf7691de809035e3ce444854b7d6290f4e7bae705887d99d3cbd982c7bc82b6f4b6b2e66ebd7de7840859c0c2d62737bd4e520b1a249f30
6
+ metadata.gz: 4f9d0d58104cbd80abdf7eed585215dc25fcb21626caafbc2342db5fd3ef8062fa2f2df25c5aae4941d891ed771c56efe2cd359441ec8dfc5866ca91aced6faf
7
+ data.tar.gz: 4a1b51184dbf8d76c6723143c99e2e3fbc2faf6d374ab2c3de0198a9511d006e68509d709483bfb6c32a93403a1313d90fb625ad9547b941d8cfb91e7091ffac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
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
+
1
6
  ## [1.0.12] - 2026-09-12
2
7
 
3
8
  - Add --example-status-persistence option to mimic rspec example status persistence runner config and to support --only-failures on repeat runs
@@ -31,7 +31,9 @@ module RSpec
31
31
 
32
32
  def run
33
33
  parse_arguments
34
- start_server
34
+
35
+ $stdout.sync = true
36
+ disabling_stdin_echo { start_server }
35
37
  end
36
38
 
37
39
  private
@@ -135,6 +137,10 @@ module RSpec
135
137
  verbose: @conductor_options[:verbose],
136
138
  ).run
137
139
  end
140
+
141
+ def disabling_stdin_echo
142
+ $stdin.tty? ? $stdin.noecho { yield } : yield
143
+ end
138
144
  end
139
145
  end
140
146
  end
@@ -15,6 +15,37 @@ module RSpec
15
15
  end
16
16
  RSpec::Core::ExampleStatusPersister.persist(examples, filename)
17
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
18
49
  end
19
50
  end
20
51
  end
@@ -46,8 +46,6 @@ module RSpec
46
46
  @formatter = @formatter_class.new(worker_count: @worker_count)
47
47
  @suite_run = SuiteRun.new
48
48
 
49
- $stdout.sync = true
50
- $stdin.echo = false if $stdin.tty?
51
49
  Dir.chdir(Conductor.root)
52
50
  ENV["PARALLEL_TEST_GROUPS"] = worker_count.to_s # parallel_tests backward-compatibility
53
51
  end
@@ -93,10 +91,26 @@ module RSpec
93
91
  config_options.configure(config)
94
92
  debug "RSpec config: #{config.inspect}"
95
93
  debug "Files to run: #{config.files_to_run}"
96
- @spec_queue = config.files_to_run.shuffle(random: Random.new(@seed))
94
+ @spec_queue = ordered_files_to_run(config)
97
95
  @suite_run.spec_files_total = @spec_queue.size
98
96
  end
99
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
+
100
114
  def preload_application
101
115
  if !@prefork_require
102
116
  debug "Prefork require not set, skipping..."
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Conductor
5
- VERSION = "1.0.12"
5
+ VERSION = "1.0.13"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Abramov