Class: FlakeySpecCatcher::Runner
- Inherits:
-
Object
- Object
- FlakeySpecCatcher::Runner
- Defined in:
- lib/flakey_spec_catcher/runner.rb
Instance Attribute Summary collapse
-
#git_controller ⇒ Object
readonly
Returns the value of attribute git_controller.
-
#random_dates ⇒ Object
readonly
Returns the value of attribute random_dates.
-
#rerun_manager ⇒ Object
readonly
Returns the value of attribute rerun_manager.
-
#test_run_count ⇒ Object
readonly
Returns the value of attribute test_run_count.
-
#user_config ⇒ Object
readonly
Returns the value of attribute user_config.
Instance Method Summary collapse
-
#initialize(test_mode: false, user_config: FlakeySpecCatcher::UserConfig.new, git_controller: FlakeySpecCatcher::GitController.new(test_mode: test_mode, user_config: user_config), result_manager: FlakeySpecCatcher::RspecResultManager.new(FlakeySpecCatcher::RspecResult), rerun_manager: FlakeySpecCatcher::RerunManager.new(git_controller: git_controller, user_config: user_config)) ⇒ Runner
constructor
A new instance of Runner.
-
#rerun_preview ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity.
- #run_specs ⇒ Object
-
#show_settings ⇒ Object
Debug Methods rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity.
-
#show_test_list ⇒ Object
end Debug methods.
Constructor Details
#initialize(test_mode: false, user_config: FlakeySpecCatcher::UserConfig.new, git_controller: FlakeySpecCatcher::GitController.new(test_mode: test_mode, user_config: user_config), result_manager: FlakeySpecCatcher::RspecResultManager.new(FlakeySpecCatcher::RspecResult), rerun_manager: FlakeySpecCatcher::RerunManager.new(git_controller: git_controller, user_config: user_config)) ⇒ Runner
Returns a new instance of Runner.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/flakey_spec_catcher/runner.rb', line 16 def initialize(test_mode: false, user_config: FlakeySpecCatcher::UserConfig.new, git_controller: FlakeySpecCatcher::GitController.new(test_mode: test_mode, user_config: user_config), result_manager: FlakeySpecCatcher::RspecResultManager.new(FlakeySpecCatcher::RspecResult), rerun_manager: FlakeySpecCatcher::RerunManager.new(git_controller: git_controller, user_config: user_config)) @git_controller = git_controller @user_config = user_config @rerun_manager = rerun_manager @rspec_result_manager = result_manager @test_run_count = 0 @temp_output_file = @user_config.output_file + 'temp' unless @user_config.output_file == File::NULL enable_random_timing end |
Instance Attribute Details
#git_controller ⇒ Object (readonly)
Returns the value of attribute git_controller.
14 15 16 |
# File 'lib/flakey_spec_catcher/runner.rb', line 14 def git_controller @git_controller end |
#random_dates ⇒ Object (readonly)
Returns the value of attribute random_dates.
14 15 16 |
# File 'lib/flakey_spec_catcher/runner.rb', line 14 def random_dates @random_dates end |
#rerun_manager ⇒ Object (readonly)
Returns the value of attribute rerun_manager.
14 15 16 |
# File 'lib/flakey_spec_catcher/runner.rb', line 14 def rerun_manager @rerun_manager end |
#test_run_count ⇒ Object (readonly)
Returns the value of attribute test_run_count.
14 15 16 |
# File 'lib/flakey_spec_catcher/runner.rb', line 14 def test_run_count @test_run_count end |
#user_config ⇒ Object (readonly)
Returns the value of attribute user_config.
14 15 16 |
# File 'lib/flakey_spec_catcher/runner.rb', line 14 def user_config @user_config end |
Instance Method Details
#rerun_preview ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/flakey_spec_catcher/runner.rb', line 51 def rerun_preview puts "\n********************************************" puts "Re-run Preview\n" @rerun_manager.rerun_capsules.each do |capsule| capsule.testcase.each do |test| rerun_msg = " Running #{test} #{@user_config.repeat_factor} times " rerun_msg += "using `#{capsule.usage}`" unless capsule.default_usage? puts rerun_msg end end puts "\n********************************************" end |
#run_specs ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/flakey_spec_catcher/runner.rb', line 73 def run_specs return 0 if @user_config.dry_run status = 0 @rerun_manager.rerun_capsules.sort.each do |capsule| @user_config.repeat_factor.times do |iteration| iteration_status = timecop_wrapper(capsule, iteration) status = [status, iteration_status].max break if @user_config.break_on_first_failure && !status.zero? end end display_results(status) copy_to_user_output unless @user_config.output_file == File::NULL # Always return 0 if silent_mode is enabled @user_config.silent_mode ? 0 : status end |
#show_settings ⇒ Object
Debug Methods rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/flakey_spec_catcher/runner.rb', line 33 def show_settings puts 'Flakey Spec Catcher Settings:' puts " Current Branch: #{@git_controller.branch}" unless @user_config.use_parent puts " Remote: #{@git_controller.remote}" unless @user_config.use_parent puts " Current Sha: #{@git_controller.working_commit_sha}" puts " Base Sha: #{@git_controller.base_commit_sha}" puts " Repeat factor: #{@user_config.repeat_factor}" puts " Break on first failure: #{@user_config.break_on_first_failure}" if @user_config.break_on_first_failure puts " Node Total: #{@user_config.split_nodes}" if @user_config.split_nodes puts " Node Index: #{@user_config.split_index}" if @user_config.split_index puts ' Random Timing: Enabled' if @user_config.random_timing puts " Changed Specs Detected: #{@git_controller.changed_examples}" return if @user_config.output_file == File::NULL puts " Verbose Output Path: #{@user_config.output_file}" end |
#show_test_list ⇒ Object
end Debug methods
65 66 67 68 69 70 71 |
# File 'lib/flakey_spec_catcher/runner.rb', line 65 def show_test_list @rerun_manager.rerun_capsules.each do |capsule| capsule.testcase.each do |test| puts test end end end |