knapsack_pro 0.46.0 → 0.47.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: faf69acd6fc43b314a341d426e48898c9939eee7
4
- data.tar.gz: 92b80713554443d3a82c87f12c839ac874adc75e
3
+ metadata.gz: 134f144c4fb7cd10705a73ccf858439ee3d9e907
4
+ data.tar.gz: 4edada383933812bbb739d7f471a28b21530492a
5
5
  SHA512:
6
- metadata.gz: 8caf5c2763a65260bd56f345c263388da4b8f0ba6df6ee4654f2daf746ef581808bb7c209afa9c49b68671866e35eb743aec45cd12f9318f1b1adcd8ec7ce37c
7
- data.tar.gz: f1e17e64c0141d7517e4fa13348b0aadeea4181b727f02a2cfa39c9b3e393bbf3ee9045ab05a4e38c2aff40f71fa91a16e6801fe45f1602b477866d6f15cb7e8
6
+ metadata.gz: 6ab40a05f0201ce49cc2c184741d31327e2a2ae2317b1895e7e6cba258c53062aa3bb9b8032141c9476f9ed20bb617c2c9fd55c84250cb7eaeec58c63d7d66c9
7
+ data.tar.gz: 482638d2f37f274b7cc3cc512d8dc24a8e5a6dd562e35c31cc8d373d8b3690cea0a23d1965844ce060d742b3e3493b3557d4118b7b2baef14b77f385efefd3f9
data/CHANGELOG.md CHANGED
@@ -2,9 +2,18 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 0.47.0
6
+
7
+ * Add in Queue Mode the RSpec summary with info about examples, failures and pending tests.
8
+ * Fix not working message `Global time execution for tests` at end of each subset of tests from work queue.
9
+
10
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/48
11
+
12
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.46.0...v0.47.0
13
+
5
14
  ### 0.46.0
6
15
 
7
- * Autoload knapsack_pro rake tasks with Rails Railties
16
+ * Autoload knapsack_pro rake tasks with Rails Railties.
8
17
 
9
18
  https://github.com/KnapsackPro/knapsack_pro-ruby/pull/47
10
19
 
@@ -19,6 +19,7 @@ module KnapsackPro
19
19
 
20
20
  if KnapsackPro::Config::Env.queue_recording_enabled?
21
21
  KnapsackPro.logger.debug('Test suite time execution queue recording enabled.')
22
+ bind_tracker_reset
22
23
  bind_before_queue_hook
23
24
  bind_time_tracker
24
25
  bind_save_queue_report
@@ -37,6 +38,10 @@ module KnapsackPro
37
38
  raise NotImplementedError
38
39
  end
39
40
 
41
+ def bind_tracker_reset
42
+ raise NotImplementedError
43
+ end
44
+
40
45
  def bind_before_queue_hook
41
46
  raise NotImplementedError
42
47
  end
@@ -58,6 +58,14 @@ module KnapsackPro
58
58
  end
59
59
  end
60
60
 
61
+ def bind_tracker_reset
62
+ ::RSpec.configure do |config|
63
+ config.before(:suite) do
64
+ KnapsackPro.tracker.reset!
65
+ end
66
+ end
67
+ end
68
+
61
69
  def bind_before_queue_hook
62
70
  ::RSpec.configure do |config|
63
71
  config.before(:suite) do
@@ -10,7 +10,7 @@ module KnapsackPro
10
10
  end
11
11
 
12
12
  class RSpecQueueSummaryFormatter < RSpec::Core::Formatters::BaseFormatter
13
- RSpec::Core::Formatters.register self, :dump_failures, :dump_pending
13
+ RSpec::Core::Formatters.register self, :dump_summary, :dump_failures, :dump_pending
14
14
 
15
15
  def self.registered_output=(output)
