knapsack_pro 6.0.3 → 7.0.0
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 +4 -4
- data/.circleci/config.yml +375 -28
- data/.github/pull_request_template.md +22 -0
- data/.gitignore +4 -0
- data/CHANGELOG.md +95 -0
- data/Gemfile +9 -0
- data/README.md +0 -7
- data/knapsack_pro.gemspec +2 -1
- data/lib/knapsack_pro/adapters/base_adapter.rb +7 -2
- data/lib/knapsack_pro/adapters/cucumber_adapter.rb +1 -3
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +16 -9
- data/lib/knapsack_pro/config/env.rb +1 -9
- data/lib/knapsack_pro/extensions/rspec_extension.rb +137 -0
- data/lib/knapsack_pro/formatters/time_tracker.rb +10 -26
- data/lib/knapsack_pro/formatters/time_tracker_fetcher.rb +8 -0
- data/lib/knapsack_pro/presenter.rb +1 -1
- data/lib/knapsack_pro/pure/queue/rspec_pure.rb +92 -0
- data/lib/knapsack_pro/runners/queue/base_runner.rb +6 -1
- data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +6 -6
- data/lib/knapsack_pro/runners/queue/minitest_runner.rb +10 -6
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +124 -173
- data/lib/knapsack_pro/urls.rb +2 -0
- data/lib/knapsack_pro/version.rb +1 -1
- data/lib/knapsack_pro.rb +1 -0
- data/spec/integration/runners/queue/rspec_runner.rb +80 -0
- data/spec/integration/runners/queue/rspec_runner_spec.rb +2232 -0
- data/spec/knapsack_pro/adapters/base_adapter_spec.rb +17 -11
- data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +2 -5
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +2 -24
- data/spec/knapsack_pro/config/env_spec.rb +1 -35
- data/spec/knapsack_pro/formatters/time_tracker_specs.rb +8 -37
- data/spec/knapsack_pro/hooks/queue_spec.rb +2 -2
- data/spec/knapsack_pro/presenter_spec.rb +1 -1
- data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +224 -0
- data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +16 -16
- data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +14 -14
- data/spec/knapsack_pro_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -1
- metadata +17 -12
- data/lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb +0 -58
- data/lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb +0 -145
- data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +0 -536
@@ -159,7 +159,7 @@ describe KnapsackPro::Adapters::BaseAdapter do
|
|
159
159
|
it do
|
160
160
|
logger = instance_double(Logger)
|
161
161
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
162
|
-
expect(logger).to receive(:debug).with('
|
162
|
+
expect(logger).to receive(:debug).with('Regular Mode enabled.')
|
163
163
|
end
|
164
164
|
it { expect(subject).to receive(:bind_time_tracker) }
|
165
165
|
it { expect(subject).to receive(:bind_save_report) }
|
@@ -168,24 +168,22 @@ describe KnapsackPro::Adapters::BaseAdapter do
|
|
168
168
|
context 'when queue recording enabled' do
|
169
169
|
let(:queue_recording_enabled?) { true }
|
170
170
|
|
171
|
-
before do
|
172
|
-
allow(subject).to receive(:bind_before_queue_hook)
|
173
|
-
allow(subject).to receive(:bind_time_tracker)
|
174
|
-
end
|
175
|
-
|
176
|
-
it do
|
171
|
+
it 'calls queue hooks in proper order before binding time tracker' do
|
177
172
|
logger = instance_double(Logger)
|
178
173
|
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
179
|
-
expect(logger).to receive(:debug).with('
|
174
|
+
expect(logger).to receive(:debug).with('Queue Mode enabled.')
|
175
|
+
|
176
|
+
expect(subject).to receive(:bind_before_queue_hook).ordered
|
177
|
+
expect(subject).to receive(:bind_after_queue_hook).ordered
|
178
|
+
expect(subject).to receive(:bind_time_tracker).ordered
|
180
179
|
end
|
181
|
-
it { expect(subject).to receive(:bind_before_queue_hook) }
|
182
|
-
it { expect(subject).to receive(:bind_time_tracker) }
|
183
180
|
end
|
184
181
|
|
185
182
|
context 'when recording disabled' do
|
186
|
-
it { expect(subject).not_to receive(:bind_time_tracker) }
|
187
183
|
it { expect(subject).not_to receive(:bind_save_report) }
|
188
184
|
it { expect(subject).not_to receive(:bind_before_queue_hook) }
|
185
|
+
it { expect(subject).not_to receive(:bind_after_queue_hook) }
|
186
|
+
it { expect(subject).not_to receive(:bind_time_tracker) }
|
189
187
|
end
|
190
188
|
end
|
191
189
|
|
@@ -212,4 +210,12 @@ describe KnapsackPro::Adapters::BaseAdapter do
|
|
212
210
|
}.to raise_error(NotImplementedError)
|
213
211
|
end
|
214
212
|
end
|
213
|
+
|
214
|
+
describe '#bind_after_queue_hook' do
|
215
|
+
it do
|
216
|
+
expect {
|
217
|
+
subject.bind_after_queue_hook
|
218
|
+
}.to raise_error(NotImplementedError)
|
219
|
+
end
|
220
|
+
end
|
215
221
|
end
|
@@ -203,16 +203,13 @@ describe KnapsackPro::Adapters::CucumberAdapter do
|
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
206
|
-
describe '#
|
206
|
+
describe '#bind_after_queue_hook' do
|
207
207
|
it do
|
208
|
-
expect(subject).to receive(:bind_before_queue_hook)
|
209
|
-
expect(subject).to receive(:bind_time_tracker)
|
210
|
-
|
211
208
|
expect(::Kernel).to receive(:at_exit).and_yield
|
212
209
|
expect(KnapsackPro::Hooks::Queue).to receive(:call_after_subset_queue)
|
213
210
|
expect(KnapsackPro::Report).to receive(:save_subset_queue_to_file)
|
214
211
|
|
215
|
-
subject.
|
212
|
+
subject.bind_after_queue_hook
|
216
213
|
end
|
217
214
|
end
|
218
215
|
end
|
@@ -341,24 +341,13 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
341
341
|
end
|
342
342
|
|
343
343
|
context 'with no focus' do
|
344
|
-
let(:logger) { instance_double(Logger) }
|
345
|
-
let(:duration) { 65 }
|
346
|
-
let(:global_time) { 'Global time execution for tests: 01m 05s' }
|
347
|
-
let(:time_tracker) { instance_double(KnapsackPro::Formatters::TimeTracker) }
|
348
|
-
|
349
344
|
it 'records time for current test path' do
|
350
345
|
expect(config).to receive(:around).with(:each).and_yield(current_example)
|
351
|
-
expect(config).to receive(:
|
352
|
-
expect(::RSpec).to receive(:configure).
|
346
|
+
expect(config).to receive(:append_after).with(:suite)
|
347
|
+
expect(::RSpec).to receive(:configure).at_least(1).and_yield(config)
|
353
348
|
|
354
349
|
expect(current_example).to receive(:run)
|
355
350
|
|
356
|
-
expect(time_tracker).to receive(:batch_duration).and_return(duration)
|
357
|
-
expect(KnapsackPro::Formatters::TimeTrackerFetcher).to receive(:call).and_return(time_tracker)
|
358
|
-
|
359
|
-
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
360
|
-
expect(logger).to receive(:debug).with(global_time)
|
361
|
-
|
362
351
|
subject.bind_time_tracker
|
363
352
|
end
|
364
353
|
end
|
@@ -378,16 +367,5 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
378
367
|
subject.bind_save_report
|
379
368
|
end
|
380
369
|
end
|
381
|
-
|
382
|
-
describe '#bind_before_queue_hook' do
|
383
|
-
it do
|
384
|
-
expect(config).to receive(:before).with(:suite).and_yield
|
385
|
-
expect(::RSpec).to receive(:configure).and_yield(config)
|
386
|
-
|
387
|
-
expect(KnapsackPro::Hooks::Queue).to receive(:call_before_queue)
|
388
|
-
|
389
|
-
subject.bind_before_queue_hook
|
390
|
-
end
|
391
|
-
end
|
392
370
|
end
|
393
371
|
end
|
@@ -511,40 +511,6 @@ describe KnapsackPro::Config::Env do
|
|
511
511
|
end
|
512
512
|
end
|
513
513
|
|
514
|
-
describe '.modify_default_rspec_formatters' do
|
515
|
-
subject { described_class.modify_default_rspec_formatters }
|
516
|
-
|
517
|
-
context 'when ENV exists' do
|
518
|
-
let(:modify_default_rspec_formatters) { 'false' }
|
519
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_MODIFY_DEFAULT_RSPEC_FORMATTERS' => modify_default_rspec_formatters }) }
|
520
|
-
it { should eq modify_default_rspec_formatters }
|
521
|
-
end
|
522
|
-
|
523
|
-
context "when ENV doesn't exist" do
|
524
|
-
it { should be true }
|
525
|
-
end
|
526
|
-
end
|
527
|
-
|
528
|
-
describe '.modify_default_rspec_formatters?' do
|
529
|
-
subject { described_class.modify_default_rspec_formatters? }
|
530
|
-
|
531
|
-
before do
|
532
|
-
expect(described_class).to receive(:modify_default_rspec_formatters).and_return(modify_default_rspec_formatters)
|
533
|
-
end
|
534
|
-
|
535
|
-
context 'when enabled' do
|
536
|
-
let(:modify_default_rspec_formatters) { true }
|
537
|
-
|
538
|
-
it { should be true }
|
539
|
-
end
|
540
|
-
|
541
|
-
context 'when disabled' do
|
542
|
-
let(:modify_default_rspec_formatters) { false }
|
543
|
-
|
544
|
-
it { should be false }
|
545
|
-
end
|
546
|
-
end
|
547
|
-
|
548
514
|
describe '.branch_encrypted' do
|
549
515
|
subject { described_class.branch_encrypted }
|
550
516
|
|
@@ -975,7 +941,7 @@ describe KnapsackPro::Config::Env do
|
|
975
941
|
end
|
976
942
|
|
977
943
|
context "when ENV doesn't exist" do
|
978
|
-
it { should eql ::Logger::
|
944
|
+
it { should eql ::Logger::INFO }
|
979
945
|
end
|
980
946
|
end
|
981
947
|
|
@@ -4,6 +4,7 @@
|
|
4
4
|
require 'rspec/core'
|
5
5
|
require 'knapsack_pro'
|
6
6
|
require 'stringio'
|
7
|
+
require 'tempfile'
|
7
8
|
require_relative '../../../lib/knapsack_pro/formatters/time_tracker'
|
8
9
|
|
9
10
|
class TestTimeTracker
|
@@ -327,24 +328,6 @@ class TestTimeTracker
|
|
327
328
|
end
|
328
329
|
end
|
329
330
|
|
330
|
-
def test_batch_duration
|
331
|
-
KnapsackPro::Formatters::TimeTracker.define_method(:rspec_split_by_test_example?) do |_file|
|
332
|
-
false
|
333
|
-
end
|
334
|
-
|
335
|
-
spec = <<~SPEC
|
336
|
-
describe "KnapsackPro::Formatters::TimeTracker" do
|
337
|
-
it do
|
338
|
-
expect(1).to eq 1
|
339
|
-
end
|
340
|
-
end
|
341
|
-
SPEC
|
342
|
-
|
343
|
-
run_specs(spec) do |_, _, time_tracker|
|
344
|
-
raise unless time_tracker.batch_duration > 0.0
|
345
|
-
end
|
346
|
-
end
|
347
|
-
|
348
331
|
def test_unexecuted_test_files
|
349
332
|
KnapsackPro::Formatters::TimeTracker.define_method(:rspec_split_by_test_example?) do |_file|
|
350
333
|
false
|
@@ -372,14 +355,6 @@ class TestTimeTracker
|
|
372
355
|
KnapsackPro::Formatters::TimeTracker.define_method(:rspec_split_by_test_example?) do |_file|
|
373
356
|
false
|
374
357
|
end
|
375
|
-
KnapsackPro::Formatters::TimeTracker.class_eval do
|
376
|
-
alias_method :original_stop, :stop
|
377
|
-
|
378
|
-
# In Regular Mode, #subset is called before #stop.
|
379
|
-
# This test makes #stop a noop to simulate that behavior.
|
380
|
-
define_method(:stop) do |_|
|
381
|
-
end
|
382
|
-
end
|
383
358
|
|
384
359
|
spec = <<~SPEC
|
385
360
|
describe "KnapsackPro::Formatters::TimeTracker" do
|
@@ -401,23 +376,20 @@ class TestTimeTracker
|
|
401
376
|
raise unless files[0]["time_execution"] > 0.10
|
402
377
|
raise unless files[0]["time_execution"] < 0.15
|
403
378
|
end
|
404
|
-
|
405
|
-
ensure
|
406
|
-
KnapsackPro::Formatters::TimeTracker.class_eval do
|
407
|
-
undef :stop
|
408
|
-
alias_method :stop, :original_stop
|
409
|
-
end
|
410
379
|
end
|
411
380
|
|
412
381
|
private
|
413
382
|
|
414
383
|
def run_specs(specs)
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
384
|
+
files = Array(specs).map.with_index do |spec, i|
|
385
|
+
file = Tempfile.new(["time_tracker_#{i}", "_spec.rb"], "./spec/knapsack_pro/formatters/")
|
386
|
+
file.write(spec)
|
387
|
+
file.rewind
|
388
|
+
file
|
419
389
|
end
|
420
390
|
|
391
|
+
paths = files.map(&:path).map { _1.sub("./", "") }
|
392
|
+
|
421
393
|
options = ::RSpec::Core::ConfigurationOptions.new([
|
422
394
|
"--format", KnapsackPro::Formatters::TimeTracker.to_s,
|
423
395
|
*paths,
|
@@ -436,7 +408,6 @@ class TestTimeTracker
|
|
436
408
|
yield(paths, times, time_tracker)
|
437
409
|
|
438
410
|
ensure
|
439
|
-
paths.each { |path| File.delete(path) }
|
440
411
|
# Need to reset because RSpec keeps reusing the same instance.
|
441
412
|
time_tracker.instance_variable_set(:@queue, {}) if time_tracker
|
442
413
|
time_tracker.instance_variable_set(:@started, time_tracker.send(:now)) if time_tracker
|
@@ -93,8 +93,8 @@ describe KnapsackPro::Hooks::Queue do
|
|
93
93
|
let(:subset_queue_id) { double }
|
94
94
|
|
95
95
|
before do
|
96
|
-
expect(KnapsackPro::Config::Env).to receive(:queue_id).
|
97
|
-
expect(KnapsackPro::Config::Env).to receive(:subset_queue_id).
|
96
|
+
expect(KnapsackPro::Config::Env).to receive(:queue_id).at_least(:once).and_return(queue_id)
|
97
|
+
expect(KnapsackPro::Config::Env).to receive(:subset_queue_id).at_least(:once).and_return(subset_queue_id)
|
98
98
|
|
99
99
|
$expected_called_blocks = []
|
100
100
|
|
@@ -8,7 +8,7 @@ describe KnapsackPro::Presenter do
|
|
8
8
|
expect(KnapsackPro).to receive(:tracker).and_return(tracker)
|
9
9
|
end
|
10
10
|
|
11
|
-
it { should eql "Global
|
11
|
+
it { should eql "Global test execution duration: 01h 02m 03s" }
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '.pretty_seconds' do
|
@@ -0,0 +1,224 @@
|
|
1
|
+
require(KnapsackPro.root + '/lib/knapsack_pro/formatters/time_tracker')
|
2
|
+
require(KnapsackPro.root + '/lib/knapsack_pro/extensions/rspec_extension')
|
3
|
+
|
4
|
+
describe KnapsackPro::Pure::Queue::RSpecPure do
|
5
|
+
let(:rspec_pure) { described_class.new }
|
6
|
+
|
7
|
+
describe '#add_knapsack_pro_formatters_to' do
|
8
|
+
subject { rspec_pure.add_knapsack_pro_formatters_to(spec_opts) }
|
9
|
+
|
10
|
+
context 'when no spec_opts' do
|
11
|
+
let(:spec_opts) { nil }
|
12
|
+
|
13
|
+
it 'returns no spec_opts' do
|
14
|
+
expect(subject).to be nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when spec_opts have Knapsack Pro formatters' do
|
19
|
+
let(:spec_opts) { '--color --format d --format KnapsackPro::Formatters::TimeTracker' }
|
20
|
+
|
21
|
+
it 'returns spec_opts' do
|
22
|
+
expect(subject).to eq spec_opts
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when spec_opts have no Knapsack Pro formatters' do
|
27
|
+
let(:spec_opts) { '--color --format d' }
|
28
|
+
|
29
|
+
it 'returns spec_opts with added Knapsack Pro formatters' do
|
30
|
+
expect(subject).to eq '--color --format d --format KnapsackPro::Formatters::TimeTracker'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#error_exit_code' do
|
36
|
+
subject { rspec_pure.error_exit_code(rspec_error_exit_code) }
|
37
|
+
|
38
|
+
context 'when RSpec has no defined error exit code' do
|
39
|
+
let(:rspec_error_exit_code) { nil }
|
40
|
+
|
41
|
+
it 'returns 1 as the default exit code' do
|
42
|
+
expect(subject).to eq 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when RSpec has a defined error exit code' do
|
47
|
+
let(:rspec_error_exit_code) { 2 }
|
48
|
+
|
49
|
+
it 'returns the custom exit code' do
|
50
|
+
expect(subject).to eq rspec_error_exit_code
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#args_with_seed_option_added_when_viable' do
|
56
|
+
let(:order_option) { KnapsackPro::Adapters::RSpecAdapter.order_option(args) }
|
57
|
+
|
58
|
+
subject { rspec_pure.args_with_seed_option_added_when_viable(order_option, seed, args) }
|
59
|
+
|
60
|
+
context 'when the order option is not random' do
|
61
|
+
let(:args) { ['--order', 'defined'] }
|
62
|
+
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new(value: nil, used?: false) }
|
63
|
+
|
64
|
+
it 'does not add the seed option to args' do
|
65
|
+
expect(subject).to eq ['--order', 'defined']
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
['random', 'rand'].each do |random_option_value|
|
70
|
+
context "when the order option is `#{random_option_value}`" do
|
71
|
+
let(:args) { ['--order', random_option_value] }
|
72
|
+
|
73
|
+
context 'when the seed is not used' do
|
74
|
+
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new(value: '123', used?: false) }
|
75
|
+
|
76
|
+
it 'does not add the seed option to args' do
|
77
|
+
expect(subject).to eq ['--order', random_option_value]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when the seed is used' do
|
82
|
+
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new(value: '123', used?: true) }
|
83
|
+
|
84
|
+
it 'adds the seed option to args' do
|
85
|
+
expect(subject).to eq ['--order', random_option_value, '--seed', '123']
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'when the order option is `rand:123`' do
|
92
|
+
let(:args) { ['--order', 'rand:123'] }
|
93
|
+
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new(value: '123', used?: true) }
|
94
|
+
|
95
|
+
it 'does not add the seed option to args' do
|
96
|
+
expect(subject).to eq ['--order', 'rand:123']
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'when the order option is not set in args AND seed is used' do
|
101
|
+
let(:args) { ['--format', 'documentation'] }
|
102
|
+
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new(value: '123', used?: true) }
|
103
|
+
|
104
|
+
it 'adds the seed option to args' do
|
105
|
+
expect(subject).to eq ['--format', 'documentation', '--seed', '123']
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'when the order option is not set in args AND seed is not used' do
|
110
|
+
let(:args) { ['--format', 'documentation'] }
|
111
|
+
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new(value: '123', used?: false) }
|
112
|
+
|
113
|
+
it 'does not add the seed option to args' do
|
114
|
+
expect(subject).to eq ['--format', 'documentation']
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#prepare_cli_args' do
|
120
|
+
subject { rspec_pure.prepare_cli_args(args, has_format_option, test_dir) }
|
121
|
+
|
122
|
+
context 'when no args' do
|
123
|
+
let(:args) { nil }
|
124
|
+
let(:has_format_option) { false }
|
125
|
+
let(:test_dir) { 'spec' }
|
126
|
+
|
127
|
+
it 'adds the default progress formatter and the default path and the time tracker formatter' do
|
128
|
+
expect(subject).to eq [
|
129
|
+
'--format', 'progress',
|
130
|
+
'--default-path', 'spec',
|
131
|
+
'--format', 'KnapsackPro::Formatters::TimeTracker',
|
132
|
+
]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'when args are present and a custom test directory is set' do
|
137
|
+
let(:args) { '--color --profile' }
|
138
|
+
let(:has_format_option) { false }
|
139
|
+
let(:test_dir) { 'custom_spec_dir' }
|
140
|
+
|
141
|
+
it do
|
142
|
+
expect(subject).to eq [
|
143
|
+
'--color',
|
144
|
+
'--profile',
|
145
|
+
'--format', 'progress',
|
146
|
+
'--default-path', 'custom_spec_dir',
|
147
|
+
'--format', 'KnapsackPro::Formatters::TimeTracker',
|
148
|
+
]
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context 'when args are present and has format option' do
|
153
|
+
let(:args) { '--color --profile --format d' }
|
154
|
+
let(:has_format_option) { true }
|
155
|
+
let(:test_dir) { 'spec' }
|
156
|
+
|
157
|
+
it 'uses the format option from args instead of the default formatter' do
|
158
|
+
expect(subject).to eq [
|
159
|
+
'--color',
|
160
|
+
'--profile',
|
161
|
+
'--format', 'd',
|
162
|
+
'--default-path', 'spec',
|
163
|
+
'--format', 'KnapsackPro::Formatters::TimeTracker',
|
164
|
+
]
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe '#rspec_command' do
|
170
|
+
let(:args) { ['--format', 'documentation'] }
|
171
|
+
let(:test_file_paths) { ['a_spec.rb', 'b_spec.rb'] }
|
172
|
+
|
173
|
+
subject { rspec_pure.rspec_command(args, test_file_paths, scope) }
|
174
|
+
|
175
|
+
context 'when there are no test file paths' do
|
176
|
+
let(:scope) { :queue_finished }
|
177
|
+
let(:test_file_paths) { [] }
|
178
|
+
|
179
|
+
it 'returns no messages' do
|
180
|
+
expect(subject).to eq []
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
context 'when a subset of queue (a batch of tests fetched from the Queue API)' do
|
185
|
+
let(:scope) { :batch_finished }
|
186
|
+
|
187
|
+
it 'returns messages with the RSpec command' do
|
188
|
+
expect(subject).to eq([
|
189
|
+
'To retry the last batch of tests fetched from the Queue API, please run the following command on your machine:',
|
190
|
+
'bundle exec rspec --format documentation "a_spec.rb" "b_spec.rb"',
|
191
|
+
])
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context 'when all tests fetched from the Queue API' do
|
196
|
+
let(:scope) { :queue_finished }
|
197
|
+
|
198
|
+
it 'returns messages with the RSpec command' do
|
199
|
+
expect(subject).to eq([
|
200
|
+
'To retry all the tests assigned to this CI node, please run the following command on your machine:',
|
201
|
+
'bundle exec rspec --format documentation "a_spec.rb" "b_spec.rb"',
|
202
|
+
])
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
describe '#exit_summary' do
|
207
|
+
subject { rspec_pure.exit_summary(unexecuted_test_files) }
|
208
|
+
|
209
|
+
context 'when there are no unexecuted test files' do
|
210
|
+
let(:unexecuted_test_files) { [] }
|
211
|
+
|
212
|
+
it { expect(subject).to be_nil }
|
213
|
+
end
|
214
|
+
|
215
|
+
context 'when there are unexecuted test files' do
|
216
|
+
let(:unexecuted_test_files) { ['b_spec.rb', 'c_spec.rb'] }
|
217
|
+
|
218
|
+
it 'returns a warning message' do
|
219
|
+
expect(subject).to eq 'Unexecuted tests on this CI node (including pending tests): b_spec.rb c_spec.rb'
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
@@ -24,7 +24,7 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
|
|
24
24
|
expect(described_class).to receive(:new).with(KnapsackPro::Adapters::CucumberAdapter).and_return(runner)
|
25
25
|
end
|
26
26
|
|
27
|
-
context 'when args provided' do
|
27
|
+
context 'when args are provided' do
|
28
28
|
let(:args) { '--retry 5 --no-strict-flaky' }
|
29
29
|
|
30
30
|
it do
|
@@ -39,7 +39,7 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
|
|
39
39
|
can_initialize_queue: true,
|
40
40
|
args: args,
|
41
41
|
exitstatus: 0,
|
42
|
-
|
42
|
+
node_test_file_paths: [],
|
43
43
|
}
|
44
44
|
expect(described_class).to receive(:handle_signal!)
|
45
45
|
expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
|
@@ -50,7 +50,7 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
context 'when args not provided' do
|
53
|
+
context 'when args are not provided' do
|
54
54
|
let(:args) { nil }
|
55
55
|
|
56
56
|
it do
|
@@ -65,7 +65,7 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
|
|
65
65
|
can_initialize_queue: true,
|
66
66
|
args: nil,
|
67
67
|
exitstatus: 0,
|
68
|
-
|
68
|
+
node_test_file_paths: [],
|
69
69
|
}
|
70
70
|
expect(described_class).to receive(:handle_signal!)
|
71
71
|
expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
|
@@ -85,21 +85,21 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
|
|
85
85
|
let(:can_initialize_queue) { double(:can_initialize_queue) }
|
86
86
|
let(:args) { '--retry 5 --no-strict-flaky' }
|
87
87
|
let(:exitstatus) { 0 }
|
88
|
-
let(:
|
88
|
+
let(:node_test_file_paths) { [] }
|
89
89
|
let(:accumulator) do
|
90
90
|
{
|
91
91
|
runner: runner,
|
92
92
|
can_initialize_queue: can_initialize_queue,
|
93
93
|
args: args,
|
94
94
|
exitstatus: exitstatus,
|
95
|
-
|
95
|
+
node_test_file_paths: node_test_file_paths,
|
96
96
|
}
|
97
97
|
end
|
98
98
|
|
99
99
|
subject { described_class.run_tests(accumulator) }
|
100
100
|
|
101
101
|
before do
|
102
|
-
expect(runner).to receive(:test_file_paths).with(can_initialize_queue: can_initialize_queue, executed_test_files:
|
102
|
+
expect(runner).to receive(:test_file_paths).with(can_initialize_queue: can_initialize_queue, executed_test_files: node_test_file_paths).and_return(test_file_paths)
|
103
103
|
end
|
104
104
|
|
105
105
|
context 'when test files exist' do
|
@@ -129,7 +129,7 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
|
|
129
129
|
allow(child_status).to receive(:exitstatus).and_return(exitstatus)
|
130
130
|
end
|
131
131
|
|
132
|
-
context 'when system process finished
|
132
|
+
context 'when system process finished (exited)' do
|
133
133
|
let(:process_exited) { true }
|
134
134
|
|
135
135
|
context 'when tests are passing' do
|
@@ -142,7 +142,7 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
|
|
142
142
|
can_initialize_queue: false,
|
143
143
|
args: args,
|
144
144
|
exitstatus: exitstatus,
|
145
|
-
|
145
|
+
node_test_file_paths: test_file_paths,
|
146
146
|
})
|
147
147
|
end
|
148
148
|
end
|
@@ -157,13 +157,13 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
|
|
157
157
|
can_initialize_queue: false,
|
158
158
|
args: args,
|
159
159
|
exitstatus: 1, # tests failed
|
160
|
-
|
160
|
+
node_test_file_paths: test_file_paths,
|
161
161
|
})
|
162
162
|
end
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
-
context
|
166
|
+
context 'when system process did not finish (it has not exited)' do
|
167
167
|
let(:process_exited) { false }
|
168
168
|
|
169
169
|
it 'raises an error' do
|
@@ -172,11 +172,11 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
-
context
|
175
|
+
context 'when test files do not exist' do
|
176
176
|
let(:test_file_paths) { [] }
|
177
177
|
|
178
|
-
context 'when
|
179
|
-
let(:
|
178
|
+
context 'when node_test_file_paths exists' do
|
179
|
+
let(:node_test_file_paths) { ['features/a.feature'] }
|
180
180
|
|
181
181
|
it 'returns exit code 0' do
|
182
182
|
expect(KnapsackPro::Adapters::CucumberAdapter).to receive(:verify_bind_method_called)
|
@@ -191,8 +191,8 @@ describe KnapsackPro::Runners::Queue::CucumberRunner do
|
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
|
-
context
|
195
|
-
let(:
|
194
|
+
context 'when node_test_file_paths do not exist' do
|
195
|
+
let(:node_test_file_paths) { [] }
|
196
196
|
|
197
197
|
it 'returns exit code 0' do
|
198
198
|
expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue)
|