knapsack_pro 3.1.3 → 3.3.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 +24 -0
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +17 -0
- data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +14 -2
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +29 -1
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +9 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '099f5615951240d49a1087c5ebbb89169f161a35bfc2f0dc4ea7de80f188e3f9'
|
4
|
+
data.tar.gz: d4939ae9f79b358038147cd5f9a40dcee95760f1fa17d84314fc183cfad722a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adfe023532b15509a4bc1cb993c3d259ffde7df5078c76cf7cf392ec5ce8b6f8eb322ca093e77eadf3ec0c8eba4748ccd0f5ccf6666fd3559eb3bd1a55c0893a
|
7
|
+
data.tar.gz: 072f8d809aa4600ed5f4987f39946cd0030faac8e4ca9bae08cf38680c3aef24226744023d5c6a74aa53b76c2fe481c35692b2f33b98ba9a8d85d17ddeb990c6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 3.3.0
|
4
|
+
|
5
|
+
* Show a JSON report file content when RSpec fails during a dry run
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/172
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.2.1...v3.3.0
|
10
|
+
|
11
|
+
### 3.2.1
|
12
|
+
|
13
|
+
* Raise exception when using `:focus` tag to avoid skipping RSpec tests
|
14
|
+
|
15
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/167
|
16
|
+
|
17
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.2.0...v3.2.1
|
18
|
+
|
19
|
+
### 3.2.0
|
20
|
+
|
21
|
+
* Add an error message to `KnapsackPro::Adapters::RspecAdapter#bind`
|
22
|
+
|
23
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/165
|
24
|
+
|
25
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.1.3...v3.2.0
|
26
|
+
|
3
27
|
### 3.1.3
|
4
28
|
|
5
29
|
* Run Fallback Mode when `Errno::ECONNRESET` exception happens
|
@@ -62,6 +62,10 @@ module KnapsackPro
|
|
62
62
|
current_test_path
|
63
63
|
end
|
64
64
|
|
65
|
+
if example.metadata[:focus] && KnapsackPro::Adapters::RSpecAdapter.rspec_configuration.filter.rules[:focus]
|
66
|
+
raise "We detected a test file path #{current_test_path} with a test using the metadata `:focus` tag. RSpec might not run some tests in the Queue Mode (causing random tests skipping problem). Please remove the `:focus` tag from your codebase. See more: https://knapsackpro.com/faq/question/rspec-is-not-running-some-tests"
|
67
|
+
end
|
68
|
+
|
65
69
|
example.run
|
66
70
|
end
|
67
71
|
|
@@ -95,12 +99,25 @@ module KnapsackPro
|
|
95
99
|
end
|
96
100
|
end
|
97
101
|
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
# Hide RSpec configuration so that we could mock it in the spec.
|
106
|
+
# Mocking existing RSpec configuration could impact test's runtime.
|
107
|
+
def self.rspec_configuration
|
108
|
+
::RSpec.configuration
|
109
|
+
end
|
98
110
|
end
|
99
111
|
|
100
112
|
# This is added to provide backwards compatibility
|
101
113
|
# In case someone is doing switch from knapsack gem to the knapsack_pro gem
|
102
114
|
# and didn't notice the class name changed
|
103
115
|
class RspecAdapter < RSpecAdapter
|
116
|
+
def self.bind
|
117
|
+
error_message = 'You have attempted to call KnapsackPro::Adapters::RspecAdapter.bind. Please switch to using the new class name: KnapsackPro::Adapters::RSpecAdapter. See https://docs.knapsackpro.com/knapsack_pro-ruby/guide for up-to-date configuration instructions.'
|
118
|
+
KnapsackPro.logger.error(error_message)
|
119
|
+
raise error_message
|
120
|
+
end
|
104
121
|
end
|
105
122
|
end
|
106
123
|
end
|
@@ -36,11 +36,19 @@ module KnapsackPro
|
|
36
36
|
] + cli_args).join(' ')
|
37
37
|
|
38
38
|
KnapsackPro.logger.error('-'*10 + ' START of actionable error message ' + '-'*50)
|
39
|
-
KnapsackPro.logger.error('
|
39
|
+
KnapsackPro.logger.error('RSpec (with a dry-run option) had a problem generating the report with test examples for the slow test files. Here is what you can do:')
|
40
|
+
|
41
|
+
KnapsackPro.logger.error("a) Please look for an error message from RSpec in the output above or below. If you don't see anything, that is fine. Sometimes RSpec does not produce any errors in the output.")
|
42
|
+
|
43
|
+
KnapsackPro.logger.error("b) Check if RSpec generated the report file #{report_path}. If the report exists, it may contain an error message. Here is a preview of the report file:")
|
44
|
+
KnapsackPro.logger.error(report_content || 'N/A')
|
45
|
+
|
46
|
+
KnapsackPro.logger.error('c) To reproduce the error manually, please run the following RSpec command. This way, you can find out what is causing the error. Please ensure you run the command in the same environment where the error occurred. For instance, if the error happens on the CI server, you should run the command in the CI environment:')
|
40
47
|
KnapsackPro.logger.error(debug_cmd)
|
48
|
+
|
41
49
|
KnapsackPro.logger.error('-'*10 + ' END of actionable error message ' + '-'*50)
|
42
50
|
|
43
|
-
raise 'There was a problem while generating test examples for the slow test files. Please read actionable error message above.'
|
51
|
+
raise 'There was a problem while generating test examples for the slow test files. Please read the actionable error message above.'
|
44
52
|
end
|
45
53
|
end
|
46
54
|
|
@@ -75,6 +83,10 @@ module KnapsackPro
|
|
75
83
|
"#{report_dir}/rspec_dry_run_json_report_node_#{KnapsackPro::Config::Env.ci_node_index}.json"
|
76
84
|
end
|
77
85
|
|
86
|
+
def report_content
|
87
|
+
File.read(report_path) if File.exist?(report_path)
|
88
|
+
end
|
89
|
+
|
78
90
|
def adapter_class
|
79
91
|
KnapsackPro::Adapters::RSpecAdapter
|
80
92
|
end
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -175,7 +175,35 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
175
175
|
let(:logger) { instance_double(Logger) }
|
176
176
|
let(:global_time) { 'Global time: 01m 05s' }
|
177
177
|
let(:test_path) { 'spec/a_spec.rb' }
|
178
|
-
let(:current_example) { double }
|
178
|
+
let(:current_example) { double(metadata: {}) }
|
179
|
+
|
180
|
+
context "when the example's metadata has :focus tag AND RSpec inclusion rule includes :focus" do
|
181
|
+
let(:current_example) { double(metadata: { focus: true }) }
|
182
|
+
|
183
|
+
it do
|
184
|
+
expect(KnapsackPro::Config::Env).to receive(:rspec_split_by_test_examples?).and_return(false)
|
185
|
+
|
186
|
+
expect(config).to receive(:prepend_before).with(:context).and_yield
|
187
|
+
|
188
|
+
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
189
|
+
expect(tracker).to receive(:start_timer).ordered
|
190
|
+
|
191
|
+
expect(config).to receive(:around).with(:each).and_yield(current_example)
|
192
|
+
expect(::RSpec).to receive(:configure).and_yield(config)
|
193
|
+
|
194
|
+
expect(tracker).to receive(:stop_timer).ordered
|
195
|
+
|
196
|
+
expect(described_class).to receive(:test_path).with(current_example).and_return(test_path)
|
197
|
+
|
198
|
+
expect(tracker).to receive(:current_test_path=).with(test_path).ordered
|
199
|
+
|
200
|
+
expect(described_class).to receive_message_chain(:rspec_configuration, :filter, :rules, :[]).with(:focus).and_return(true)
|
201
|
+
|
202
|
+
expect {
|
203
|
+
subject.bind_time_tracker
|
204
|
+
}.to raise_error /We detected a test file path spec\/a_spec\.rb with a test using the metadata `:focus` tag/
|
205
|
+
end
|
206
|
+
end
|
179
207
|
|
180
208
|
context 'when rspec split by test examples is disabled' do
|
181
209
|
before do
|
@@ -11,7 +11,7 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
|
|
11
11
|
|
12
12
|
expect(FileUtils).to receive(:mkdir_p).with(report_dir)
|
13
13
|
|
14
|
-
expect(File).to receive(:exist?).with(report_path).and_return(true)
|
14
|
+
expect(File).to receive(:exist?).at_least(:once).with(report_path).and_return(true)
|
15
15
|
expect(File).to receive(:delete).with(report_path)
|
16
16
|
|
17
17
|
expect(rspec_test_example_detector).to receive(:slow_test_files).and_return(test_file_entities)
|
@@ -68,8 +68,15 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
|
|
68
68
|
context 'when exit code from RSpec::Core::Runner is 1' do
|
69
69
|
let(:exit_code) { 1 }
|
70
70
|
|
71
|
+
before do
|
72
|
+
json_file = %{
|
73
|
+
{"version":"3.11.0","messages":["An error occurred while loading ./spec/a_spec.rb"],"examples":[],"summary":{"duration":3.6e-05,"example_count":0,"failure_count":0,"pending_count":0,"errors_outside_of_examples_count":1},"summary_line":"0 examples, 0 failures, 1 error occurred outside of examples"}
|
74
|
+
}.strip
|
75
|
+
expect(File).to receive(:read).with(report_path).and_return(json_file)
|
76
|
+
end
|
77
|
+
|
71
78
|
it do
|
72
|
-
expect { subject }.to raise_error(RuntimeError, 'There was a problem while generating test examples for the slow test files. Please read actionable error message above.')
|
79
|
+
expect { subject }.to raise_error(RuntimeError, 'There was a problem while generating test examples for the slow test files. Please read the actionable error message above.')
|
73
80
|
end
|
74
81
|
end
|
75
82
|
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: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -405,7 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
405
405
|
- !ruby/object:Gem::Version
|
406
406
|
version: '0'
|
407
407
|
requirements: []
|
408
|
-
rubygems_version: 3.
|
408
|
+
rubygems_version: 3.3.7
|
409
409
|
signing_key:
|
410
410
|
specification_version: 4
|
411
411
|
summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
|