knapsack_pro 8.3.0 → 8.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 154cc1aaba977644e5f9dd5298e594ba4e6bbc4a67ec1edf1caac2aaf3d21ebb
4
- data.tar.gz: 11a7acd42b97cd0e2d0075733e0a34ebcc5677f1cbd2e5342cccb2745405cadd
3
+ metadata.gz: 479679af72441adcef212263c4a92e92760fc3bb82779616c47504d0a137a69c
4
+ data.tar.gz: 6376bcc3c00f50efa3633a1d015b23bb7a6fd3d8a3188d6912327e5f79c1ae27
5
5
  SHA512:
6
- metadata.gz: 733e3fc942afe5ba74bc1b689ac9255bba46e28ddfdd60a826a0946f68a9c208d139786c2ff32319885adbe1c1a0e0696d9f63c5dc1a916b6b5a4072af3e9de8
7
- data.tar.gz: 5769bf6874b3b93a1349268688d0304015da91072d9661852b034e937628f1be51d17a4e96a9124713fc6a730f953257989ba4613c6d5246de6ac8ec332c21e7
6
+ metadata.gz: 7dc0407f4c64d578cac17f64f71d93ac123e8ee7a96eeca2637e7e131449c35318bed7b6636d9e722528f36059a4cb5a8748b18e7737aaa8e92ba8212c82f83e
7
+ data.tar.gz: b3c505870912614006845bbf65b488ca1fe201f0a22e0dc449d5b2f7651603eceea5693fa7db5eff68bc7cd5bc89dde673eb21097a4cb341473b5b06bbcacaf5
data/CHANGELOG.md CHANGED
@@ -1,6 +1,23 @@
1
1
  # Changelog
2
2
 
