From d8cefe73c6f431cc4bd062d30eb6d42cfbb0fc99 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 20 Jan 2025 21:11:28 +0100 Subject: [PATCH 01/15] feat(RSpec): show a line number for hanging specs --- lib/knapsack_pro/runners/queue/base_runner.rb | 5 +++++ .../runners/queue/rspec_runner.rb | 20 +++++++++++++++++++ .../runners/queue/rspec_runner_spec.rb | 7 +++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/knapsack_pro/runners/queue/base_runner.rb b/lib/knapsack_pro/runners/queue/base_runner.rb index 6d7c15a2..1786c91a 100644 --- a/lib/knapsack_pro/runners/queue/base_runner.rb +++ b/lib/knapsack_pro/runners/queue/base_runner.rb @@ -77,6 +77,8 @@ def log_threads puts 'Use the following backtrace(s) to find the line of code that got stuck if the CI node hung and terminated your tests.' puts 'How to read the backtrace: https://knapsackpro.com/perma/ruby/backtrace-debugging' + post_log_threads(threads) + threads.each do |thread| puts if thread == Thread.main @@ -95,6 +97,9 @@ def log_threads $stdout.flush end + + def post_log_threads + end end end end diff --git a/lib/knapsack_pro/runners/queue/rspec_runner.rb b/lib/knapsack_pro/runners/queue/rspec_runner.rb index 0175e21c..902ab292 100644 --- a/lib/knapsack_pro/runners/queue/rspec_runner.rb +++ b/lib/knapsack_pro/runners/queue/rspec_runner.rb @@ -121,6 +121,26 @@ def post_trap_signals RSpec.world.wants_to_quit = true end + def post_log_threads(threads) + threads.each do |thread| + next unless thread.backtrace + + spec_file_lines = thread.backtrace.select { |line| line.include?('_spec.rb') } + + unless spec_file_lines.empty? + puts + if thread == Thread.main + puts "Hanging specs in the main thread:" + else + puts "Non-main thread inspect: #{thread.inspect}" + puts "Hanging specs in non-main thread:" + end + puts spec_file_lines.join("\n") + puts + end + end + end + def pre_run_setup ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] = 'true' ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id diff --git a/spec/integration/runners/queue/rspec_runner_spec.rb b/spec/integration/runners/queue/rspec_runner_spec.rb index 3a948c8d..2d487a39 100644 --- a/spec/integration/runners/queue/rspec_runner_spec.rb +++ b/spec/integration/runners/queue/rspec_runner_spec.rb @@ -1405,10 +1405,13 @@ def when_first_matching_example_defined(type:) 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.') + expect(actual.stdout).to include('Hanging specs in the main thread:') + expect(actual.stdout).to include('Hanging specs in non-main thread:') expect(actual.stdout).to include('Main thread backtrace:') - expect(actual.stdout).to match(/spec_integration\/b_spec\.rb:7:in .*kill/) + expect(actual.stdout.scan(/spec_integration\/b_spec\.rb:7:in .*kill/).size).to eq 2 + expect(actual.stdout).to include('Hanging specs in the main thread:') expect(actual.stdout).to include('Non-main thread backtrace:') - expect(actual.stdout).to match(/spec_integration\/a_spec\.rb:6:in .*sleep/) + expect(actual.stdout.scan(/spec_integration\/a_spec\.rb:6:in .*sleep/).size).to eq 2 expect(actual.exit_code).to eq 1 From fee498a56e05fe3568b4eaf240bc188833edd761 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 20 Jan 2025 21:34:26 +0100 Subject: [PATCH 02/15] feat(RSpec): print current batch RSpec command for hanging node --- lib/knapsack_pro/runners/queue/rspec_runner.rb | 17 +++++++++++++++++ .../runners/queue/rspec_runner_spec.rb | 2 ++ 2 files changed, 19 insertions(+) diff --git a/lib/knapsack_pro/runners/queue/rspec_runner.rb b/lib/knapsack_pro/runners/queue/rspec_runner.rb index 902ab292..30a358a8 100644 --- a/lib/knapsack_pro/runners/queue/rspec_runner.rb +++ b/lib/knapsack_pro/runners/queue/rspec_runner.rb @@ -119,6 +119,8 @@ def log_fail_fast_limit_met def post_trap_signals RSpec.world.wants_to_quit = true + + print_current_rspec_batch_command end def post_log_threads(threads) @@ -185,6 +187,21 @@ def pull_tests_from_queue(can_initialize_queue: false) test_file_paths end + def print_current_rspec_batch_command + test_file_paths = @queue.current_batch&.test_file_paths + return unless test_file_paths + + puts + puts '=' * 80 + + order_option = @adapter_class.order_option(@cli_args) + printable_args = @rspec_pure.args_with_seed_option_added_when_viable(order_option, @rspec_runner.knapsack__seed, @cli_args) + messages = @rspec_pure.rspec_command(printable_args, test_file_paths, :batch_finished) + messages.each do |message| + puts message + end + end + def log_rspec_batch_command(test_file_paths) order_option = @adapter_class.order_option(@cli_args) printable_args = @rspec_pure.args_with_seed_option_added_when_viable(order_option, @rspec_runner.knapsack__seed, @cli_args) diff --git a/spec/integration/runners/queue/rspec_runner_spec.rb b/spec/integration/runners/queue/rspec_runner_spec.rb index 2d487a39..9d99c787 100644 --- a/spec/integration/runners/queue/rspec_runner_spec.rb +++ b/spec/integration/runners/queue/rspec_runner_spec.rb @@ -1403,6 +1403,8 @@ def when_first_matching_example_defined(type:) OUTPUT ) + 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:') + expect(actual.stdout).to include('bundle exec rspec --format documentation --default-path spec_integration "spec_integration/b_spec.rb" "spec_integration/c_spec.rb"') 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.') expect(actual.stdout).to include('Hanging specs in the main thread:') From 430253aeea98d2883628382af38b8cf2db692e39 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 20 Jan 2025 21:56:00 +0100 Subject: [PATCH 03/15] wip: print Randomized with seed 123 at the top of the output --- lib/knapsack_pro/extensions/rspec_extension.rb | 9 +++++++++ lib/knapsack_pro/runners/queue/rspec_runner.rb | 2 ++ spec/integration/runners/queue/rspec_runner_spec.rb | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/knapsack_pro/extensions/rspec_extension.rb b/lib/knapsack_pro/extensions/rspec_extension.rb index 6fe9adcb..c0b0caca 100644 --- a/lib/knapsack_pro/extensions/rspec_extension.rb +++ b/lib/knapsack_pro/extensions/rspec_extension.rb @@ -13,6 +13,15 @@ def self.setup! RSpec::Core::Configuration.prepend(Configuration) end + # Based on: + # https://github.com/rspec/rspec/blob/5946b3c9aa61279bf52363bfde4d850810daaa3a/rspec-core/lib/rspec/core/notifications.rb#L283 + def self.print_seed(seed) + puts '+'*50 + puts seed.inspect + return unless seed.used? + puts "\nRandomized with seed #{seed.value}\n" + end + module World # Based on: # https://github.com/rspec/rspec-core/blob/f8c8880dabd8f0544a6f91d8d4c857c1bd8df903/lib/rspec/core/world.rb#L171 diff --git a/lib/knapsack_pro/runners/queue/rspec_runner.rb b/lib/knapsack_pro/runners/queue/rspec_runner.rb index 30a358a8..9ae0fd04 100644 --- a/lib/knapsack_pro/runners/queue/rspec_runner.rb +++ b/lib/knapsack_pro/runners/queue/rspec_runner.rb @@ -157,6 +157,8 @@ def pre_run_setup @rspec_runner.knapsack__setup(@stream_error, @stream_out) ensure_no_deprecated_run_all_when_everything_filtered_option! + + KnapsackPro::Extensions::RSpecExtension.print_seed(@rspec_runner.knapsack__seed) end def post_run_tasks(exit_code) diff --git a/spec/integration/runners/queue/rspec_runner_spec.rb b/spec/integration/runners/queue/rspec_runner_spec.rb index 9d99c787..953bf38b 100644 --- a/spec/integration/runners/queue/rspec_runner_spec.rb +++ b/spec/integration/runners/queue/rspec_runner_spec.rb @@ -90,7 +90,7 @@ def log(stdout, stderr, status) ENV['KNAPSACK_PRO_LOG_LEVEL'] = 'debug' # Useful when creating or editing a test: - # ENV['TEST__SHOW_DEBUG_LOG'] = 'true' + ENV['TEST__SHOW_DEBUG_LOG'] = 'true' end after do FileUtils.rm_rf(SPEC_DIRECTORY) @@ -914,7 +914,7 @@ def when_first_matching_example_defined(type:) actual = subject - expect(actual.stdout).to include('Randomized with seed 123') + expect(actual.stdout.scan(/Randomized with seed 123/).size).to eq 2 # 1st batch expect(actual.stdout).to include('INFO -- : [knapsack_pro] bundle exec rspec --order rand:123 --format progress --default-path spec_integration "spec_integration/a_spec.rb" "spec_integration/b_spec.rb"') From 4d87e93aecbafe18967a465f3428d0f771292ef2 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 20 Jan 2025 21:56:05 +0100 Subject: [PATCH 04/15] Revert "wip: print Randomized with seed 123 at the top of the output" This reverts commit 430253aeea98d2883628382af38b8cf2db692e39. --- lib/knapsack_pro/extensions/rspec_extension.rb | 9 --------- lib/knapsack_pro/runners/queue/rspec_runner.rb | 2 -- spec/integration/runners/queue/rspec_runner_spec.rb | 4 ++-- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/knapsack_pro/extensions/rspec_extension.rb b/lib/knapsack_pro/extensions/rspec_extension.rb index c0b0caca..6fe9adcb 100644 --- a/lib/knapsack_pro/extensions/rspec_extension.rb +++ b/lib/knapsack_pro/extensions/rspec_extension.rb @@ -13,15 +13,6 @@ def self.setup! RSpec::Core::Configuration.prepend(Configuration) end - # Based on: - # https://github.com/rspec/rspec/blob/5946b3c9aa61279bf52363bfde4d850810daaa3a/rspec-core/lib/rspec/core/notifications.rb#L283 - def self.print_seed(seed) - puts '+'*50 - puts seed.inspect - return unless seed.used? - puts "\nRandomized with seed #{seed.value}\n" - end - module World # Based on: # https://github.com/rspec/rspec-core/blob/f8c8880dabd8f0544a6f91d8d4c857c1bd8df903/lib/rspec/core/world.rb#L171 diff --git a/lib/knapsack_pro/runners/queue/rspec_runner.rb b/lib/knapsack_pro/runners/queue/rspec_runner.rb index 9ae0fd04..30a358a8 100644 --- a/lib/knapsack_pro/runners/queue/rspec_runner.rb +++ b/lib/knapsack_pro/runners/queue/rspec_runner.rb @@ -157,8 +157,6 @@ def pre_run_setup @rspec_runner.knapsack__setup(@stream_error, @stream_out) ensure_no_deprecated_run_all_when_everything_filtered_option! - - KnapsackPro::Extensions::RSpecExtension.print_seed(@rspec_runner.knapsack__seed) end def post_run_tasks(exit_code) diff --git a/spec/integration/runners/queue/rspec_runner_spec.rb b/spec/integration/runners/queue/rspec_runner_spec.rb index 953bf38b..9d99c787 100644 --- a/spec/integration/runners/queue/rspec_runner_spec.rb +++ b/spec/integration/runners/queue/rspec_runner_spec.rb @@ -90,7 +90,7 @@ def log(stdout, stderr, status) ENV['KNAPSACK_PRO_LOG_LEVEL'] = 'debug' # Useful when creating or editing a test: - ENV['TEST__SHOW_DEBUG_LOG'] = 'true' + # ENV['TEST__SHOW_DEBUG_LOG'] = 'true' end after do FileUtils.rm_rf(SPEC_DIRECTORY) @@ -914,7 +914,7 @@ def when_first_matching_example_defined(type:) actual = subject - expect(actual.stdout.scan(/Randomized with seed 123/).size).to eq 2 + expect(actual.stdout).to include('Randomized with seed 123') # 1st batch expect(actual.stdout).to include('INFO -- : [knapsack_pro] bundle exec rspec --order rand:123 --format progress --default-path spec_integration "spec_integration/a_spec.rb" "spec_integration/b_spec.rb"') From 01829cfb7d1f0565e0d1f733758b2dd0b62d13a3 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 20 Jan 2025 22:01:13 +0100 Subject: [PATCH 05/15] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f38fdc3..7fc75ede 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +### 7.14.0 + +* Improve debugging for hanging CI node. Show hanging spec files in the RSpec output and a command to reproduce the current batch of tests. + + https://github.com/KnapsackPro/knapsack_pro-ruby/pull/287 + +https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.13.1...v7.14.0 + ### 7.13.1 * Fix handling signals for non-RSpec test runners From 6a6148a3f005a97acea078b530f73752e78f314e Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Mon, 20 Jan 2025 22:27:41 +0100 Subject: [PATCH 06/15] guard clause --- .../runners/queue/rspec_runner.rb | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/knapsack_pro/runners/queue/rspec_runner.rb b/lib/knapsack_pro/runners/queue/rspec_runner.rb index 30a358a8..371203a4 100644 --- a/lib/knapsack_pro/runners/queue/rspec_runner.rb +++ b/lib/knapsack_pro/runners/queue/rspec_runner.rb @@ -128,18 +128,17 @@ def post_log_threads(threads) next unless thread.backtrace spec_file_lines = thread.backtrace.select { |line| line.include?('_spec.rb') } - - unless spec_file_lines.empty? - puts - if thread == Thread.main - puts "Hanging specs in the main thread:" - else - puts "Non-main thread inspect: #{thread.inspect}" - puts "Hanging specs in non-main thread:" - end - puts spec_file_lines.join("\n") - puts + next if spec_file_lines.empty? + + puts + if thread == Thread.main + puts "Hanging specs in the main thread:" + else + puts "Non-main thread inspect: #{thread.inspect}" + puts "Hanging specs in non-main thread:" end + puts spec_file_lines.join("\n") + puts end end From 34d6ca5667d49e46878e10798a8b0ff74e636613 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 23 Jan 2025 14:28:54 +0100 Subject: [PATCH 07/15] add the missing argument to post_log_threads & comment --- lib/knapsack_pro/runners/queue/base_runner.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/knapsack_pro/runners/queue/base_runner.rb b/lib/knapsack_pro/runners/queue/base_runner.rb index 1786c91a..f3d58ba7 100644 --- a/lib/knapsack_pro/runners/queue/base_runner.rb +++ b/lib/knapsack_pro/runners/queue/base_runner.rb @@ -98,7 +98,8 @@ def log_threads $stdout.flush end - def post_log_threads + def post_log_threads(threads) + # implement in a child class if you need to log more info end end end From 42c6aec6d0f9e53981025892e753700710f74066 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 23 Jan 2025 14:38:11 +0100 Subject: [PATCH 08/15] refactor: use the log_current_tests method name --- lib/knapsack_pro/runners/queue/base_runner.rb | 4 ++-- lib/knapsack_pro/runners/queue/rspec_runner.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/knapsack_pro/runners/queue/base_runner.rb b/lib/knapsack_pro/runners/queue/base_runner.rb index f3d58ba7..42cb0a25 100644 --- a/lib/knapsack_pro/runners/queue/base_runner.rb +++ b/lib/knapsack_pro/runners/queue/base_runner.rb @@ -77,7 +77,7 @@ def log_threads puts 'Use the following backtrace(s) to find the line of code that got stuck if the CI node hung and terminated your tests.' puts 'How to read the backtrace: https://knapsackpro.com/perma/ruby/backtrace-debugging' - post_log_threads(threads) + log_current_tests(threads) threads.each do |thread| puts @@ -98,7 +98,7 @@ def log_threads $stdout.flush end - def post_log_threads(threads) + def log_current_tests(threads) # implement in a child class if you need to log more info end end diff --git a/lib/knapsack_pro/runners/queue/rspec_runner.rb b/lib/knapsack_pro/runners/queue/rspec_runner.rb index 371203a4..f0fa1e98 100644 --- a/lib/knapsack_pro/runners/queue/rspec_runner.rb +++ b/lib/knapsack_pro/runners/queue/rspec_runner.rb @@ -123,7 +123,7 @@ def post_trap_signals print_current_rspec_batch_command end - def post_log_threads(threads) + def log_current_tests(threads) threads.each do |thread| next unless thread.backtrace From 330ad70a03582287e9f7402b5aa321f3f7c68ffc Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 23 Jan 2025 14:40:00 +0100 Subject: [PATCH 09/15] rename to print_current_batch_rspec_command --- lib/knapsack_pro/runners/queue/rspec_runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/knapsack_pro/runners/queue/rspec_runner.rb b/lib/knapsack_pro/runners/queue/rspec_runner.rb index f0fa1e98..86131194 100644 --- a/lib/knapsack_pro/runners/queue/rspec_runner.rb +++ b/lib/knapsack_pro/runners/queue/rspec_runner.rb @@ -120,7 +120,7 @@ def log_fail_fast_limit_met def post_trap_signals RSpec.world.wants_to_quit = true - print_current_rspec_batch_command + print_current_batch_rspec_command end def log_current_tests(threads) @@ -186,7 +186,7 @@ def pull_tests_from_queue(can_initialize_queue: false) test_file_paths end - def print_current_rspec_batch_command + def print_current_batch_rspec_command test_file_paths = @queue.current_batch&.test_file_paths return unless test_file_paths From 3923837578b80d6033d2d5949ec2e6ad43a5461f Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 23 Jan 2025 14:51:24 +0100 Subject: [PATCH 10/15] use: Running --- lib/knapsack_pro/runners/queue/rspec_runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/knapsack_pro/runners/queue/rspec_runner.rb b/lib/knapsack_pro/runners/queue/rspec_runner.rb index 86131194..a66e2798 100644 --- a/lib/knapsack_pro/runners/queue/rspec_runner.rb +++ b/lib/knapsack_pro/runners/queue/rspec_runner.rb @@ -132,10 +132,10 @@ def log_current_tests(threads) puts if thread == Thread.main - puts "Hanging specs in the main thread:" + puts "Running specs in the main thread:" else puts "Non-main thread inspect: #{thread.inspect}" - puts "Hanging specs in non-main thread:" + puts "Running specs in non-main thread:" end puts spec_file_lines.join("\n") puts From 1ca80b5d98fa3f4663bf093643c1d8b6857e84e1 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 23 Jan 2025 14:52:19 +0100 Subject: [PATCH 11/15] Apply suggestions from code review Co-authored-by: Riccardo --- spec/integration/runners/queue/rspec_runner_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/integration/runners/queue/rspec_runner_spec.rb b/spec/integration/runners/queue/rspec_runner_spec.rb index 9d99c787..ea9e3c5e 100644 --- a/spec/integration/runners/queue/rspec_runner_spec.rb +++ b/spec/integration/runners/queue/rspec_runner_spec.rb @@ -1410,10 +1410,10 @@ def when_first_matching_example_defined(type:) expect(actual.stdout).to include('Hanging specs in the main thread:') expect(actual.stdout).to include('Hanging specs in non-main thread:') expect(actual.stdout).to include('Main thread backtrace:') - expect(actual.stdout.scan(/spec_integration\/b_spec\.rb:7:in .*kill/).size).to eq 2 + expect(actual.stdout).to match(/spec_integration\/b_spec\.rb:7:in .*kill/).twice expect(actual.stdout).to include('Hanging specs in the main thread:') expect(actual.stdout).to include('Non-main thread backtrace:') - expect(actual.stdout.scan(/spec_integration\/a_spec\.rb:6:in .*sleep/).size).to eq 2 + expect(actual.stdout).to match(/spec_integration\/a_spec\.rb:6:in .*sleep/).twice expect(actual.exit_code).to eq 1 From 35004e79d549e4480fbd62392ee5c9e8de95211f Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 23 Jan 2025 14:55:07 +0100 Subject: [PATCH 12/15] Update rspec_runner_spec.rb --- spec/integration/runners/queue/rspec_runner_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/integration/runners/queue/rspec_runner_spec.rb b/spec/integration/runners/queue/rspec_runner_spec.rb index 9d99c787..96af0bdf 100644 --- a/spec/integration/runners/queue/rspec_runner_spec.rb +++ b/spec/integration/runners/queue/rspec_runner_spec.rb @@ -1407,11 +1407,10 @@ def when_first_matching_example_defined(type:) expect(actual.stdout).to include('bundle exec rspec --format documentation --default-path spec_integration "spec_integration/b_spec.rb" "spec_integration/c_spec.rb"') 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.') - expect(actual.stdout).to include('Hanging specs in the main thread:') - expect(actual.stdout).to include('Hanging specs in non-main thread:') + expect(actual.stdout).to include('Running specs in the main thread:') + expect(actual.stdout).to include('Running specs in non-main thread:') expect(actual.stdout).to include('Main thread backtrace:') expect(actual.stdout.scan(/spec_integration\/b_spec\.rb:7:in .*kill/).size).to eq 2 - expect(actual.stdout).to include('Hanging specs in the main thread:') expect(actual.stdout).to include('Non-main thread backtrace:') expect(actual.stdout.scan(/spec_integration\/a_spec\.rb:6:in .*sleep/).size).to eq 2 From 8980e8d5f0f0f9394e7413b09b7ae2708cfe07f6 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 23 Jan 2025 14:59:03 +0100 Subject: [PATCH 13/15] revert twice on match to fix spec Failure/Error: expect(actual.stdout).to match(/spec_integration\/b_spec\.rb:7:in .*kill/).twice NoMethodError: undefined method `twice' for an instance of RSpec::Matchers::BuiltIn::Match --- spec/integration/runners/queue/rspec_runner_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/integration/runners/queue/rspec_runner_spec.rb b/spec/integration/runners/queue/rspec_runner_spec.rb index 57471dba..96af0bdf 100644 --- a/spec/integration/runners/queue/rspec_runner_spec.rb +++ b/spec/integration/runners/queue/rspec_runner_spec.rb @@ -1410,9 +1410,9 @@ def when_first_matching_example_defined(type:) expect(actual.stdout).to include('Running specs in the main thread:') expect(actual.stdout).to include('Running specs in non-main thread:') expect(actual.stdout).to include('Main thread backtrace:') - expect(actual.stdout).to match(/spec_integration\/b_spec\.rb:7:in .*kill/).twice + expect(actual.stdout.scan(/spec_integration\/b_spec\.rb:7:in .*kill/).size).to eq 2 expect(actual.stdout).to include('Non-main thread backtrace:') - expect(actual.stdout).to match(/spec_integration\/a_spec\.rb:6:in .*sleep/).twice + expect(actual.stdout.scan(/spec_integration\/a_spec\.rb:6:in .*sleep/).size).to eq 2 expect(actual.exit_code).to eq 1 From 83e72aeb45e8e8812140ec8c6e85413954c1cc19 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 23 Jan 2025 15:52:45 +0100 Subject: [PATCH 14/15] Update CHANGELOG.md Co-authored-by: Riccardo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fc75ede..4c8dade2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### 7.14.0 -* Improve debugging for hanging CI node. Show hanging spec files in the RSpec output and a command to reproduce the current batch of tests. +* Improve debugging for hanging CI nodes: show hanging spec files in the RSpec output and a command to reproduce the current batch of tests. https://github.com/KnapsackPro/knapsack_pro-ruby/pull/287 From 09ac671a4a85021b332407b316317894d92a3162 Mon Sep 17 00:00:00 2001 From: Artur Trzop Date: Thu, 23 Jan 2025 15:54:43 +0100 Subject: [PATCH 15/15] rename print_current_batch_rspec_command to log_current_batch_rspec_command --- lib/knapsack_pro/runners/queue/rspec_runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/knapsack_pro/runners/queue/rspec_runner.rb b/lib/knapsack_pro/runners/queue/rspec_runner.rb index a66e2798..b960150f 100644 --- a/lib/knapsack_pro/runners/queue/rspec_runner.rb +++ b/lib/knapsack_pro/runners/queue/rspec_runner.rb @@ -120,7 +120,7 @@ def log_fail_fast_limit_met def post_trap_signals RSpec.world.wants_to_quit = true - print_current_batch_rspec_command + log_current_batch_rspec_command end def log_current_tests(threads) @@ -186,7 +186,7 @@ def pull_tests_from_queue(can_initialize_queue: false) test_file_paths end - def print_current_batch_rspec_command + def log_current_batch_rspec_command test_file_paths = @queue.current_batch&.test_file_paths return unless test_file_paths