Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zzaakiirr committed Aug 22, 2024
1 parent e3c1739 commit ccf58b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/command/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -474,23 +474,23 @@ def step_finish(success, abort_on_error: true)
end
end

def step(message, abort_on_error: true, retry_on_failure: false, max_retry_count: Float::INFINITY, wait: 1) # rubocop:disable Metrics/MethodLength
def step(message, abort_on_error: true, retry_on_failure: false, max_retry_count: 1000, wait: 1) # rubocop:disable Metrics/MethodLength
progress.print("#{message}...")

Shell.use_tmp_stderr do
success = false

begin
if retry_on_failure
run_count = 0
while !success && run_count < max_retry_count
retry_count = 0
while !success && retry_count <= max_retry_count
success = yield
break if success

progress.print(".")
Kernel.sleep(wait)

run_count += 1
retry_count += 1
end
else
success = yield
Expand Down
9 changes: 4 additions & 5 deletions spec/command/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
require "spec_helper"

describe Command::Base do
subject(:command) { described_class.new(config) }

let(:config) { instance_double(Command::Config) }
let(:command) { described_class.new(config) }

around do |example|
suppress_output { example.run }
Expand All @@ -25,7 +24,7 @@
true if run_count == 3
end

expect(run_count).to eq 3
expect(run_count).to eq(3)
end

context "with max_retry_count option" do
Expand All @@ -39,7 +38,7 @@
false
end

expect(run_count).to eq 1
expect(run_count).to eq(1 + 1) # 1 run and 1 retry after fail
end
end
end
Expand All @@ -55,7 +54,7 @@
false
end

expect(run_count).to eq 1
expect(run_count).to eq(1)
end
end
end
Expand Down

0 comments on commit ccf58b9

Please sign in to comment.