3
- ### UNRELEASED
3
+ ### UNRELEASED (patch)
4
+
5
+ ### 8.3.2
6
+
7
+ * Fix infinite recursion when the logger enters a loop. [The issue](https://github.com/KnapsackPro/knapsack_pro-ruby/issues/269) occurs when `KNAPSACK_PRO_LOG_DIR=log` is set and a conflict arises between the values of environment variables from the CI provider and those configured by the user (e.g., `KNAPSACK_PRO_CI_NODE_INDEX`, `KNAPSACK_PRO_CI_NODE_TOTAL`).
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/304
10
+
11
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.3.1...v8.3.2
12
+
13
+ ### 8.3.1
14
+
15
+ * Fix RSpec TimeTracker to properly track `before(:all)/after(:all)`.
16
+
17
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/303
18
+
19
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.3.0...v8.3.1
20
+
4
21
 
5
22
  ### 8.3.0
6
23
 
@@ -13,11 +13,11 @@ module KnapsackPro
13
13
 
14
14
  class << self
15
15
  def ci_node_total
16
- (env_for('KNAPSACK_PRO_CI_NODE_TOTAL', :node_total) || 1).to_i
16
+ @ci_node_total ||= (env_for('KNAPSACK_PRO_CI_NODE_TOTAL', :node_total) || 1).to_i
17
17
  end
18
18
 
19
19
  def ci_node_index
20
- (env_for('KNAPSACK_PRO_CI_NODE_INDEX', :node_index) || 0).to_i
20
+ @ci_node_index ||= (env_for('KNAPSACK_PRO_CI_NODE_INDEX', :node_index) || 0).to_i
21
21
  end
22
22
 
23
23
  def ci_node_build_id
@@ -294,7 +294,7 @@ module KnapsackPro
294
294
  ci_env_value = ci_env_for(ci_env_method)
295
295
 
296
296
  if !knapsack_env_value.nil? && !ci_env_value.nil? && knapsack_env_value != ci_env_value.to_s
297
- KnapsackPro.logger.info("You have set the environment variable #{knapsack_env_name} to #{knapsack_env_value} which could be automatically determined from the CI environment as #{ci_env_value}.")
297
+ warn("You have set the environment variable #{knapsack_env_name} to #{knapsack_env_value} which could be automatically determined from the CI environment as #{ci_env_value}.")
298
298
  end
299
299
 
300
300
  knapsack_env_value != nil ? knapsack_env_value : ci_env_value
@@ -19,7 +19,7 @@ module KnapsackPro
19
19
  @output = StringIO.new
20
20
  @time_each = nil
21
21
  @time_all = nil
22
- @before_all = 0.0
22
+ @time_all_by_group_id_path = Hash.new(0)
23
23
  @group = {}
24
24
  @paths = {}
25
25
  @suite_started = now
@@ -38,12 +38,12 @@ module KnapsackPro
38
38
  end
39
39
 
40
40
  def example_group_started(notification)
41
- return unless top_level_group?(notification.group)
41
+ record_time_all(notification.group.parent_groups[1], @time_all_by_group_id_path, @time_all)
42
42
  @time_all = now
43
43
  end
44
44
 
45
- def example_started(_notification)
46
- @before_all = now - @time_all if @before_all == 0.0
45
+ def example_started(notification)
46
+ record_time_all(notification.example.example_group, @time_all_by_group_id_path, @time_all)
47
47
  @time_each = now
48
48
  end
49
49
 
@@ -53,11 +53,12 @@ module KnapsackPro
53
53
  end
54
54
 
55
55
  def example_group_finished(notification)
56
+ record_time_all(notification.group, @time_all_by_group_id_path, @time_all)
57
+ @time_all = now
56
58
  return unless top_level_group?(notification.group)
57
59
 
58
- after_all = @time_all.nil? ? 0.0 : now - @time_all
59
- add_hooks_time(@group, @before_all, after_all)
60
- @before_all = 0.0
60
+ add_hooks_time(@group, @time_all_by_group_id_path)
61
+ @time_all_by_group_id_path = Hash.new(0)
61
62
  @paths = merge(@paths, @group)
62
63
  @group = {}
63
64
  end
@@ -104,10 +105,17 @@ module KnapsackPro
104
105
  group.metadata[:parent_example_group].nil?
105
106
  end
106
107
 
107
- def add_hooks_time(group, before_all, after_all)
108
+ def add_hooks_time(group, time_all_by_group_id_path)
108
109
  group.each do |_, example|
109
110
  next if example[:time_execution] == 0.0
110
- example[:time_execution] += before_all + after_all
111
+
112
+ example[:time_execution] += time_all_by_group_id_path.sum do |group_id_path, time|
113
+ # :path is a file path (a_spec.rb), sum any before/after(:all) in the file
114
+ next time if group_id_path.start_with?(example[:path])
115
+ # :path is an id path (a_spec.rb[1:1]), sum any before/after(:all) above it
116
+ next time if example[:path].start_with?(group_id_path[0..-2])
117
+ 0
118
+ end
111
119
  end
112
120
  end
113
121
 
@@ -123,6 +131,13 @@ module KnapsackPro
123
131
  end
124
132
  end
125
133
 
134
+ def record_time_all(group, time_all_by_group_id_path, time_all)
135
+ return unless group # above top level group
136
+
137
+ group_id_path = KnapsackPro::TestFileCleaner.clean(group.id)
138
+ time_all_by_group_id_path[group_id_path] += now - time_all
139
+ end
140
+
126
141
  def path_for(example)
127
142
  file_path = file_path_for(example)
128
143
  return nil if file_path == ""
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KnapsackPro
4
- VERSION = '8.3.0'
4
+ VERSION = '8.3.2'
5
5
  end
@@ -1,6 +1,11 @@
1
1
  describe KnapsackPro::Config::Env do
2
2
  before { stub_const("ENV", {}) }
3
3
 
4
+ before(:each) do
5
+ described_class.remove_instance_variable(:@ci_node_index) if described_class.instance_variable_defined?(:@ci_node_index)
6
+ described_class.remove_instance_variable(:@ci_node_total) if described_class.instance_variable_defined?(:@ci_node_total)
7
+ end
8
+
4
9
  describe '.ci_node_total' do
5
10
  subject { described_class.ci_node_total }
6
11
 
@@ -19,12 +24,9 @@ describe KnapsackPro::Config::Env do
19
24
  end
20
25
 
21
26
  context 'when both KNAPSACK_PRO_CI_NODE_TOTAL and CI environment have value' do
22
- let(:logger) { instance_double(Logger, info: nil) }
23
-
24
27
  before do
25
28
  stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_TOTAL' => env_value })
26
29
  expect(described_class).to receive(:ci_env_for).with(:node_total).and_return(ci_value)
27
- allow(KnapsackPro).to receive(:logger).and_return(logger)
28
30
  end
29
31
 
30
32
  context 'when values are different' do
@@ -34,7 +36,7 @@ describe KnapsackPro::Config::Env do
34
36
  it { should eq 5 }
35
37
 
36
38
  it 'logs a warning' do
37
- expect(logger).to receive(:info).with(
39
+ expect(described_class).to receive(:warn).with(
38
40
  'You have set the environment variable KNAPSACK_PRO_CI_NODE_TOTAL to 5 which could be automatically determined from the CI environment as 4.'
39
41
  )
40
42
  subject
@@ -46,7 +48,7 @@ describe KnapsackPro::Config::Env do
46
48
  let(:ci_value) { 5 }
47
49
 
48
50
  it 'does not log a warning' do
49
- expect(logger).not_to receive(:info)
51
+ expect(described_class).not_to receive(:warn)
50
52
  subject
51
53
  end
52
54
  end
@@ -76,12 +78,9 @@ describe KnapsackPro::Config::Env do
76
78
  end
77
79
 
78
80
  context 'when both KNAPSACK_PRO_CI_NODE_INDEX and CI environment have value' do
79
- let(:logger) { instance_double(Logger, info: nil) }
80
-
81
81
  before do
82
82
  stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_INDEX' => env_value })
83
83
  expect(described_class).to receive(:ci_env_for).with(:node_index).and_return(ci_value)
84
- allow(KnapsackPro).to receive(:logger).and_return(logger)
85
84
  end
86
85
 
87
86
  context 'when values are different' do
@@ -91,7 +90,7 @@ describe KnapsackPro::Config::Env do
91
90
  it { should eq 3 }
92
91
 
93
92
  it 'logs a warning' do
94
- expect(logger).to receive(:info).with(
93
+ expect(described_class).to receive(:warn).with(
95
94
  'You have set the environment variable KNAPSACK_PRO_CI_NODE_INDEX to 3 which could be automatically determined from the CI environment as 2.'
96
95
  )
97
96
  subject
@@ -103,7 +102,7 @@ describe KnapsackPro::Config::Env do
103
102
  let(:ci_value) { 3 }
104
103
 
105
104
  it 'does not log a warning' do
106
- expect(logger).not_to receive(:info)
105
+ expect(described_class).not_to receive(:warn)
107
106
  subject
108
107
  end
109
108
  end
@@ -140,12 +139,9 @@ describe KnapsackPro::Config::Env do
140
139
  end
141
140
 
142
141
  context 'when both KNAPSACK_PRO_CI_NODE_BUILD_ID and CI environment have value' do
143
- let(:logger) { instance_double(Logger, info: nil) }
144
-
145
142
  before do
146
143
  stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_BUILD_ID' => env_value })
147
144
  expect(described_class).to receive(:ci_env_for).with(:node_build_id).and_return(ci_value)
148
- allow(KnapsackPro).to receive(:logger).and_return(logger)
149
145
  end
150
146
 
151
147
  context 'when values are different' do
@@ -155,7 +151,7 @@ describe KnapsackPro::Config::Env do
155
151
  it { should eq '7' }
156
152
 
157
153
  it 'logs a warning' do
158
- expect(logger).to receive(:info).with(
154
+ expect(described_class).to receive(:warn).with(
159
155
  'You have set the environment variable KNAPSACK_PRO_CI_NODE_BUILD_ID to 7 which could be automatically determined from the CI environment as 8.'
160
156
  )
161
157
  subject
@@ -167,7 +163,7 @@ describe KnapsackPro::Config::Env do
167
163
  let(:ci_value) { '7' }
168
164
 
169
165
  it 'does not log a warning' do
170
- expect(logger).not_to receive(:info)
166
+ expect(described_class).not_to receive(:warn)
171
167
  subject
172
168
  end
173
169
  end
@@ -199,12 +195,9 @@ describe KnapsackPro::Config::Env do
199
195
  end
200
196
 
201
197
  context 'when both KNAPSACK_PRO_CI_NODE_RETRY_COUNT and CI environment have value' do
202
- let(:logger) { instance_double(Logger, info: nil) }
203
-
204
198
  before do
205
199
  stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_RETRY_COUNT' => env_value })
206
200
  expect(described_class).to receive(:ci_env_for).with(:node_retry_count).and_return(ci_value)
207
- allow(KnapsackPro).to receive(:logger).and_return(logger)
208
201
  end
209
202
 
210
203
  context 'when values are different' do
@@ -214,7 +207,7 @@ describe KnapsackPro::Config::Env do
214
207
  it { should eq 1 }
215
208
 
216
209
  it 'logs a warning' do
217
- expect(logger).to receive(:info).with(
210
+ expect(described_class).to receive(:warn).with(
218
211
  'You have set the environment variable KNAPSACK_PRO_CI_NODE_RETRY_COUNT to 1 which could be automatically determined from the CI environment as 2.'
219
212
  )
220
213
  subject
@@ -226,7 +219,7 @@ describe KnapsackPro::Config::Env do
226
219
  let(:ci_value) { '7' }
227
220
 
228
221
  it 'does not log a warning' do
229
- expect(logger).not_to receive(:info)
222
+ expect(described_class).not_to receive(:warn)
230
223
  subject
231
224
  end
232
225
  end
@@ -269,12 +262,9 @@ describe KnapsackPro::Config::Env do
269
262
  end
270
263
 
271
264
  context 'when both KNAPSACK_PRO_COMMIT_HASH and CI environment have value' do
272
- let(:logger) { instance_double(Logger, info: nil) }
273
-
274
265
  before do
275
266
  stub_const("ENV", { 'KNAPSACK_PRO_COMMIT_HASH' => env_value })
276
267
  expect(described_class).to receive(:ci_env_for).with(:commit_hash).and_return(ci_value)
277
- allow(KnapsackPro).to receive(:logger).and_return(logger)
278
268
  end
279
269
 
280
270
  context 'when values are different' do
@@ -284,7 +274,7 @@ describe KnapsackPro::Config::Env do
284
274
  it { should eq '3fa64859337f6e56409d49f865d13fd7' }
285
275
 
286
276
  it 'logs a warning' do
287
- expect(logger).to receive(:info).with(
277
+ expect(described_class).to receive(:warn).with(
288
278
  'You have set the environment variable KNAPSACK_PRO_COMMIT_HASH to 3fa64859337f6e56409d49f865d13fd7 which could be automatically determined from the CI environment as fe61a08118d0d52e97c38666eba1eaf3.'
289
279
  )
290
280
  subject
@@ -296,7 +286,7 @@ describe KnapsackPro::Config::Env do
296
286
  let(:ci_value) { '3fa64859337f6e56409d49f865d13fd7' }
297
287
 
298
288
  it 'does not log a warning' do
299
- expect(logger).not_to receive(:info)
289
+ expect(described_class).not_to receive(:warn)
300
290
  subject
301
291
  end
302
292
  end
@@ -326,12 +316,9 @@ describe KnapsackPro::Config::Env do
326
316
  end
327
317
 
328
318
  context 'when both KNAPSACK_PRO_BRANCH and CI environment have value' do
329
- let(:logger) { instance_double(Logger, info: nil) }
330
-
331
319
  before do
332
320
  stub_const("ENV", { 'KNAPSACK_PRO_BRANCH' => env_value })
333
321
  expect(described_class).to receive(:ci_env_for).with(:branch).and_return(ci_value)
334
- allow(KnapsackPro).to receive(:logger).and_return(logger)
335
322
  end
336
323
 
337
324
  context 'when values are different' do
@@ -341,7 +328,7 @@ describe KnapsackPro::Config::Env do
341
328
  it { should eq 'main' }
342
329
 
343
330
  it 'logs a warning' do
344
- expect(logger).to receive(:info).with(
331
+ expect(described_class).to receive(:warn).with(
345
332
  'You have set the environment variable KNAPSACK_PRO_BRANCH to main which could be automatically determined from the CI environment as feature-branch.'
346
333
  )
347
334
  subject
@@ -353,7 +340,7 @@ describe KnapsackPro::Config::Env do
353
340
  let(:ci_value) { 'main' }
354
341
 
355
342
  it 'does not log a warning' do
356
- expect(logger).not_to receive(:info)
343
+ expect(described_class).not_to receive(:warn)
357
344
  subject
358
345
  end
359
346
  end
@@ -383,12 +370,9 @@ describe KnapsackPro::Config::Env do
383
370
  end
384
371
 
385
372
  context 'when both KNAPSACK_PRO_PROJECT_DIR and CI environment have value' do
386
- let(:logger) { instance_double(Logger, info: nil) }
387
-
388
373
  before do
389
374
  stub_const("ENV", { 'KNAPSACK_PRO_PROJECT_DIR' => env_value })
390
375
  expect(described_class).to receive(:ci_env_for).with(:project_dir).and_return(ci_value)
391
- allow(KnapsackPro).to receive(:logger).and_return(logger)
392
376
  end
393
377
 
394
378
  context 'when values are different' do
@@ -398,7 +382,7 @@ describe KnapsackPro::Config::Env do
398
382
  it { should eq '/home/user/myapp' }
399
383
 
400
384
  it 'logs a warning' do
401
- expect(logger).to receive(:info).with(
385
+ expect(described_class).to receive(:warn).with(
402
386
  'You have set the environment variable KNAPSACK_PRO_PROJECT_DIR to /home/user/myapp which could be automatically determined from the CI environment as /home/runner/myapp.'
403
387
  )
404
388
  subject
@@ -410,7 +394,7 @@ describe KnapsackPro::Config::Env do
410
394
  let(:ci_value) { '/home/user/myapp' }
411
395
 
412
396
  it 'does not log a warning' do
413
- expect(logger).not_to receive(:info)
397
+ expect(described_class).not_to receive(:warn)
414
398
  subject
415
399
  end
416
400
  end
@@ -440,12 +424,9 @@ describe KnapsackPro::Config::Env do
440
424
  end
441
425
 
442
426
  context 'when both KNAPSACK_PRO_USER_SEAT and CI environment have value' do
443
- let(:logger) { instance_double(Logger, info: nil) }
444
-
445
427
  before do
446
428
  stub_const("ENV", { 'KNAPSACK_PRO_USER_SEAT' => env_value })
447
429
  expect(described_class).to receive(:ci_env_for).with(:user_seat).and_return(ci_value)
448
- allow(KnapsackPro).to receive(:logger).and_return(logger)
449
430
  end
450
431
 
451
432
  context 'when values are different' do
@@ -455,7 +436,7 @@ describe KnapsackPro::Config::Env do
455
436
  it { should eq 'John Doe' }
456
437
 
457
438
  it 'logs a warning' do
458
- expect(logger).to receive(:info).with(
439
+ expect(described_class).to receive(:warn).with(
459
440
  'You have set the environment variable KNAPSACK_PRO_USER_SEAT to John Doe which could be automatically determined from the CI environment as Jane Doe.'
460
441
  )
461
442
  subject
@@ -467,7 +448,7 @@ describe KnapsackPro::Config::Env do
467
448
  let(:ci_value) { 'John Doe' }
468
449
 
469
450
  it 'does not log a warning' do
470
- expect(logger).not_to receive(:info)
451
+ expect(described_class).not_to receive(:warn)
471
452
  subject
472
453
  end
473
454
  end
@@ -872,13 +853,11 @@ describe KnapsackPro::Config::Env do
872
853
  it "on #{ci} it is false" do
873
854
  stub_const("ENV", env.merge({ 'KNAPSACK_PRO_FIXED_QUEUE_SPLIT' => 'false' }))
874
855
 
875
- logger = instance_double(Logger)
876
- allow(KnapsackPro).to receive(:logger).and_return(logger)
877
856
  ci_env = described_class.detected_ci.new.fixed_queue_split
878
857
  if ci_env == false
879
- expect(logger).not_to receive(:info)
858
+ expect(described_class).not_to receive(:warn)
880
859
  else
881
- expect(logger).to receive(:info).with(
860
+ expect(described_class).to receive(:warn).with(
882
861
  'You have set the environment variable KNAPSACK_PRO_FIXED_QUEUE_SPLIT to false which could be automatically determined from the CI environment as true.'
883
862
  )
884
863
  end
@@ -907,13 +886,11 @@ describe KnapsackPro::Config::Env do
907
886
  it "on #{ci} it is true" do
908
887
  stub_const("ENV", env.merge({ 'KNAPSACK_PRO_FIXED_QUEUE_SPLIT' => 'true' }))
909
888
 
910
- logger = instance_double(Logger)
911
- allow(KnapsackPro).to receive(:logger).and_return(logger)
912
889
  ci_env = described_class.detected_ci.new.fixed_queue_split
913
890
  if ci_env == true
914
- expect(logger).not_to receive(:info)
891
+ expect(described_class).not_to receive(:warn)
915
892
  else
916
- expect(logger).to receive(:info).with(
893
+ expect(described_class).to receive(:warn).with(
917
894
  'You have set the environment variable KNAPSACK_PRO_FIXED_QUEUE_SPLIT to true which could be automatically determined from the CI environment as false.'
918
895
  )
919
896
  end
@@ -220,6 +220,63 @@ class TestTimeTracker
220
220
  end
221
221
  end
222
222
 
223
+ def test_nested_hooks
224
+ KnapsackPro::Formatters::TimeTracker.define_method(:rspec_split_by_test_example?) do |_file|
225
+ false
226
+ end
227
+
228
+ spec = <<~SPEC
229
+ describe "KnapsackPro::Formatters::TimeTracker" do
230
+ before(:all) do
231
+ sleep 0.1
232
+ end
233
+
234
+ after(:all) do
235
+ sleep 0.1
236
+ end
237
+
238
+ it do
239
+ expect(1).to eq 1
240
+ end
241
+
242
+ describe do
243
+ before(:all) do
244
+ sleep 0.1
245
+ end
246
+
247
+ after(:all) do
248
+ sleep 0.1
249
+ end
250
+
251
+ it do
252
+ expect(1).to eq 1
253
+ end
254
+ end
255
+
256
+ describe do
257
+ before(:all) do
258
+ sleep 0.1
259
+ end
260
+
261
+ after(:all) do
262
+ sleep 0.1
263
+ end
264
+
265
+ it do
266
+ expect(1).to eq 1
267
+ end
268
+ end
269
+ end
270
+ SPEC
271
+
272
+ run_specs(spec) do |spec_paths, times|
273
+ raise unless times.size == 1
274
+ raise unless times[0]["path"] == spec_paths.first
275
+ raise unless times[0]["time_execution"] > 0.60
276
+ raise unless times[0]["time_execution"] < 0.65
277
+ end
278
+ end
279
+
223
280
  def test_hooks_with_rspec_split_by_test_example
224
281
  KnapsackPro::Formatters::TimeTracker.define_method(:rspec_split_by_test_example?) do |_file|
225
282
  true
@@ -263,6 +320,68 @@ class TestTimeTracker
263
320
  end
264
321
  end
265
322
 
323
+ def test_nested_hooks_with_rspec_split_by_test_example
324
+ KnapsackPro::Formatters::TimeTracker.define_method(:rspec_split_by_test_example?) do |_file|
325
+ true
326
+ end
327
+
328
+ spec = <<~SPEC
329
+ describe "KnapsackPro::Formatters::TimeTracker" do
330
+ before(:all) do
331
+ sleep 0.1
332
+ end
333
+
334
+ after(:all) do
335
+ sleep 0.1
336
+ end
337
+
338
+ it do
339
+ expect(1).to eq 1
340
+ end
341
+
342
+ describe do
343
+ before(:all) do
344
+ sleep 0.1
345
+ end
346
+
347
+ after(:all) do
348
+ sleep 0.1
349
+ end
350
+
351
+ it do
352
+ expect(1).to eq 1
353
+ end
354
+ end
355
+
356
+ describe do
357
+ before(:all) do
358
+ sleep 0.1
359
+ end
360
+
361
+ after(:all) do
362
+ sleep 0.1
363
+ end
364
+
365
+ it do
366
+ expect(1).to eq 1
367
+ end
368
+ end
369
+ end
370
+ SPEC
371
+
372
+ run_specs(spec) do |spec_paths, times|
373
+ raise unless times.size == 3
374
+ spec_path = spec_paths.first
375
+ raise unless times.find { |time| time["path"] == "#{spec_path}[1:1]" }["time_execution"] > 0.20
376
+ raise unless times.find { |time| time["path"] == "#{spec_path}[1:1]" }["time_execution"] < 0.25
377
+ raise unless times.find { |time| time["path"] == "#{spec_path}[1:2:1]" }["time_execution"] > 0.40
378
+ raise unless times.find { |time| time["path"] == "#{spec_path}[1:2:1]" }["time_execution"] < 0.45
379
+ raise unless times.find { |time| time["path"] == "#{spec_path}[1:3:1]" }["time_execution"] > 0.40
380
+ raise unless times.find { |time| time["path"] == "#{spec_path}[1:3:1]" }["time_execution"] < 0.45
381
+ end
382
+ end
383
+
384
+
266
385
  def test_unknown_path
267
386
  KnapsackPro::Formatters::TimeTracker.class_eval do
268
387
  alias_method :original_file_path_for, :file_path_for
@@ -10,7 +10,10 @@ describe KnapsackPro do
10
10
 
11
11
  subject { described_class.logger }
12
12
 
13
- before { described_class.reset_logger! }
13
+ before(:each) do
14
+ described_class.reset_logger!
15
+ KnapsackPro::Config::Env.remove_instance_variable(:@ci_node_index) if KnapsackPro::Config::Env.instance_variable_defined?(:@ci_node_index)
16
+ end
14
17
  after { described_class.reset_logger! }
15
18
 
16
19
  context 'when KNAPSACK_PRO_LOG_DIR is set' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.3.0
4
+ version: 8.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake
@@ -428,7 +428,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
428
428
  - !ruby/object:Gem::Version
429
429
  version: '0'
430
430
  requirements: []
431
- rubygems_version: 3.6.2
431
+ rubygems_version: 3.6.7
432
432
  specification_version: 4
433
433
  summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
434
434
  job finish work at a similar time.