knapsack_pro 7.13.1 → 7.14.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 199f5a710b27c9e76985316a9ac5dfeb95b6f7970a9246f26cdfaee8fb06adcd
4
- data.tar.gz: 2b3421149a4284e32abf8f3351e6efafac9fc2bcd26a0225228b6f1a1ba5753d
3
+ metadata.gz: 113e9ca31d058ab9623d6a0bb278768ad0a864db8bb8776440d00ceb2a648b37
4
+ data.tar.gz: '084be6d88bf072c8ece112b3de2a6707b240816e993f039701cd68e7920f7988'
5
5
  SHA512:
6
- metadata.gz: 983ffb0e290dba0d7a3e93bcf025fa0fd380e9457bc9c93c477783386c79dfeb1195a726f1513aea2970c882c46621d929e5ad204e343afa81eaa9ca73906790
7
- data.tar.gz: 3f5031d341b563fbf231e38506c70521fc3cbd3b7ff55a529c725491b330cbd7bed105fbd6540c97fe76842d6c84b63dbaf8369937a4cbddb10ebde754ec6a1a
6
+ metadata.gz: 97015f7b3db931f3a9f68e7ef59aecb99f0befa5202b148d5aa56736d256048c842c00babc265c47c583534f2a0dafc488c49b748b4b3084f93a2d42f6013d84
7
+ data.tar.gz: 62fd8be74b14f402840ea4b9b6866a9ac008daa09d279e2cee21bd3f513d8f746f635c770c83e65db36139aa6e9ebb362301794e6aad70a9d59796dd86167d90
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ### 7.14.0
4
+
5
+ * Improve debugging for hanging CI nodes: show hanging spec files in the RSpec output and a command to reproduce the current batch of tests.
6
+
7
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/287
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.13.1...v7.14.0
10
+
3
11
  ### 7.13.1
4
12
 
5
13
  * Fix handling signals for non-RSpec test runners
@@ -77,6 +77,8 @@ module KnapsackPro
77
77
  puts 'Use the following backtrace(s) to find the line of code that got stuck if the CI node hung and terminated your tests.'
78
78
  puts 'How to read the backtrace: https://knapsackpro.com/perma/ruby/backtrace-debugging'
79
79
 
80
+ log_current_tests(threads)
81
+
80
82
  threads.each do |thread|
81
83
  puts
82
84
  if thread == Thread.main
@@ -95,6 +97,10 @@ module KnapsackPro
95
97
 
96
98
  $stdout.flush
97
99
  end
100
+
101
+ def log_current_tests(threads)
102
+ # implement in a child class if you need to log more info
103
+ end
98
104
  end
99
105
  end
100
106
  end
@@ -119,6 +119,27 @@ module KnapsackPro
119
119
 
120
120
  def post_trap_signals
121
121
  RSpec.world.wants_to_quit = true
122
+
123
+ log_current_batch_rspec_command
124
+ end
125
+
126
+ def log_current_tests(threads)
127
+ threads.each do |thread|
128
+ next unless thread.backtrace
129
+
130
+ spec_file_lines = thread.backtrace.select { |line| line.include?('_spec.rb') }
131
+ next if spec_file_lines.empty?
132
+
133
+ puts
134
+ if thread == Thread.main
135
+ puts "Running specs in the main thread:"
136
+ else
137
+ puts "Non-main thread inspect: #{thread.inspect}"
138
+ puts "Running specs in non-main thread:"
139
+ end
140
+ puts spec_file_lines.join("\n")
141
+ puts
142
+ end
122
143
  end
123
144
 
124
145
  def pre_run_setup
@@ -165,6 +186,21 @@ module KnapsackPro
165
186
  test_file_paths
166
187
  end
167
188
 
189
+ def log_current_batch_rspec_command
190
+ test_file_paths = @queue.current_batch&.test_file_paths
191
+ return unless test_file_paths
192
+
193
+ puts
194
+ puts '=' * 80
195
+
196
+ order_option = @adapter_class.order_option(@cli_args)
197
+ printable_args = @rspec_pure.args_with_seed_option_added_when_viable(order_option, @rspec_runner.knapsack__seed, @cli_args)
198
+ messages = @rspec_pure.rspec_command(printable_args, test_file_paths, :batch_finished)
199
+ messages.each do |message|
200
+ puts message
201
+ end
202
+ end
203
+
168
204
  def log_rspec_batch_command(test_file_paths)
169
205
  order_option = @adapter_class.order_option(@cli_args)
170
206
  printable_args = @rspec_pure.args_with_seed_option_added_when_viable(order_option, @rspec_runner.knapsack__seed, @cli_args)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KnapsackPro
4
- VERSION = '7.13.1'
4
+ VERSION = '7.14.0'
5
5
  end
@@ -1403,12 +1403,16 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
1403
1403
  OUTPUT
1404
1404
  )
1405
1405
 
1406
+ expect(actual.stdout).to include('To retry the last batch of tests fetched from the Queue API, please run the following command on your machine:')
1407
+ expect(actual.stdout).to include('bundle exec rspec --format documentation --default-path spec_integration "spec_integration/b_spec.rb" "spec_integration/c_spec.rb"')
1406
1408
 
1407
1409
  expect(actual.stdout).to include('Use the following backtrace(s) to find the line of code that got stuck if the CI node hung and terminated your tests.')
1410
+ expect(actual.stdout).to include('Running specs in the main thread:')
1411
+ expect(actual.stdout).to include('Running specs in non-main thread:')
1408
1412
  expect(actual.stdout).to include('Main thread backtrace:')
1409
- expect(actual.stdout).to match(/spec_integration\/b_spec\.rb:7:in .*kill/)
1413
+ expect(actual.stdout.scan(/spec_integration\/b_spec\.rb:7:in .*kill/).size).to eq 2
1410
1414
  expect(actual.stdout).to include('Non-main thread backtrace:')
1411
- expect(actual.stdout).to match(/spec_integration\/a_spec\.rb:6:in .*sleep/)
1415
+ expect(actual.stdout.scan(/spec_integration\/a_spec\.rb:6:in .*sleep/).size).to eq 2
1412
1416
 
1413
1417
 
1414
1418
  expect(actual.exit_code).to eq 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.13.1
4
+ version: 7.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-04 00:00:00.000000000 Z
11
+ date: 2025-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake