knapsack_pro 3.8.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +377 -23
- data/.github/dependabot.yml +11 -0
- data/.github/pull_request_template.md +22 -0
- data/.gitignore +4 -0
- data/CHANGELOG.md +325 -1
- data/Gemfile +9 -0
- data/README.md +3 -10
- data/bin/test +15 -0
- data/knapsack_pro.gemspec +7 -6
- data/lib/knapsack_pro/adapters/base_adapter.rb +17 -2
- data/lib/knapsack_pro/adapters/cucumber_adapter.rb +3 -3
- data/lib/knapsack_pro/adapters/minitest_adapter.rb +2 -0
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +88 -49
- data/lib/knapsack_pro/adapters/spinach_adapter.rb +2 -0
- data/lib/knapsack_pro/adapters/test_unit_adapter.rb +2 -0
- data/lib/knapsack_pro/allocator.rb +2 -0
- data/lib/knapsack_pro/allocator_builder.rb +2 -0
- data/lib/knapsack_pro/base_allocator_builder.rb +8 -25
- data/lib/knapsack_pro/build_distribution_fetcher.rb +2 -0
- data/lib/knapsack_pro/client/api/action.rb +2 -0
- data/lib/knapsack_pro/client/api/v1/base.rb +2 -0
- data/lib/knapsack_pro/client/api/v1/build_distributions.rb +5 -0
- data/lib/knapsack_pro/client/api/v1/build_subsets.rb +2 -0
- data/lib/knapsack_pro/client/api/v1/queues.rb +6 -1
- data/lib/knapsack_pro/client/connection.rb +5 -6
- data/lib/knapsack_pro/config/ci/app_veyor.rb +18 -0
- data/lib/knapsack_pro/config/ci/base.rb +27 -0
- data/lib/knapsack_pro/config/ci/buildkite.rb +18 -0
- data/lib/knapsack_pro/config/ci/circle.rb +18 -0
- data/lib/knapsack_pro/config/ci/cirrus_ci.rb +18 -0
- data/lib/knapsack_pro/config/ci/codefresh.rb +18 -0
- data/lib/knapsack_pro/config/ci/codeship.rb +18 -0
- data/lib/knapsack_pro/config/ci/github_actions.rb +26 -0
- data/lib/knapsack_pro/config/ci/gitlab_ci.rb +20 -1
- data/lib/knapsack_pro/config/ci/heroku.rb +18 -0
- data/lib/knapsack_pro/config/ci/semaphore.rb +16 -0
- data/lib/knapsack_pro/config/ci/semaphore2.rb +19 -0
- data/lib/knapsack_pro/config/ci/travis.rb +18 -0
- data/lib/knapsack_pro/config/env.rb +46 -22
- data/lib/knapsack_pro/config/env_generator.rb +2 -0
- data/lib/knapsack_pro/config/temp_files.rb +8 -4
- data/lib/knapsack_pro/crypto/branch_encryptor.rb +2 -0
- data/lib/knapsack_pro/crypto/decryptor.rb +2 -0
- data/lib/knapsack_pro/crypto/digestor.rb +2 -0
- data/lib/knapsack_pro/crypto/encryptor.rb +2 -0
- data/lib/knapsack_pro/extensions/rspec_extension.rb +137 -0
- data/lib/knapsack_pro/formatters/rspec_json_formatter.rb +2 -0
- data/lib/knapsack_pro/formatters/time_tracker.rb +152 -0
- data/lib/knapsack_pro/formatters/time_tracker_fetcher.rb +20 -0
- data/lib/knapsack_pro/hooks/queue.rb +2 -0
- data/lib/knapsack_pro/logger_wrapper.rb +2 -0
- data/lib/knapsack_pro/mask_string.rb +9 -0
- data/lib/knapsack_pro/presenter.rb +6 -3
- data/lib/knapsack_pro/pure/queue/rspec_pure.rb +92 -0
- data/lib/knapsack_pro/queue_allocator.rb +2 -0
- data/lib/knapsack_pro/queue_allocator_builder.rb +2 -0
- data/lib/knapsack_pro/railtie.rb +2 -0
- data/lib/knapsack_pro/report.rb +15 -9
- data/lib/knapsack_pro/repository_adapter_initiator.rb +2 -0
- data/lib/knapsack_pro/repository_adapters/base_adapter.rb +2 -0
- data/lib/knapsack_pro/repository_adapters/env_adapter.rb +2 -0
- data/lib/knapsack_pro/repository_adapters/git_adapter.rb +50 -0
- data/lib/knapsack_pro/runners/base_runner.rb +2 -0
- data/lib/knapsack_pro/runners/cucumber_runner.rb +2 -0
- data/lib/knapsack_pro/runners/minitest_runner.rb +2 -0
- data/lib/knapsack_pro/runners/queue/base_runner.rb +29 -0
- data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +9 -6
- data/lib/knapsack_pro/runners/queue/minitest_runner.rb +13 -6
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +128 -135
- data/lib/knapsack_pro/runners/rspec_runner.rb +22 -3
- data/lib/knapsack_pro/runners/spinach_runner.rb +2 -0
- data/lib/knapsack_pro/runners/test_unit_runner.rb +2 -0
- data/lib/knapsack_pro/slow_test_file_determiner.rb +2 -0
- data/lib/knapsack_pro/slow_test_file_finder.rb +2 -0
- data/lib/knapsack_pro/task_loader.rb +2 -0
- data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +2 -0
- data/lib/knapsack_pro/test_case_mergers/base_merger.rb +2 -0
- data/lib/knapsack_pro/test_case_mergers/rspec_merger.rb +2 -0
- data/lib/knapsack_pro/test_file_cleaner.rb +2 -0
- data/lib/knapsack_pro/test_file_finder.rb +2 -0
- data/lib/knapsack_pro/test_file_pattern.rb +2 -0
- data/lib/knapsack_pro/test_file_presenter.rb +2 -0
- data/lib/knapsack_pro/test_files_with_test_cases_composer.rb +2 -0
- data/lib/knapsack_pro/test_flat_distributor.rb +2 -0
- data/lib/knapsack_pro/tracker.rb +3 -3
- data/lib/knapsack_pro/urls.rb +4 -0
- data/lib/knapsack_pro/utils.rb +2 -0
- data/lib/knapsack_pro/version.rb +3 -1
- data/lib/knapsack_pro.rb +5 -3
- data/lib/tasks/cucumber.rake +2 -0
- data/lib/tasks/encrypted_branch_names.rake +2 -0
- data/lib/tasks/encrypted_test_file_names.rake +2 -0
- data/lib/tasks/minitest.rake +2 -0
- data/lib/tasks/queue/cucumber.rake +13 -0
- data/lib/tasks/queue/minitest.rake +13 -0
- data/lib/tasks/queue/rspec.rake +13 -0
- data/lib/tasks/rspec.rake +5 -0
- data/lib/tasks/salt.rake +2 -0
- data/lib/tasks/spinach.rake +2 -0
- data/lib/tasks/test_unit.rake +2 -0
- data/spec/integration/api/build_distributions_subset_spec.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 +30 -11
- data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +2 -5
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +146 -174
- data/spec/knapsack_pro/base_allocator_builder_spec.rb +22 -48
- data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +19 -27
- data/spec/knapsack_pro/client/api/v1/queues_spec.rb +23 -43
- data/spec/knapsack_pro/client/connection_spec.rb +59 -7
- data/spec/knapsack_pro/config/ci/app_veyor_spec.rb +22 -8
- data/spec/knapsack_pro/config/ci/base_spec.rb +1 -0
- data/spec/knapsack_pro/config/ci/buildkite_spec.rb +51 -16
- data/spec/knapsack_pro/config/ci/circle_spec.rb +48 -13
- data/spec/knapsack_pro/config/ci/cirrus_ci_spec.rb +12 -12
- data/spec/knapsack_pro/config/ci/codefresh_spec.rb +21 -6
- data/spec/knapsack_pro/config/ci/codeship_spec.rb +20 -6
- data/spec/knapsack_pro/config/ci/github_actions_spec.rb +37 -10
- data/spec/knapsack_pro/config/ci/gitlab_ci_spec.rb +48 -13
- data/spec/knapsack_pro/config/ci/heroku_spec.rb +12 -12
- data/spec/knapsack_pro/config/ci/semaphore2_spec.rb +11 -11
- data/spec/knapsack_pro/config/ci/semaphore_spec.rb +12 -12
- data/spec/knapsack_pro/config/ci/travis_spec.rb +8 -8
- data/spec/knapsack_pro/config/env_spec.rb +204 -124
- data/spec/knapsack_pro/formatters/time_tracker_specs.rb +424 -0
- 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/repository_adapters/git_adapter_spec.rb +72 -0
- data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +18 -16
- data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +17 -14
- data/spec/knapsack_pro/runners/rspec_runner_spec.rb +40 -23
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +1 -0
- data/spec/knapsack_pro/tracker_spec.rb +0 -4
- data/spec/knapsack_pro_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -1
- metadata +26 -23
- data/lib/knapsack_pro/config/ci/snap_ci.rb +0 -35
- data/lib/knapsack_pro/config/ci/solano_ci.rb +0 -32
- data/lib/knapsack_pro/extensions/time.rb +0 -7
- data/lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb +0 -56
- data/lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb +0 -112
- data/spec/knapsack_pro/config/ci/snap_ci_spec.rb +0 -104
- data/spec/knapsack_pro/config/ci/solano_ci_spec.rb +0 -73
- data/spec/knapsack_pro/extensions/time_spec.rb +0 -5
- data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +0 -342
@@ -1,342 +0,0 @@
|
|
1
|
-
describe KnapsackPro::Runners::Queue::RSpecRunner do
|
2
|
-
before do
|
3
|
-
# we don't want to modify rspec formatters because we want to see tests summary at the end
|
4
|
-
# when you run this test file or whole test suite for the knapsack_pro gem
|
5
|
-
stub_const('ENV', { 'KNAPSACK_PRO_MODIFY_DEFAULT_RSPEC_FORMATTERS' => false })
|
6
|
-
|
7
|
-
require KnapsackPro.root + '/lib/knapsack_pro/formatters/rspec_queue_summary_formatter'
|
8
|
-
require KnapsackPro.root + '/lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension'
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '.run' do
|
12
|
-
let(:test_suite_token_rspec) { 'fake-token' }
|
13
|
-
let(:queue_id) { 'fake-queue-id' }
|
14
|
-
let(:test_dir) { 'fake-test-dir' }
|
15
|
-
let(:runner) do
|
16
|
-
instance_double(described_class, test_dir: test_dir)
|
17
|
-
end
|
18
|
-
|
19
|
-
subject { described_class.run(args) }
|
20
|
-
|
21
|
-
before do
|
22
|
-
expect(KnapsackPro::Config::Env).to receive(:test_suite_token_rspec).and_return(test_suite_token_rspec)
|
23
|
-
expect(KnapsackPro::Config::EnvGenerator).to receive(:set_queue_id).and_return(queue_id)
|
24
|
-
|
25
|
-
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_TEST_SUITE_TOKEN', test_suite_token_rspec)
|
26
|
-
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_QUEUE_RECORDING_ENABLED', 'true')
|
27
|
-
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_QUEUE_ID', queue_id)
|
28
|
-
|
29
|
-
expect(KnapsackPro::Config::Env).to receive(:set_test_runner_adapter).with(KnapsackPro::Adapters::RSpecAdapter)
|
30
|
-
|
31
|
-
expect(described_class).to receive(:new).with(KnapsackPro::Adapters::RSpecAdapter).and_return(runner)
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when args provided' do
|
35
|
-
context 'when format option is not provided' do
|
36
|
-
let(:args) { '--example-arg example-value' }
|
37
|
-
|
38
|
-
it 'uses default formatter progress' do
|
39
|
-
expected_exitstatus = 0
|
40
|
-
expected_accumulator = {
|
41
|
-
status: :completed,
|
42
|
-
exitstatus: expected_exitstatus
|
43
|
-
}
|
44
|
-
accumulator = {
|
45
|
-
status: :next,
|
46
|
-
runner: runner,
|
47
|
-
can_initialize_queue: true,
|
48
|
-
args: ['--example-arg', 'example-value', '--format', 'progress', '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter', '--default-path', 'fake-test-dir'],
|
49
|
-
exitstatus: 0,
|
50
|
-
all_test_file_paths: [],
|
51
|
-
}
|
52
|
-
expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
|
53
|
-
|
54
|
-
expect(Kernel).to receive(:exit).with(expected_exitstatus)
|
55
|
-
|
56
|
-
subject
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when format option is provided as --format' do
|
61
|
-
let(:args) { '--format documentation' }
|
62
|
-
|
63
|
-
it 'uses provided format option instead of default formatter progress' do
|
64
|
-
expected_exitstatus = 0
|
65
|
-
expected_accumulator = {
|
66
|
-
status: :completed,
|
67
|
-
exitstatus: expected_exitstatus
|
68
|
-
}
|
69
|
-
accumulator = {
|
70
|
-
status: :next,
|
71
|
-
runner: runner,
|
72
|
-
can_initialize_queue: true,
|
73
|
-
args: ['--format', 'documentation', '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter', '--default-path', 'fake-test-dir'],
|
74
|
-
exitstatus: 0,
|
75
|
-
all_test_file_paths: [],
|
76
|
-
}
|
77
|
-
expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
|
78
|
-
|
79
|
-
expect(Kernel).to receive(:exit).with(expected_exitstatus)
|
80
|
-
|
81
|
-
subject
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'when format option is provided as -f' do
|
86
|
-
let(:args) { '-f d' }
|
87
|
-
|
88
|
-
it 'uses provided format option instead of default formatter progress' do
|
89
|
-
expected_exitstatus = 0
|
90
|
-
expected_accumulator = {
|
91
|
-
status: :completed,
|
92
|
-
exitstatus: expected_exitstatus
|
93
|
-
}
|
94
|
-
accumulator = {
|
95
|
-
status: :next,
|
96
|
-
runner: runner,
|
97
|
-
can_initialize_queue: true,
|
98
|
-
args: ['-f', 'd', '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter', '--default-path', 'fake-test-dir'],
|
99
|
-
exitstatus: 0,
|
100
|
-
all_test_file_paths: [],
|
101
|
-
}
|
102
|
-
expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
|
103
|
-
|
104
|
-
expect(Kernel).to receive(:exit).with(expected_exitstatus)
|
105
|
-
|
106
|
-
subject
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'when format option is provided without a delimiter' do
|
111
|
-
let(:args) { '-fMyCustomFormatter' }
|
112
|
-
|
113
|
-
it 'uses provided format option instead of default formatter progress' do
|
114
|
-
expected_exitstatus = 0
|
115
|
-
expected_accumulator = {
|
116
|
-
status: :completed,
|
117
|
-
exitstatus: expected_exitstatus
|
118
|
-
}
|
119
|
-
accumulator = {
|
120
|
-
status: :next,
|
121
|
-
runner: runner,
|
122
|
-
can_initialize_queue: true,
|
123
|
-
args: ['-fMyCustomFormatter', '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter', '--default-path', 'fake-test-dir'],
|
124
|
-
exitstatus: 0,
|
125
|
-
all_test_file_paths: [],
|
126
|
-
}
|
127
|
-
expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
|
128
|
-
|
129
|
-
expect(Kernel).to receive(:exit).with(expected_exitstatus)
|
130
|
-
|
131
|
-
subject
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
context 'when RSpec split by test examples feature is enabled' do
|
136
|
-
before do
|
137
|
-
expect(KnapsackPro::Config::Env).to receive(:rspec_split_by_test_examples?).and_return(true)
|
138
|
-
expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!).and_call_original
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'when tag option is provided' do
|
142
|
-
let(:args) { '--tag example-value' }
|
143
|
-
|
144
|
-
it do
|
145
|
-
expect { subject }.to raise_error(/It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature/)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
context 'when args not provided' do
|
152
|
-
let(:args) { nil }
|
153
|
-
|
154
|
-
it do
|
155
|
-
expected_exitstatus = 0
|
156
|
-
expected_accumulator = {
|
157
|
-
status: :completed,
|
158
|
-
exitstatus: expected_exitstatus
|
159
|
-
}
|
160
|
-
accumulator = {
|
161
|
-
status: :next,
|
162
|
-
runner: runner,
|
163
|
-
can_initialize_queue: true,
|
164
|
-
args: ['--format', 'progress', '--format', 'KnapsackPro::Formatters::RSpecQueueSummaryFormatter', '--default-path', 'fake-test-dir'],
|
165
|
-
exitstatus: 0,
|
166
|
-
all_test_file_paths: [],
|
167
|
-
}
|
168
|
-
expect(described_class).to receive(:run_tests).with(accumulator).and_return(expected_accumulator)
|
169
|
-
|
170
|
-
expect(Kernel).to receive(:exit).with(expected_exitstatus)
|
171
|
-
|
172
|
-
subject
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
describe '.run_tests' do
|
178
|
-
let(:runner) { instance_double(described_class) }
|
179
|
-
let(:can_initialize_queue) { double(:can_initialize_queue) }
|
180
|
-
let(:args) { ['--no-color', '--default-path', 'fake-test-dir'] }
|
181
|
-
let(:exitstatus) { double }
|
182
|
-
let(:all_test_file_paths) { [] }
|
183
|
-
let(:accumulator) do
|
184
|
-
{
|
185
|
-
runner: runner,
|
186
|
-
can_initialize_queue: can_initialize_queue,
|
187
|
-
args: args,
|
188
|
-
exitstatus: exitstatus,
|
189
|
-
all_test_file_paths: all_test_file_paths,
|
190
|
-
}
|
191
|
-
end
|
192
|
-
|
193
|
-
subject { described_class.run_tests(accumulator) }
|
194
|
-
|
195
|
-
before do
|
196
|
-
expect(runner).to receive(:test_file_paths).with(can_initialize_queue: can_initialize_queue, executed_test_files: all_test_file_paths).and_return(test_file_paths)
|
197
|
-
end
|
198
|
-
|
199
|
-
context 'when test files exist' do
|
200
|
-
let(:test_file_paths) { ['a_spec.rb', 'b_spec.rb'] }
|
201
|
-
let(:logger) { double }
|
202
|
-
let(:rspec_seed) { 7771 }
|
203
|
-
|
204
|
-
before do
|
205
|
-
subset_queue_id = 'fake-subset-queue-id'
|
206
|
-
expect(KnapsackPro::Config::EnvGenerator).to receive(:set_subset_queue_id).and_return(subset_queue_id)
|
207
|
-
|
208
|
-
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_SUBSET_QUEUE_ID', subset_queue_id)
|
209
|
-
|
210
|
-
tracker = instance_double(KnapsackPro::Tracker)
|
211
|
-
expect(KnapsackPro).to receive(:tracker).twice.and_return(tracker)
|
212
|
-
expect(tracker).to receive(:reset!)
|
213
|
-
expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
|
214
|
-
|
215
|
-
options = double
|
216
|
-
expect(RSpec::Core::ConfigurationOptions).to receive(:new).with([
|
217
|
-
'--no-color',
|
218
|
-
'--default-path', 'fake-test-dir',
|
219
|
-
'a_spec.rb', 'b_spec.rb',
|
220
|
-
]).and_return(options)
|
221
|
-
|
222
|
-
rspec_core_runner = double
|
223
|
-
expect(RSpec::Core::Runner).to receive(:new).with(options).and_return(rspec_core_runner)
|
224
|
-
expect(rspec_core_runner).to receive(:run).with($stderr, $stdout).and_return(exit_code)
|
225
|
-
|
226
|
-
expect(described_class).to receive(:rspec_clear_examples)
|
227
|
-
|
228
|
-
expect(KnapsackPro::Hooks::Queue).to receive(:call_before_subset_queue)
|
229
|
-
|
230
|
-
expect(KnapsackPro::Hooks::Queue).to receive(:call_after_subset_queue)
|
231
|
-
|
232
|
-
expect(KnapsackPro::Report).to receive(:save_subset_queue_to_file)
|
233
|
-
|
234
|
-
configuration = double
|
235
|
-
expect(rspec_core_runner).to receive(:configuration).twice.and_return(configuration)
|
236
|
-
expect(configuration).to receive(:seed_used?).and_return(true)
|
237
|
-
expect(configuration).to receive(:seed).and_return(rspec_seed)
|
238
|
-
|
239
|
-
expect(KnapsackPro).to receive(:logger).twice.and_return(logger)
|
240
|
-
expect(logger).to receive(:info)
|
241
|
-
.with("To retry the last batch of tests fetched from the API Queue, please run the following command on your machine:")
|
242
|
-
expect(logger).to receive(:info).with(/#{args.join(' ')} --seed #{rspec_seed}/)
|
243
|
-
end
|
244
|
-
|
245
|
-
context 'when exit code is zero' do
|
246
|
-
let(:exit_code) { 0 }
|
247
|
-
|
248
|
-
it do
|
249
|
-
expect(subject).to eq({
|
250
|
-
status: :next,
|
251
|
-
runner: runner,
|
252
|
-
can_initialize_queue: false,
|
253
|
-
args: args,
|
254
|
-
exitstatus: exitstatus,
|
255
|
-
all_test_file_paths: test_file_paths,
|
256
|
-
})
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
context 'when exit code is not zero' do
|
261
|
-
let(:exit_code) { double }
|
262
|
-
|
263
|
-
it do
|
264
|
-
expect(subject).to eq({
|
265
|
-
status: :next,
|
266
|
-
runner: runner,
|
267
|
-
can_initialize_queue: false,
|
268
|
-
args: args,
|
269
|
-
exitstatus: exit_code,
|
270
|
-
all_test_file_paths: test_file_paths,
|
271
|
-
})
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
context "when test files don't exist" do
|
277
|
-
let(:test_file_paths) { [] }
|
278
|
-
|
279
|
-
context 'when all_test_file_paths exist' do
|
280
|
-
let(:all_test_file_paths) { ['a_spec.rb'] }
|
281
|
-
let(:logger) { double }
|
282
|
-
|
283
|
-
before do
|
284
|
-
described_class.class_variable_set(:@@used_seed, used_seed)
|
285
|
-
|
286
|
-
expect(KnapsackPro).to receive(:logger).twice.and_return(logger)
|
287
|
-
|
288
|
-
expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:verify_bind_method_called)
|
289
|
-
|
290
|
-
expect(KnapsackPro::Formatters::RSpecQueueSummaryFormatter).to receive(:print_summary)
|
291
|
-
expect(KnapsackPro::Formatters::RSpecQueueProfileFormatterExtension).to receive(:print_summary)
|
292
|
-
|
293
|
-
expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue)
|
294
|
-
expect(KnapsackPro::Report).to receive(:save_node_queue_to_api)
|
295
|
-
|
296
|
-
expect(logger).to receive(:info)
|
297
|
-
.with('To retry all the tests assigned to this CI node, please run the following command on your machine:')
|
298
|
-
expect(logger).to receive(:info).with(logged_rspec_command_matcher)
|
299
|
-
end
|
300
|
-
|
301
|
-
context 'when @@used_seed has been set' do
|
302
|
-
let(:used_seed) { '8333' }
|
303
|
-
let(:logged_rspec_command_matcher) { /#{args.join(' ')} --seed #{used_seed} \"a_spec.rb"/ }
|
304
|
-
|
305
|
-
it do
|
306
|
-
expect(subject).to eq({
|
307
|
-
status: :completed,
|
308
|
-
exitstatus: exitstatus,
|
309
|
-
})
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
context 'when @@used_seed has not been set' do
|
314
|
-
let(:used_seed) { nil }
|
315
|
-
let(:logged_rspec_command_matcher) { /#{args.join(' ')} \"a_spec.rb"/ }
|
316
|
-
|
317
|
-
it do
|
318
|
-
expect(subject).to eq({
|
319
|
-
status: :completed,
|
320
|
-
exitstatus: exitstatus,
|
321
|
-
})
|
322
|
-
end
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
context "when all_test_file_paths don't exist" do
|
327
|
-
let(:all_test_file_paths) { [] }
|
328
|
-
|
329
|
-
it do
|
330
|
-
expect(KnapsackPro::Hooks::Queue).to receive(:call_after_queue)
|
331
|
-
expect(KnapsackPro::Report).to receive(:save_node_queue_to_api)
|
332
|
-
expect(KnapsackPro).to_not receive(:logger)
|
333
|
-
|
334
|
-
expect(subject).to eq({
|
335
|
-
status: :completed,
|
336
|
-
exitstatus: exitstatus,
|
337
|
-
})
|
338
|
-
end
|
339
|
-
end
|
340
|
-
end
|
341
|
-
end
|
342
|
-
end
|