knapsack_pro 1.19.0 → 1.20.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/CHANGELOG.md +8 -0
- data/README.md +4 -2
- data/lib/knapsack_pro/formatters/rspec_json_formatter.rb +20 -0
- data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +9 -2
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +27 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f06c380d215524276faa79157268a701ca58e3e0ab22fdcfb78119786596bf65
|
4
|
+
data.tar.gz: e5c3d4a9258fd43dd869367bd7d1fdaacd786904f67cfe4041f2fc7aa49daf25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad9e73fca6cb2b53d8c9d156a012ea43c159cb37380c8c6cbe95f2ee0d94abca8707ea94eff3c59d428e48afdd9f3500f28aff8f5d85d12f7fe22e7f726cf9ca
|
7
|
+
data.tar.gz: 2d1b257cade9a1c82e93c530a9d30cb292c05a3df007ed5e18e809472520d035590ec06b6457790ce4f37190c28beb60801c21a6a646e2ac3674abaf3c299ea1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 1.20.0
|
4
|
+
|
5
|
+
* Add support for tests split by test examples to RSpec older than 3.6.0
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/104
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v1.19.0...v1.20.0
|
10
|
+
|
3
11
|
### 1.19.0
|
4
12
|
|
5
13
|
* RSpec split test files by test examples (by individual `it`s)
|
data/README.md
CHANGED
@@ -608,7 +608,9 @@ This is helpful when you have one or a few very slow test files that are a bottl
|
|
608
608
|
|
609
609
|
### RSpec split test files by test examples (by individual `it`s)
|
610
610
|
|
611
|
-
|
611
|
+
__Requirement:__ It works with >= RSpec 3.6.0.
|
612
|
+
|
613
|
+
In order to split RSpec test files by test examples across parallel CI nodes you need to set environment variable:
|
612
614
|
|
613
615
|
```
|
614
616
|
KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true
|
@@ -1002,7 +1004,7 @@ env:
|
|
1002
1004
|
- KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
|
1003
1005
|
|
1004
1006
|
- KNAPSACK_PRO_CI_NODE_TOTAL=2
|
1005
|
-
|
1007
|
+
jobs:
|
1006
1008
|
- KNAPSACK_PRO_CI_NODE_INDEX=0
|
1007
1009
|
- KNAPSACK_PRO_CI_NODE_INDEX=1
|
1008
1010
|
```
|
@@ -0,0 +1,20 @@
|
|
1
|
+
RSpec::Support.require_rspec_core('formatters/json_formatter')
|
2
|
+
|
3
|
+
# based on https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/formatters/json_formatter.rb
|
4
|
+
module KnapsackPro
|
5
|
+
module Formatters
|
6
|
+
class RSpecJsonFormatter < RSpec::Core::Formatters::JsonFormatter
|
7
|
+
RSpec::Core::Formatters.register self, :message, :dump_summary, :dump_profile, :stop, :seed, :close
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# add example.id to json report to support < RSpec 3.6.0
|
12
|
+
# based on https://github.com/rspec/rspec-core/pull/2369/files
|
13
|
+
def format_example(example)
|
14
|
+
super.merge({
|
15
|
+
:id => example.id,
|
16
|
+
})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -7,14 +7,21 @@ module KnapsackPro
|
|
7
7
|
def generate_json_report
|
8
8
|
require 'rspec/core'
|
9
9
|
|
10
|
+
cli_format =
|
11
|
+
if Gem::Version.new(RSpec::Core::Version::STRING) < Gem::Version.new('3.6.0')
|
12
|
+
require_relative '../formatters/rspec_json_formatter'
|
13
|
+
['--format', KnapsackPro::Formatters::RSpecJsonFormatter.to_s]
|
14
|
+
else
|
15
|
+
['--format', 'json']
|
16
|
+
end
|
17
|
+
|
10
18
|
ensure_report_dir_exists
|
11
19
|
remove_old_json_report
|
12
20
|
|
13
21
|
test_file_paths = KnapsackPro::TestFileFinder.call(test_file_pattern)
|
14
22
|
|
15
|
-
cli_args = [
|
23
|
+
cli_args = cli_format + [
|
16
24
|
'--dry-run',
|
17
|
-
'--format', 'json',
|
18
25
|
'--out', REPORT_PATH,
|
19
26
|
'--default-path', test_dir,
|
20
27
|
] + test_file_paths.map { |t| t.fetch('path') }
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -27,8 +27,8 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
|
|
27
27
|
|
28
28
|
options = double
|
29
29
|
expect(RSpec::Core::ConfigurationOptions).to receive(:new).with([
|
30
|
+
'--format', expected_format,
|
30
31
|
'--dry-run',
|
31
|
-
'--format', 'json',
|
32
32
|
'--out', report_path,
|
33
33
|
'--default-path', test_dir,
|
34
34
|
'spec/a_spec.rb', 'spec/b_spec.rb',
|
@@ -39,20 +39,38 @@ describe KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector do
|
|
39
39
|
expect(rspec_core_runner).to receive(:run).with($stderr, $stdout).and_return(exit_code)
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
shared_examples 'generate_json_report runs RSpec::Core::Runner' do
|
43
|
+
context 'when exit code from RSpec::Core::Runner is 0' do
|
44
|
+
let(:exit_code) { 0 }
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
it do
|
47
|
+
expect(subject).to be_nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when exit code from RSpec::Core::Runner is 1' do
|
52
|
+
let(:exit_code) { 1 }
|
53
|
+
|
54
|
+
it do
|
55
|
+
expect { subject }.to raise_error(RuntimeError, 'There was problem to generate test examples for test suite')
|
56
|
+
end
|
47
57
|
end
|
48
58
|
end
|
49
59
|
|
50
|
-
context 'when
|
51
|
-
let(:
|
60
|
+
context 'when RSpec >= 3.6.0' do
|
61
|
+
let(:expected_format) { 'json' }
|
52
62
|
|
53
|
-
|
54
|
-
|
63
|
+
it_behaves_like 'generate_json_report runs RSpec::Core::Runner'
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when RSpec < 3.6.0' do
|
67
|
+
let(:expected_format) { 'KnapsackPro::Formatters::RSpecJsonFormatter' }
|
68
|
+
|
69
|
+
before do
|
70
|
+
stub_const('RSpec::Core::Version::STRING', '3.5.0')
|
55
71
|
end
|
72
|
+
|
73
|
+
it_behaves_like 'generate_json_report runs RSpec::Core::Runner'
|
56
74
|
end
|
57
75
|
end
|
58
76
|
|
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.20.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-04-
|
11
|
+
date: 2020-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -257,6 +257,7 @@ files:
|
|
257
257
|
- lib/knapsack_pro/crypto/digestor.rb
|
258
258
|
- lib/knapsack_pro/crypto/encryptor.rb
|
259
259
|
- lib/knapsack_pro/extensions/time.rb
|
260
|
+
- lib/knapsack_pro/formatters/rspec_json_formatter.rb
|
260
261
|
- lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
|
261
262
|
- lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb
|
262
263
|
- lib/knapsack_pro/hooks/queue.rb
|