Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle case when start timer was not called (rspec-retry issue) #33

Merged
merged 6 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

* TODO

### 0.36.0

* Show messages about not executed test files as warnings in logs.
* Handle case when start timer was not called (rspec-retry issue).

https://github.com/KnapsackPro/knapsack_pro-ruby/pull/33

https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.35.0...v0.36.0

### 0.35.0

* Add `RSpecQueueProfileFormatterExtension` to show profile summary only once at the very end of RSpec Queue Mode output.
Expand Down
4 changes: 2 additions & 2 deletions lib/knapsack_pro/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def self.save
test_files = KnapsackPro.tracker.to_a

if test_files.empty?
KnapsackPro.logger.info("No test files were executed on this CI node. When you use knapsack_pro regular mode then probably reason might be very narrowed tests list - you run only tests with specified tag and there are fewer test files with the tag than node total number.")
KnapsackPro.logger.warn("No test files were executed on this CI node. When you use knapsack_pro regular mode then probably reason might be very narrowed tests list - you run only tests with specified tag and there are fewer test files with the tag than node total number.")
end

create_build_subset(test_files)
Expand Down Expand Up @@ -35,7 +35,7 @@ def self.save_node_queue_to_api
end

if test_files.empty?
KnapsackPro.logger.info("No test files were executed on this CI node. When you use knapsack_pro queue mode then probably reason might be that CI node was started after the test files from the queue were already executed by other CI nodes. That is why this CI node has no test files to execute.")
KnapsackPro.logger.warn("No test files were executed on this CI node. When you use knapsack_pro queue mode then probably reason might be that CI node was started after the test files from the queue were already executed by other CI nodes. That is why this CI node has no test files to execute.")
end

create_build_subset(test_files)
Expand Down
2 changes: 1 addition & 1 deletion lib/knapsack_pro/tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def start_timer
end

def stop_timer
@execution_time = now_without_mock_time.to_f - @start_time
@execution_time = @start_time ? now_without_mock_time.to_f - @start_time : 0.0
update_global_time
update_test_file_time
@execution_time
Expand Down
2 changes: 1 addition & 1 deletion lib/knapsack_pro/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module KnapsackPro
VERSION = '0.35.0'
VERSION = '0.36.0'
end
16 changes: 16 additions & 0 deletions spec/knapsack_pro/tracker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@
it { expect(tracker.test_files_with_time['b_spec.rb']).to be_within(delta).of(0) }
it_behaves_like '#to_a'
end

# https://github.com/KnapsackPro/knapsack_pro-ruby/issues/32
context 'when start timer was not called (rspec-retry issue)' do
before do
test_paths.each_with_index do |test_path, index|
tracker.current_test_path = test_path
tracker.stop_timer
end
end

it { expect(tracker.global_time).to eq 0 }
it { expect(tracker.test_files_with_time.keys.size).to eql 2 }
it { expect(tracker.test_files_with_time['a_spec.rb']).to eq 0 }
it { expect(tracker.test_files_with_time['b_spec.rb']).to eq 0 }
it_behaves_like '#to_a'
end
end

describe '#reset!' do
Expand Down