knapsack_pro 1.20.2 → 1.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +24 -12
- data/lib/knapsack_pro.rb +6 -0
- data/lib/knapsack_pro/adapters/base_adapter.rb +16 -0
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +11 -9
- data/lib/knapsack_pro/allocator.rb +7 -5
- data/lib/knapsack_pro/allocator_builder.rb +2 -1
- data/lib/knapsack_pro/base_allocator_builder.rb +41 -10
- data/lib/knapsack_pro/build_distribution_fetcher.rb +57 -0
- data/lib/knapsack_pro/client/api/v1/build_distributions.rb +13 -0
- data/lib/knapsack_pro/client/connection.rb +30 -12
- data/lib/knapsack_pro/config/env.rb +4 -0
- data/lib/knapsack_pro/queue_allocator.rb +7 -5
- data/lib/knapsack_pro/queue_allocator_builder.rb +2 -1
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +7 -0
- data/lib/knapsack_pro/runners/rspec_runner.rb +5 -2
- data/lib/knapsack_pro/slow_test_file_determiner.rb +28 -0
- data/lib/knapsack_pro/slow_test_file_finder.rb +27 -0
- data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +18 -2
- data/lib/knapsack_pro/test_case_mergers/base_merger.rb +29 -0
- data/lib/knapsack_pro/test_case_mergers/rspec_merger.rb +34 -0
- data/lib/knapsack_pro/test_file_finder.rb +43 -5
- data/lib/knapsack_pro/test_files_with_test_cases_composer.rb +22 -0
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/adapters/base_adapter_spec.rb +55 -0
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +61 -25
- data/spec/knapsack_pro/allocator_builder_spec.rb +7 -3
- data/spec/knapsack_pro/allocator_spec.rb +7 -5
- data/spec/knapsack_pro/base_allocator_builder_spec.rb +79 -27
- data/spec/knapsack_pro/build_distribution_fetcher_spec.rb +89 -0
- data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +31 -0
- data/spec/knapsack_pro/client/connection_spec.rb +165 -103
- data/spec/knapsack_pro/config/env_spec.rb +14 -0
- data/spec/knapsack_pro/queue_allocator_builder_spec.rb +7 -3
- data/spec/knapsack_pro/queue_allocator_spec.rb +7 -5
- data/spec/knapsack_pro/runners/rspec_runner_spec.rb +4 -4
- data/spec/knapsack_pro/slow_test_file_determiner_spec.rb +74 -0
- data/spec/knapsack_pro/slow_test_file_finder_spec.rb +43 -0
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +81 -35
- data/spec/knapsack_pro/test_case_mergers/base_merger_spec.rb +27 -0
- data/spec/knapsack_pro/test_case_mergers/rspec_merger_spec.rb +59 -0
- data/spec/knapsack_pro/test_file_finder_spec.rb +105 -29
- data/spec/knapsack_pro/test_files_with_test_cases_composer_spec.rb +41 -0
- metadata +27 -10
@@ -7,29 +7,105 @@ describe KnapsackPro::TestFileFinder do
|
|
7
7
|
|
8
8
|
before do
|
9
9
|
test_file_finder = instance_double(described_class, call: test_files)
|
10
|
-
expect(described_class).to receive(:new).with(test_file_pattern).and_return(test_file_finder)
|
10
|
+
expect(described_class).to receive(:new).with(test_file_pattern, true).and_return(test_file_finder)
|
11
11
|
end
|
12
12
|
|
13
13
|
it { should eq test_files }
|
14
14
|
end
|
15
15
|
|
16
|
+
describe '.slow_test_files_by_pattern' do
|
17
|
+
let(:adapter_class) { double }
|
18
|
+
|
19
|
+
subject { described_class.slow_test_files_by_pattern(adapter_class) }
|
20
|
+
|
21
|
+
before do
|
22
|
+
expect(KnapsackPro::Config::Env).to receive(:slow_test_file_pattern).at_least(1).and_return(slow_test_file_pattern)
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when slow_test_file_pattern is present' do
|
26
|
+
let(:slow_test_file_pattern) { double }
|
27
|
+
let(:test_file_entities) do
|
28
|
+
[
|
29
|
+
{ 'path' => 'a_spec.rb' },
|
30
|
+
{ 'path' => 'b_spec.rb' },
|
31
|
+
{ 'path' => 'c_spec.rb' },
|
32
|
+
]
|
33
|
+
end
|
34
|
+
let(:slow_test_file_entities) do
|
35
|
+
[
|
36
|
+
{ 'path' => 'b_spec.rb' },
|
37
|
+
{ 'path' => 'c_spec.rb' },
|
38
|
+
{ 'path' => 'd_spec.rb' },
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
it do
|
43
|
+
test_file_pattern = double
|
44
|
+
expect(KnapsackPro::TestFilePattern).to receive(:call).with(adapter_class).and_return(test_file_pattern)
|
45
|
+
expect(described_class).to receive(:call).with(test_file_pattern).and_return(test_file_entities)
|
46
|
+
|
47
|
+
expect(described_class).to receive(:call).with(slow_test_file_pattern, test_file_list_enabled: false).and_return(slow_test_file_entities)
|
48
|
+
|
49
|
+
expect(subject).to eq([
|
50
|
+
{ 'path' => 'b_spec.rb' },
|
51
|
+
{ 'path' => 'c_spec.rb' },
|
52
|
+
])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when slow_test_file_pattern is not present' do
|
57
|
+
let(:slow_test_file_pattern) { nil }
|
58
|
+
|
59
|
+
it do
|
60
|
+
expect { subject }.to raise_error RuntimeError, 'KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN is not defined'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '.select_test_files_that_can_be_run' do
|
66
|
+
let(:adapter_class) { double }
|
67
|
+
let(:test_file_entities_to_run) do
|
68
|
+
[
|
69
|
+
{ 'path' => 'a_spec.rb' },
|
70
|
+
{ 'path' => 'b_spec.rb' },
|
71
|
+
{ 'path' => 'not_existing_on_disk_spec.rb' },
|
72
|
+
]
|
73
|
+
end
|
74
|
+
# test files existing on disk
|
75
|
+
let(:test_file_entities) do
|
76
|
+
[
|
77
|
+
{ 'path' => 'a_spec.rb' },
|
78
|
+
{ 'path' => 'b_spec.rb' },
|
79
|
+
{ 'path' => 'c_spec.rb' },
|
80
|
+
]
|
81
|
+
end
|
82
|
+
|
83
|
+
subject { described_class.select_test_files_that_can_be_run(adapter_class, test_file_entities_to_run) }
|
84
|
+
|
85
|
+
it do
|
86
|
+
test_file_pattern = double
|
87
|
+
expect(KnapsackPro::TestFilePattern).to receive(:call).with(adapter_class).and_return(test_file_pattern)
|
88
|
+
expect(described_class).to receive(:call).with(test_file_pattern).and_return(test_file_entities)
|
89
|
+
|
90
|
+
expect(subject).to eq([
|
91
|
+
{ 'path' => 'a_spec.rb' },
|
92
|
+
{ 'path' => 'b_spec.rb' },
|
93
|
+
])
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
16
97
|
describe '#call' do
|
98
|
+
let(:test_file_list_enabled) { true }
|
17
99
|
let(:test_file_pattern) { 'spec_fake/**{,/*/**}/*_spec.rb' }
|
18
100
|
|
19
|
-
subject { described_class.new(test_file_pattern).call }
|
101
|
+
subject { described_class.new(test_file_pattern, test_file_list_enabled).call }
|
20
102
|
|
21
103
|
context 'when KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN is not defined' do
|
22
104
|
it do
|
23
105
|
should eq([
|
24
|
-
{
|
25
|
-
|
26
|
-
},
|
27
|
-
{
|
28
|
-
'path' => 'spec_fake/models/admin_spec.rb',
|
29
|
-
},
|
30
|
-
{
|
31
|
-
'path' => 'spec_fake/models/user_spec.rb',
|
32
|
-
},
|
106
|
+
{ 'path' => 'spec_fake/controllers/users_controller_spec.rb' },
|
107
|
+
{ 'path' => 'spec_fake/models/admin_spec.rb' },
|
108
|
+
{ 'path' => 'spec_fake/models/user_spec.rb' },
|
33
109
|
])
|
34
110
|
end
|
35
111
|
end
|
@@ -43,12 +119,8 @@ describe KnapsackPro::TestFileFinder do
|
|
43
119
|
|
44
120
|
it do
|
45
121
|
should eq([
|
46
|
-
{
|
47
|
-
|
48
|
-
},
|
49
|
-
{
|
50
|
-
'path' => 'spec_fake/models/user_spec.rb',
|
51
|
-
},
|
122
|
+
{ 'path' => 'spec_fake/models/admin_spec.rb' },
|
123
|
+
{ 'path' => 'spec_fake/models/user_spec.rb' },
|
52
124
|
])
|
53
125
|
end
|
54
126
|
end
|
@@ -63,20 +135,24 @@ describe KnapsackPro::TestFileFinder do
|
|
63
135
|
|
64
136
|
it do
|
65
137
|
expect(subject).to eq([
|
66
|
-
{
|
67
|
-
|
68
|
-
},
|
69
|
-
{
|
70
|
-
'path' => 'spec/foo_spec.rb',
|
71
|
-
},
|
72
|
-
{
|
73
|
-
'path' => 'spec/time_helpers_spec.rb:10',
|
74
|
-
},
|
75
|
-
{
|
76
|
-
'path' => 'spec/time_helpers_spec.rb:38',
|
77
|
-
},
|
138
|
+
{ 'path' => 'spec/bar_spec.rb' },
|
139
|
+
{ 'path' => 'spec/foo_spec.rb' },
|
140
|
+
{ 'path' => 'spec/time_helpers_spec.rb:10' },
|
141
|
+
{ 'path' => 'spec/time_helpers_spec.rb:38' },
|
78
142
|
])
|
79
143
|
end
|
144
|
+
|
145
|
+
context 'when test_file_list_enabled=false' do
|
146
|
+
let(:test_file_list_enabled) { false }
|
147
|
+
|
148
|
+
it do
|
149
|
+
should eq([
|
150
|
+
{ 'path' => 'spec_fake/controllers/users_controller_spec.rb' },
|
151
|
+
{ 'path' => 'spec_fake/models/admin_spec.rb' },
|
152
|
+
{ 'path' => 'spec_fake/models/user_spec.rb' },
|
153
|
+
])
|
154
|
+
end
|
155
|
+
end
|
80
156
|
end
|
81
157
|
end
|
82
158
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
describe KnapsackPro::TestFilesWithTestCasesComposer do
|
2
|
+
let(:test_files) do
|
3
|
+
[
|
4
|
+
{ 'path' => 'spec/a_spec.rb' },
|
5
|
+
{ 'path' => 'spec/b_spec.rb' },
|
6
|
+
{ 'path' => 'spec/c_spec.rb' },
|
7
|
+
{ 'path' => 'spec/slow_1_spec.rb' },
|
8
|
+
{ 'path' => 'spec/slow_2_spec.rb' },
|
9
|
+
]
|
10
|
+
end
|
11
|
+
let(:slow_test_files) do
|
12
|
+
[
|
13
|
+
{ 'path' => 'spec/slow_1_spec.rb', 'time_execution' => 1.0 },
|
14
|
+
{ 'path' => 'spec/slow_2_spec.rb', 'time_execution' => 2.0 },
|
15
|
+
]
|
16
|
+
end
|
17
|
+
let(:test_file_cases) do
|
18
|
+
[
|
19
|
+
{ 'path' => 'spec/slow_1_spec.rb[1:1]' },
|
20
|
+
{ 'path' => 'spec/slow_1_spec.rb[1:2]' },
|
21
|
+
{ 'path' => 'spec/slow_2_spec.rb[1:1:1]' },
|
22
|
+
{ 'path' => 'spec/slow_2_spec.rb[1:1:2]' },
|
23
|
+
{ 'path' => 'spec/slow_2_spec.rb[1:1:3]' },
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
subject { described_class.call(test_files, slow_test_files, test_file_cases) }
|
28
|
+
|
29
|
+
it 'returns test files that are not slow and test file cases for slow test files' do
|
30
|
+
expect(subject).to eq([
|
31
|
+
{ 'path' => 'spec/a_spec.rb' },
|
32
|
+
{ 'path' => 'spec/b_spec.rb' },
|
33
|
+
{ 'path' => 'spec/c_spec.rb' },
|
34
|
+
{ 'path' => 'spec/slow_1_spec.rb[1:1]' },
|
35
|
+
{ 'path' => 'spec/slow_1_spec.rb[1:2]' },
|
36
|
+
{ 'path' => 'spec/slow_2_spec.rb[1:1:1]' },
|
37
|
+
{ 'path' => 'spec/slow_2_spec.rb[1:1:2]' },
|
38
|
+
{ 'path' => 'spec/slow_2_spec.rb[1:1:3]' },
|
39
|
+
])
|
40
|
+
end
|
41
|
+
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: 1.
|
4
|
+
version: 1.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -42,22 +42,22 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
48
45
|
- - ">="
|
49
46
|
- !ruby/object:Gem::Version
|
50
47
|
version: 2.10.0
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '3.0'
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- - "~>"
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '3.0'
|
58
55
|
- - ">="
|
59
56
|
- !ruby/object:Gem::Version
|
60
57
|
version: 2.10.0
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rspec-its
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,6 +229,7 @@ files:
|
|
229
229
|
- lib/knapsack_pro/allocator.rb
|
230
230
|
- lib/knapsack_pro/allocator_builder.rb
|
231
231
|
- lib/knapsack_pro/base_allocator_builder.rb
|
232
|
+
- lib/knapsack_pro/build_distribution_fetcher.rb
|
232
233
|
- lib/knapsack_pro/client/api/action.rb
|
233
234
|
- lib/knapsack_pro/client/api/v1/base.rb
|
234
235
|
- lib/knapsack_pro/client/api/v1/build_distributions.rb
|
@@ -281,12 +282,17 @@ files:
|
|
281
282
|
- lib/knapsack_pro/runners/rspec_runner.rb
|
282
283
|
- lib/knapsack_pro/runners/spinach_runner.rb
|
283
284
|
- lib/knapsack_pro/runners/test_unit_runner.rb
|
285
|
+
- lib/knapsack_pro/slow_test_file_determiner.rb
|
286
|
+
- lib/knapsack_pro/slow_test_file_finder.rb
|
284
287
|
- lib/knapsack_pro/task_loader.rb
|
285
288
|
- lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb
|
289
|
+
- lib/knapsack_pro/test_case_mergers/base_merger.rb
|
290
|
+
- lib/knapsack_pro/test_case_mergers/rspec_merger.rb
|
286
291
|
- lib/knapsack_pro/test_file_cleaner.rb
|
287
292
|
- lib/knapsack_pro/test_file_finder.rb
|
288
293
|
- lib/knapsack_pro/test_file_pattern.rb
|
289
294
|
- lib/knapsack_pro/test_file_presenter.rb
|
295
|
+
- lib/knapsack_pro/test_files_with_test_cases_composer.rb
|
290
296
|
- lib/knapsack_pro/test_flat_distributor.rb
|
291
297
|
- lib/knapsack_pro/tracker.rb
|
292
298
|
- lib/knapsack_pro/utils.rb
|
@@ -317,6 +323,7 @@ files:
|
|
317
323
|
- spec/knapsack_pro/allocator_builder_spec.rb
|
318
324
|
- spec/knapsack_pro/allocator_spec.rb
|
319
325
|
- spec/knapsack_pro/base_allocator_builder_spec.rb
|
326
|
+
- spec/knapsack_pro/build_distribution_fetcher_spec.rb
|
320
327
|
- spec/knapsack_pro/client/api/action_spec.rb
|
321
328
|
- spec/knapsack_pro/client/api/v1/base_spec.rb
|
322
329
|
- spec/knapsack_pro/client/api/v1/build_distributions_spec.rb
|
@@ -365,12 +372,17 @@ files:
|
|
365
372
|
- spec/knapsack_pro/runners/rspec_runner_spec.rb
|
366
373
|
- spec/knapsack_pro/runners/spinach_runner_spec.rb
|
367
374
|
- spec/knapsack_pro/runners/test_unit_runner_spec.rb
|
375
|
+
- spec/knapsack_pro/slow_test_file_determiner_spec.rb
|
376
|
+
- spec/knapsack_pro/slow_test_file_finder_spec.rb
|
368
377
|
- spec/knapsack_pro/task_loader_spec.rb
|
369
378
|
- spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb
|
379
|
+
- spec/knapsack_pro/test_case_mergers/base_merger_spec.rb
|
380
|
+
- spec/knapsack_pro/test_case_mergers/rspec_merger_spec.rb
|
370
381
|
- spec/knapsack_pro/test_file_cleaner_spec.rb
|
371
382
|
- spec/knapsack_pro/test_file_finder_spec.rb
|
372
383
|
- spec/knapsack_pro/test_file_pattern_spec.rb
|
373
384
|
- spec/knapsack_pro/test_file_presenter_spec.rb
|
385
|
+
- spec/knapsack_pro/test_files_with_test_cases_composer_spec.rb
|
374
386
|
- spec/knapsack_pro/test_flat_distributor_spec.rb
|
375
387
|
- spec/knapsack_pro/tracker_spec.rb
|
376
388
|
- spec/knapsack_pro/utils_spec.rb
|
@@ -410,8 +422,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
410
422
|
- !ruby/object:Gem::Version
|
411
423
|
version: '0'
|
412
424
|
requirements: []
|
413
|
-
|
414
|
-
rubygems_version: 2.7.6
|
425
|
+
rubygems_version: 3.0.6
|
415
426
|
signing_key:
|
416
427
|
specification_version: 4
|
417
428
|
summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
|
@@ -432,6 +443,7 @@ test_files:
|
|
432
443
|
- spec/knapsack_pro/allocator_builder_spec.rb
|
433
444
|
- spec/knapsack_pro/allocator_spec.rb
|
434
445
|
- spec/knapsack_pro/base_allocator_builder_spec.rb
|
446
|
+
- spec/knapsack_pro/build_distribution_fetcher_spec.rb
|
435
447
|
- spec/knapsack_pro/client/api/action_spec.rb
|
436
448
|
- spec/knapsack_pro/client/api/v1/base_spec.rb
|
437
449
|
- spec/knapsack_pro/client/api/v1/build_distributions_spec.rb
|
@@ -480,12 +492,17 @@ test_files:
|
|
480
492
|
- spec/knapsack_pro/runners/rspec_runner_spec.rb
|
481
493
|
- spec/knapsack_pro/runners/spinach_runner_spec.rb
|
482
494
|
- spec/knapsack_pro/runners/test_unit_runner_spec.rb
|
495
|
+
- spec/knapsack_pro/slow_test_file_determiner_spec.rb
|
496
|
+
- spec/knapsack_pro/slow_test_file_finder_spec.rb
|
483
497
|
- spec/knapsack_pro/task_loader_spec.rb
|
484
498
|
- spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb
|
499
|
+
- spec/knapsack_pro/test_case_mergers/base_merger_spec.rb
|
500
|
+
- spec/knapsack_pro/test_case_mergers/rspec_merger_spec.rb
|
485
501
|
- spec/knapsack_pro/test_file_cleaner_spec.rb
|
486
502
|
- spec/knapsack_pro/test_file_finder_spec.rb
|
487
503
|
- spec/knapsack_pro/test_file_pattern_spec.rb
|
488
504
|
- spec/knapsack_pro/test_file_presenter_spec.rb
|
505
|
+
- spec/knapsack_pro/test_files_with_test_cases_composer_spec.rb
|
489
506
|
- spec/knapsack_pro/test_flat_distributor_spec.rb
|
490
507
|
- spec/knapsack_pro/tracker_spec.rb
|
491
508
|
- spec/knapsack_pro/utils_spec.rb
|