class KnapsackPro::Runners::Queue::BaseRunner
Constants
- TERMINATION_SIGNALS
- TerminationError
Attributes
Public Class Methods
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 41 def self.child_status $? end
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 45 def self.handle_signal! raise TerminationError.new('Knapsack Pro process was terminated!') if @@terminate_process end
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 20 def initialize(adapter_class) @allocator_builder = KnapsackPro::QueueAllocatorBuilder.new(adapter_class) @allocator = allocator_builder.allocator trap_signals end
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 12 def self.run(args) raise NotImplementedError end
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 16 def self.run_tests(runner, can_initialize_queue, args, exitstatus) raise NotImplementedError end
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 49 def self.set_terminate_process @@terminate_process = true end
Public Instance Methods
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 32 def test_dir allocator_builder.test_dir end
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 26 def test_file_paths(args) can_initialize_queue = args.fetch(:can_initialize_queue) executed_test_files = args.fetch(:executed_test_files) allocator.test_file_paths(can_initialize_queue, executed_test_files) end
Private Instance Methods
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 101 def log_current_tests(threads) # implement in a child class if you need to log more info end
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 71 def log_threads threads = Thread.list puts puts '=' * 80 puts "Start logging #{threads.count} detected 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' log_current_tests(threads) threads.each do |thread| puts if thread == Thread.main puts "Main thread backtrace:" else puts "Non-main thread inspect: #{thread.inspect}" puts "Non-main thread backtrace:" end puts thread.backtrace&.join("\n") puts end puts puts 'End logging threads.' puts '=' * 80 $stdout.flush end
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 68 def post_trap_signals end
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 53 def set_terminate_process self.class.set_terminate_process end
Source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 57 def trap_signals TERMINATION_SIGNALS.each do |signal| Signal.trap(signal) { puts "#{signal} signal has been received. Terminating Knapsack Pro..." @@terminate_process = true post_trap_signals log_threads } end end