class KnapsackPro::Runners::Queue::BaseRunner
Constants
- TERMINATION_SIGNALS
- TerminationError
Attributes
allocator[R]
allocator_builder[R]
Public Class Methods
child_status()
click to toggle source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 41 def self.child_status $? end
handle_signal!()
click to toggle 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
new(adapter_class)
click to toggle 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
run(args)
click to toggle source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 12 def self.run(args) raise NotImplementedError end
run_tests(runner, can_initialize_queue, args, exitstatus)
click to toggle 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
set_terminate_process()
click to toggle source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 49 def self.set_terminate_process @@terminate_process = true end
Public Instance Methods
test_dir()
click to toggle source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 32 def test_dir allocator_builder.test_dir end
test_file_paths(args)
click to toggle 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
log_threads()
click to toggle source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 68 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' 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
set_terminate_process()
click to toggle source
# File lib/knapsack_pro/runners/queue/base_runner.rb, line 53 def set_terminate_process self.class.set_terminate_process end
trap_signals()
click to toggle 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 RSpec.world.wants_to_quit = true log_threads } end end