16
16
  @registered_output = {
@@ -86,6 +86,21 @@ module KnapsackPro
86
86
  return if notification.pending_examples.empty?
87
87
  self.class.most_recent_pending = notification.fully_formatted_pending_examples
88
88
  end
89
+
90
+ def dump_summary(summary)
91
+ colorizer = ::RSpec::Core::Formatters::ConsoleCodes
92
+ duration = KnapsackPro.tracker.global_time_since_beginning
93
+ formatted_duration = ::RSpec::Core::Formatters::Helpers.format_duration(duration)
94
+
95
+ formatted = "\nFinished in #{formatted_duration}\n" \
96
+ "#{summary.colorized_totals_line(colorizer)}\n"
97
+
98
+ unless summary.failed_examples.empty?
99
+ formatted += (summary.colorized_rerun_commands(colorizer) + "\n")
100
+ end
101
+
102
+ self.class.most_recent_summary = formatted
103
+ end
89
104
  end
90
105
  end
91
106
  end
@@ -12,7 +12,6 @@ module KnapsackPro
12
12
 
13
13
  def self.save_subset_queue_to_file
14
14
  test_files = KnapsackPro.tracker.to_a
15
- KnapsackPro.tracker.reset!
16
15
 
17
16
  subset_queue_id = KnapsackPro::Config::Env.subset_queue_id
18
17
 
@@ -2,10 +2,11 @@ module KnapsackPro
2
2
  class Tracker
3
3
  include Singleton
4
4
 
5
- attr_reader :global_time, :test_files_with_time
5
+ attr_reader :global_time_since_beginning, :global_time, :test_files_with_time
6
6
  attr_writer :current_test_path
7
7
 
8
8
  def initialize
9
+ @global_time_since_beginning = 0
9
10
  set_defaults
10
11
  end
11
12
 
@@ -18,10 +19,10 @@ module KnapsackPro
18
19
  end
19
20
 
20
21
  def stop_timer
21
- @execution_time = @start_time ? now_without_mock_time.to_f - @start_time : 0.0
22
- update_global_time
23
- update_test_file_time
24
- @execution_time
22
+ execution_time = @start_time ? now_without_mock_time.to_f - @start_time : 0.0
23
+ update_global_time(execution_time)
24
+ update_test_file_time(execution_time)
25
+ execution_time
25
26
  end
26
27
 
27
28
  def current_test_path
@@ -48,13 +49,14 @@ module KnapsackPro
48
49
  @test_path = nil
49
50
  end
50
51
 
51
- def update_global_time
52
- @global_time += @execution_time
52
+ def update_global_time(execution_time)
53
+ @global_time += execution_time
54
+ @global_time_since_beginning += execution_time
53
55
  end
54
56
 
55
- def update_test_file_time
57
+ def update_test_file_time(execution_time)
56
58
  @test_files_with_time[current_test_path] ||= 0
57
- @test_files_with_time[current_test_path] += @execution_time
59
+ @test_files_with_time[current_test_path] += execution_time
58
60
  end
59
61
 
60
62
  def now_without_mock_time
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '0.46.0'
2
+ VERSION = '0.47.0'
3
3
  end
@@ -48,6 +48,7 @@ describe KnapsackPro::Adapters::BaseAdapter do
48
48
  let(:queue_recording_enabled?) { true }
49
49
 
50
50
  before do
51
+ allow(subject).to receive(:bind_tracker_reset)
51
52
  allow(subject).to receive(:bind_before_queue_hook)
52
53
  allow(subject).to receive(:bind_time_tracker)
53
54
  allow(subject).to receive(:bind_save_queue_report)
@@ -58,12 +59,14 @@ describe KnapsackPro::Adapters::BaseAdapter do
58
59
  expect(KnapsackPro).to receive(:logger).and_return(logger)
59
60
  expect(logger).to receive(:debug).with('Test suite time execution queue recording enabled.')
60
61
  end
62
+ it { expect(subject).to receive(:bind_tracker_reset) }
61
63
  it { expect(subject).to receive(:bind_before_queue_hook) }
62
64
  it { expect(subject).to receive(:bind_time_tracker) }
63
65
  it { expect(subject).to receive(:bind_save_queue_report) }
64
66
  end
65
67
 
66
68
  context 'when recording disabled' do
69
+ it { expect(subject).not_to receive(:bind_tracker_reset) }
67
70
  it { expect(subject).not_to receive(:bind_time_tracker) }
68
71
  it { expect(subject).not_to receive(:bind_save_report) }
69
72
  it { expect(subject).not_to receive(:bind_save_queue_report) }
@@ -95,6 +98,14 @@ describe KnapsackPro::Adapters::BaseAdapter do
95
98
  end
96
99
  end
97
100
 
101
+ describe '#bind_tracker_reset' do
102
+ it do
103
+ expect {
104
+ subject.bind_tracker_reset
105
+ }.to raise_error(NotImplementedError)
106
+ end
107
+ end
108
+
98
109
  describe '#bind_before_queue_hook' do
99
110
  it do
100
111
  expect {
@@ -124,6 +124,19 @@ describe KnapsackPro::Adapters::RSpecAdapter do
124
124
  end
125
125
  end
126
126
 
127
+ describe '#bind_tracker_reset' do
128
+ it do
129
+ expect(config).to receive(:before).with(:suite).and_yield
130
+ expect(::RSpec).to receive(:configure).and_yield(config)
131
+
132
+ tracker = instance_double(KnapsackPro::Tracker)
133
+ expect(KnapsackPro).to receive(:tracker).and_return(tracker)
134
+ expect(tracker).to receive(:reset!)
135
+
136
+ subject.bind_tracker_reset
137
+ end
138
+ end
139
+
127
140
  describe '#bind_before_queue_hook' do
128
141
  it do
129
142
  expect(config).to receive(:before).with(:suite).and_yield
@@ -20,8 +20,7 @@ describe KnapsackPro::Report do
20
20
  before do
21
21
  test_files = [{path: fake_path}]
22
22
  tracker = instance_double(KnapsackPro::Tracker, to_a: test_files)
23
- expect(KnapsackPro).to receive(:tracker).twice.and_return(tracker)
24
- expect(tracker).to receive(:reset!)
23
+ expect(KnapsackPro).to receive(:tracker).and_return(tracker)
25
24
 
26
25
  subset_queue_id = 'fake-subset-queue-id'
27
26
  expect(KnapsackPro::Config::Env).to receive(:subset_queue_id).and_return(subset_queue_id)
@@ -114,5 +114,9 @@ describe KnapsackPro::Tracker do
114
114
  end
115
115
 
116
116
  it_behaves_like 'default trakcer attributes'
117
+
118
+ it "global time since beginning won't be reset" do
119
+ expect(tracker.global_time_since_beginning).to be >= 0.1
120
+ end
117
121
  end
118
122
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.46.0
4
+ version: 0.47.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-12 00:00:00.000000000 Z
11
+ date: 2017-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake