knapsack_pro 5.6.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
6
6
 
7
7
  require KnapsackPro.root + '/lib/knapsack_pro/formatters/rspec_queue_summary_formatter'
8
8
  require KnapsackPro.root + '/lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension'
9
+ require KnapsackPro.root + '/lib/knapsack_pro/formatters/time_tracker'
9
10
  end
10
11
 
11
12
  describe '.run' do
@@ -45,7 +46,13 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
45
46
  status: :next,
46
47
  runner: runner,
47
48
  can_initialize_queue: true,
48
- args: ['--example-arg', 'example-value', '--format', 'progress', '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter', '--default-path', 'fake-test-dir'],
49
+ args: [
50
+ '--example-arg', 'example-value',
51
+ '--format', 'progress',
52
+ '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter',
53
+ '--format', 'KnapsackPro::Formatters::TimeTracker',
54
+ '--default-path', 'fake-test-dir',
55
+ ],
49
56
  exitstatus: 0,
50
57
  all_test_file_paths: [],
51
58
  }
@@ -71,7 +78,12 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
71
78
  status: :next,
72
79
  runner: runner,
73
80
  can_initialize_queue: true,
74
- args: ['--format', 'documentation', '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter', '--default-path', 'fake-test-dir'],
81
+ args: [
82
+ '--format', 'documentation',
83
+ '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter',
84
+ '--format', 'KnapsackPro::Formatters::TimeTracker',
85
+ '--default-path', 'fake-test-dir',
86
+ ],
75
87
  exitstatus: 0,
76
88
  all_test_file_paths: [],
77
89
  }
@@ -97,7 +109,12 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
97
109
  status: :next,
98
110
  runner: runner,
99
111
  can_initialize_queue: true,
100
- args: ['-f', 'd', '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter', '--default-path', 'fake-test-dir'],
112
+ args: [
113
+ '-f', 'd',
114
+ '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter',
115
+ '--format', 'KnapsackPro::Formatters::TimeTracker',
116
+ '--default-path', 'fake-test-dir',
117
+ ],
101
118
  exitstatus: 0,
102
119
  all_test_file_paths: [],
103
120
  }
@@ -123,7 +140,12 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
123
140
  status: :next,
124
141
  runner: runner,
125
142
  can_initialize_queue: true,
126
- args: ['-fMyCustomFormatter', '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter', '--default-path', 'fake-test-dir'],
143
+ args: [
144
+ '-fMyCustomFormatter',
145
+ '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter',
146
+ '--format', 'KnapsackPro::Formatters::TimeTracker',
147
+ '--default-path', 'fake-test-dir',
148
+ ],
127
149
  exitstatus: 0,
128
150
  all_test_file_paths: [],
129
151
  }
@@ -165,7 +187,12 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
165
187
  status: :next,
166
188
  runner: runner,
167
189
  can_initialize_queue: true,
168
- args: ['--format', 'progress', '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter', '--default-path', 'fake-test-dir'],
190
+ args: [
191
+ '--format', 'progress',
192
+ '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter',
193
+ '--format', 'KnapsackPro::Formatters::TimeTracker',
194
+ '--default-path', 'fake-test-dir',
195
+ ],
169
196
  exitstatus: 0,
170
197
  all_test_file_paths: [],
171
198
  }
@@ -219,12 +246,7 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
219
246
 
220
247
  expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_SUBSET_QUEUE_ID', subset_queue_id)
221
248
 
222
- tracker = instance_double(KnapsackPro::Tracker)
223
- expect(KnapsackPro).to receive(:tracker).twice.and_return(tracker)
224
- expect(tracker).to receive(:reset!)
225
- expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
226
-
227
- expect(described_class).to receive(:ensure_spec_opts_have_rspec_queue_summary_formatter)
249
+ expect(described_class).to receive(:ensure_spec_opts_have_knapsack_pro_formatters)
228
250
  options = double
229
251
  expect(RSpec::Core::ConfigurationOptions).to receive(:new).with([
230
252
  '--no-color',
@@ -241,8 +263,6 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
241
263
 
242
264
  expect(KnapsackPro::Hooks::Queue).to receive(:call_after_subset_queue)
243
265
 
244
- expect(KnapsackPro::Report).to receive(:save_subset_queue_to_file)
245
-
246
266
  configuration = double
247
267
  expect(rspec_core_runner).to receive(:configuration).twice.and_return(configuration)
248
268
  expect(configuration).to receive(:seed_used?).and_return(true)
@@ -344,12 +364,7 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
344
364
 
345
365
  expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_SUBSET_QUEUE_ID', subset_queue_id)
346
366
 
347
- tracker = instance_double(KnapsackPro::Tracker)
348
- expect(KnapsackPro).to receive(:tracker).twice.and_return(tracker)
349
- expect(tracker).to receive(:reset!)
350
- expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
351
-
352
- expect(described_class).to receive(:ensure_spec_opts_have_rspec_queue_summary_formatter)
367
+ expect(described_class).to receive(:ensure_spec_opts_have_knapsack_pro_formatters)
353
368
  options = double
354
369
  expect(RSpec::Core::ConfigurationOptions).to receive(:new).with([
355
370
  '--no-color',
@@ -361,16 +376,14 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
361
376
  expect(RSpec::Core::Runner).to receive(:new).with(options).and_return(rspec_core_runner)
362
377
  expect(rspec_core_runner).to receive(:run).with($stderr, $stdout).and_raise SystemExit
363
378
  expect(KnapsackPro::Hooks::Queue).to receive(:call_before_subset_queue)
364
- allow(KnapsackPro::Report).to receive(:save_subset_queue_to_file)
365
379
  allow(KnapsackPro::Hooks::Queue).to receive(:call_after_subset_queue)
366
380
  allow(KnapsackPro::Hooks::Queue).to receive(:call_after_queue)
367
381
  allow(KnapsackPro::Formatters::RSpecQueueSummaryFormatter).to receive(:print_exit_summary)
368
382
  expect(Kernel).to receive(:exit).with(1)
369
383
  end
370
384
 
371
- it 'does not call #save_subset_queue_to_file or #rspec_clear_examples' do
385
+ it 'does not call #rspec_clear_examples' do
372
386
  expect(described_class).not_to receive(:rspec_clear_examples)
373
- expect(KnapsackPro::Report).not_to receive(:save_subset_queue_to_file)
374
387
  expect { subject }.to raise_error SystemExit
375
388
  end
376
389
 
@@ -411,7 +424,14 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
411
424
  expect(KnapsackPro::Formatters::RSpecQueueProfileFormatterExtension).to receive(:print_summary)
412
425
 
413
426
  expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue)
414
- expect(KnapsackPro::Report).to receive(:save_node_queue_to_api)
427
+
428
+ time_tracker = instance_double(KnapsackPro::Formatters::TimeTracker)
429
+ times = all_test_file_paths.map do |path|
430
+ [{ path: path, time_execution: 1.0 }]
431
+ end
432
+ expect(time_tracker).to receive(:queue).and_return(times)
433
+ expect(KnapsackPro::Formatters::TimeTrackerFetcher).to receive(:call).and_return(time_tracker)
434
+ expect(KnapsackPro::Report).to receive(:save_node_queue_to_api).with(times)
415
435
 
416
436
  expect(logger).to receive(:info)
417
437
  .with('To retry all the tests assigned to this CI node, please run the following command on your machine:')
@@ -448,7 +468,15 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
448
468
 
449
469
  it do
450
470
  expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue)
451
- expect(KnapsackPro::Report).to receive(:save_node_queue_to_api)
471
+
472
+ time_tracker = instance_double(KnapsackPro::Formatters::TimeTracker)
473
+ times = all_test_file_paths.map do |path|
474
+ [{ path: path, time_execution: 0.0 }]
475
+ end
476
+ expect(time_tracker).to receive(:queue).and_return(times)
477
+ expect(KnapsackPro::Formatters::TimeTrackerFetcher).to receive(:call).and_return(time_tracker)
478
+ expect(KnapsackPro::Report).to receive(:save_node_queue_to_api).with(times)
479
+
452
480
  expect(KnapsackPro).to_not receive(:logger)
453
481
 
454
482
  expect(subject).to eq({
@@ -460,29 +488,40 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
460
488
  end
461
489
  end
462
490
 
463
- describe '.ensure_spec_opts_have_rspec_queue_summary_formatter' do
464
- subject { described_class.ensure_spec_opts_have_rspec_queue_summary_formatter }
491
+ describe '.ensure_spec_opts_have_knapsack_pro_formatters' do
492
+ subject { described_class.ensure_spec_opts_have_knapsack_pro_formatters }
465
493
 
466
494
  context 'when `SPEC_OPTS` is set' do
467
- context 'when `SPEC_OPTS` has RSpec Queue Summary Formatter' do
495
+ context 'when `SPEC_OPTS` has RSpecQueueSummaryFormatter' do
468
496
  before do
469
497
  stub_const('ENV', { 'SPEC_OPTS' => '--format json --format KnapsackPro::Formatters::RSpecQueueSummaryFormatter' })
470
498
  end
471
499
 
472
- it 'does nothing' do
500
+ it 'adds TimeTracker' do
501
+ subject
502
+ expect(ENV['SPEC_OPTS']).to eq '--format json --format KnapsackPro::Formatters::RSpecQueueSummaryFormatter --format KnapsackPro::Formatters::TimeTracker'
503
+ end
504
+ end
505
+
506
+ context 'when `SPEC_OPTS` has TimeTracker' do
507
+ before do
508
+ stub_const('ENV', { 'SPEC_OPTS' => '--format json --format KnapsackPro::Formatters::TimeTracker' })
509
+ end
510
+
511
+ it 'adds RSpecQueueSummaryFormatter' do
473
512
  subject
474
- expect(ENV['SPEC_OPTS']).to eq '--format json --format KnapsackPro::Formatters::RSpecQueueSummaryFormatter'
513
+ expect(ENV['SPEC_OPTS']).to eq '--format json --format KnapsackPro::Formatters::TimeTracker --format KnapsackPro::Formatters::RSpecQueueSummaryFormatter'
475
514
  end
476
515
  end
477
516
 
478
- context 'when `SPEC_OPTS` has no RSpec Queue Summary Formatter' do
517
+ context 'when `SPEC_OPTS` has no Knapsack Pro formatters' do
479
518
  before do
480
519
  stub_const('ENV', { 'SPEC_OPTS' => '--format json' })
481
520
  end
482
521
 
483
- it 'adds RSpec Queue Summary Formatter to `SPEC_OPTS`' do
522
+ it 'adds RSpecQueueSummaryFormatter and TimeTracker to `SPEC_OPTS`' do
484
523
  subject
485
- expect(ENV['SPEC_OPTS']).to eq '--format json --format KnapsackPro::Formatters::RSpecQueueSummaryFormatter'
524
+ expect(ENV['SPEC_OPTS']).to eq '--format json --format KnapsackPro::Formatters::RSpecQueueSummaryFormatter --format KnapsackPro::Formatters::TimeTracker'
486
525
  end
487
526
  end
488
527
  end
@@ -42,14 +42,11 @@ describe KnapsackPro::Runners::RSpecRunner do
42
42
  expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:verify_bind_method_called).ordered
43
43
  expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!).with(['--profile', '--color']).ordered
44
44
 
45
- tracker = instance_double(KnapsackPro::Tracker)
46
- expect(KnapsackPro).to receive(:tracker).and_return(tracker)
47
- expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
48
-
49
45
  expect(Rake::Task).to receive(:[]).with('knapsack_pro:rspec_run').at_least(1).and_return(task)
50
46
 
51
47
  expect(RSpec::Core::RakeTask).to receive(:new).with('knapsack_pro:rspec_run').and_yield(task_config)
52
- expect(task_config).to receive(:rspec_opts=).with('--profile --color --default-path fake-test-dir spec/a_spec.rb spec/b_spec.rb[1:1]')
48
+ expect(RSpec::Core::ConfigurationOptions).to receive_message_chain(:new, :options).and_return({})
49
+ expect(task_config).to receive(:rspec_opts=).with('--profile --color --format progress --format KnapsackPro::Formatters::TimeTracker --default-path fake-test-dir spec/a_spec.rb spec/b_spec.rb[1:1]')
53
50
  expect(task_config).to receive(:pattern=).with([])
54
51
  end
55
52
 
@@ -177,29 +177,8 @@ describe KnapsackPro::Tracker do
177
177
 
178
178
  it_behaves_like 'default trakcer attributes'
179
179
 
180
- it "global time since beginning won't be reset" do
181
- expect(tracker.global_time_since_beginning).to be >= 0.1
182
- end
183
-
184
180
  it 'resets prerun_tests_loaded to false' do
185
181
  expect(tracker.prerun_tests_loaded).to be false
186
182
  end
187
183
  end
188
-
189
-
190
- describe '#unexecuted_test_files' do
191
- before do
192
- tracker.set_prerun_tests(['a_spec.rb', 'b_spec.rb', 'c_spec.rb'])
193
-
194
- # measure execution time for b_spec.rb
195
- tracker.current_test_path = 'b_spec.rb'
196
- tracker.start_timer
197
- sleep 0.1
198
- tracker.stop_timer
199
- end
200
-
201
- it 'returns test files without measured time' do
202
- expect(tracker.unexecuted_test_files).to eq(['a_spec.rb', 'c_spec.rb'])
203
- end
204
- end
205
184
  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: 5.6.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-24 00:00:00.000000000 Z
11
+ date: 2023-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -183,7 +183,7 @@ description: Run tests in parallel across CI server nodes based on tests executi
183
183
  time. Thanks to that your CI build time is as fast as possible. It works with many
184
184
  CI providers.
185
185
  email:
186
- - arturtrzop@gmail.com
186
+ - support@knapsackpro.com
187
187
  executables:
188
188
  - knapsack_pro
189
189
  extensions: []
@@ -201,6 +201,7 @@ files:
201
201
  - README.md
202
202
  - Rakefile
203
203
  - bin/knapsack_pro
204
+ - bin/test
204
205
  - knapsack_pro.gemspec
205
206
  - lib/knapsack_pro.rb
206
207
  - lib/knapsack_pro/adapters/base_adapter.rb
@@ -239,10 +240,11 @@ files:
239
240
  - lib/knapsack_pro/crypto/decryptor.rb
240
241
  - lib/knapsack_pro/crypto/digestor.rb
241
242
  - lib/knapsack_pro/crypto/encryptor.rb
242
- - lib/knapsack_pro/extensions/time.rb
243
243
  - lib/knapsack_pro/formatters/rspec_json_formatter.rb
244
244
  - lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
245
245
  - lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb
246
+ - lib/knapsack_pro/formatters/time_tracker.rb
247
+ - lib/knapsack_pro/formatters/time_tracker_fetcher.rb
246
248
  - lib/knapsack_pro/hooks/queue.rb
247
249
  - lib/knapsack_pro/logger_wrapper.rb
248
250
  - lib/knapsack_pro/mask_string.rb
@@ -335,7 +337,7 @@ files:
335
337
  - spec/knapsack_pro/crypto/decryptor_spec.rb
336
338
  - spec/knapsack_pro/crypto/digestor_spec.rb
337
339
  - spec/knapsack_pro/crypto/encryptor_spec.rb
338
- - spec/knapsack_pro/extensions/time_spec.rb
340
+ - spec/knapsack_pro/formatters/time_tracker_specs.rb
339
341
  - spec/knapsack_pro/hooks/queue_spec.rb
340
342
  - spec/knapsack_pro/logger_wrapper_spec.rb
341
343
  - spec/knapsack_pro/presenter_spec.rb
@@ -388,7 +390,7 @@ licenses:
388
390
  metadata:
389
391
  bug_tracker_uri: https://github.com/KnapsackPro/knapsack_pro-ruby/issues
390
392
  changelog_uri: https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md
391
- documentation_uri: https://docs.knapsackpro.com/integration/
393
+ documentation_uri: https://docs.knapsackpro.com/knapsack_pro-ruby/guide/
392
394
  homepage_uri: https://knapsackpro.com
393
395
  source_code_uri: https://github.com/KnapsackPro/knapsack_pro-ruby
394
396
  post_install_message:
@@ -455,7 +457,7 @@ test_files:
455
457
  - spec/knapsack_pro/crypto/decryptor_spec.rb
456
458
  - spec/knapsack_pro/crypto/digestor_spec.rb
457
459
  - spec/knapsack_pro/crypto/encryptor_spec.rb
458
- - spec/knapsack_pro/extensions/time_spec.rb
460
+ - spec/knapsack_pro/formatters/time_tracker_specs.rb
459
461
  - spec/knapsack_pro/hooks/queue_spec.rb
460
462
  - spec/knapsack_pro/logger_wrapper_spec.rb
461
463
  - spec/knapsack_pro/presenter_spec.rb
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'time'
4
-
5
- class Time
6
- class << self
7
- alias_method :raw_now, :now
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- describe Time do
2
- it do
3
- expect(Time.respond_to?(:raw_now)).to be true
4
- end
5
- end