knapsack_pro 11.0.0 → 11.0.1
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/lib/knapsack_pro/adapters/rspec_adapter.rb +23 -16
- data/lib/knapsack_pro/formatters/time_tracker.rb +11 -8
- data/lib/knapsack_pro/version.rb +1 -1
- data/lib/knapsack_pro.rb +10 -10
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ef9cbd99ef5c4bdb062a04337881da1422b6d06d9b217f915501ae29205e223
|
|
4
|
+
data.tar.gz: 36f197ac02ab0a653e46f4400d0b1cafd8600528255a4d1262c7d1db988345cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9381634364fd597f823ee9bb836fad096b1ce9e38c03dc106d95a07ceadaf7f1930f0f4849e5e0e478316d3950b4ce1d509207150ca8f50a863972ee071a319e
|
|
7
|
+
data.tar.gz: 4dcb81bf900413c96199674a8077cfb1e6abc8027813c742dfb2a4f625258d72794e1f24c165bd3c0e77849ded2afc75bf9ef7048c7a8a343e6998efb8668b29
|
|
@@ -7,7 +7,9 @@ module KnapsackPro
|
|
|
7
7
|
class RSpecAdapter < BaseAdapter
|
|
8
8
|
TEST_DIR_PATTERN = 'spec/**{,/*/**}/*_spec.rb'
|
|
9
9
|
# https://github.com/rspec/rspec/blob/86b5e4218eece4c1913fe9aad24c0a96d8bc9f40/rspec-core/lib/rspec/core/example.rb#L122
|
|
10
|
-
|
|
10
|
+
ID_REGEX = /\[[\d\s:,]+\]\z/.freeze
|
|
11
|
+
ID_PATH_PREFIX = '['
|
|
12
|
+
ID_PATH_SUFFIX = ']'
|
|
11
13
|
|
|
12
14
|
def self.split_by_test_cases_enabled?
|
|
13
15
|
return false unless KnapsackPro::Config::Env.rspec_split_by_test_examples?
|
|
@@ -57,28 +59,33 @@ module KnapsackPro
|
|
|
57
59
|
end
|
|
58
60
|
|
|
59
61
|
def self.file_path_for(example)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return p if p.include?('_spec.rb') || p.include?('.feature')
|
|
69
|
-
end
|
|
62
|
+
p = parse_file_path(example.id)
|
|
63
|
+
return p if p.include?('_spec.rb') || p.include?('.feature')
|
|
64
|
+
|
|
65
|
+
p = example.metadata[:file_path]
|
|
66
|
+
return p if p.include?('_spec.rb') || p.include?('.feature')
|
|
67
|
+
|
|
68
|
+
p = example.metadata[:example_group][:file_path]
|
|
69
|
+
return p if p.include?('_spec.rb') || p.include?('.feature')
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
p = top_level_group(example)[:file_path]
|
|
72
|
+
return p if p.include?('_spec.rb') || p.include?('.feature')
|
|
73
|
+
|
|
74
|
+
''
|
|
72
75
|
end
|
|
73
76
|
|
|
74
77
|
def self.parse_file_path(path)
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
return path unless path.end_with?(ID_PATH_SUFFIX)
|
|
79
|
+
|
|
80
|
+
index = path.rindex(ID_PATH_PREFIX)
|
|
81
|
+
return path if index.nil?
|
|
82
|
+
return path unless ID_REGEX.match?(path, index)
|
|
83
|
+
|
|
84
|
+
path[0, index]
|
|
77
85
|
end
|
|
78
86
|
|
|
79
87
|
def self.id_path?(path)
|
|
80
|
-
|
|
81
|
-
!id.nil?
|
|
88
|
+
path.end_with?(ID_PATH_SUFFIX) && ID_REGEX.match?(path)
|
|
82
89
|
end
|
|
83
90
|
|
|
84
91
|
def self.concat_test_files(test_files, id_paths)
|
|
@@ -81,7 +81,7 @@ module KnapsackPro
|
|
|
81
81
|
|
|
82
82
|
add_hooks_time(@group, @time_all_by_group_id_path)
|
|
83
83
|
@time_all_by_group_id_path = Hash.new(0)
|
|
84
|
-
|
|
84
|
+
merge!(@paths, @group)
|
|
85
85
|
@group = {}
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -94,7 +94,9 @@ module KnapsackPro
|
|
|
94
94
|
object[path] = { path: path, time_execution: 0.0 }
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
-
merge(@paths, missing)
|
|
97
|
+
merge!(@paths, missing)
|
|
98
|
+
|
|
99
|
+
@paths.values.map do |example|
|
|
98
100
|
example.transform_keys(&:to_s)
|
|
99
101
|
end
|
|
100
102
|
end
|
|
@@ -189,12 +191,13 @@ module KnapsackPro
|
|
|
189
191
|
end
|
|
190
192
|
end
|
|
191
193
|
|
|
192
|
-
def merge(h1, h2)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
def merge!(h1, h2)
|
|
195
|
+
h2.each do |path, example|
|
|
196
|
+
if recorded = h1[path]
|
|
197
|
+
recorded[:time_execution] += example[:time_execution]
|
|
198
|
+
else
|
|
199
|
+
h1[path] = example
|
|
200
|
+
end
|
|
198
201
|
end
|
|
199
202
|
end
|
|
200
203
|
|
data/lib/knapsack_pro/version.rb
CHANGED
data/lib/knapsack_pro.rb
CHANGED
|
@@ -110,17 +110,17 @@ module KnapsackPro
|
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
def logger
|
|
113
|
-
if
|
|
114
|
-
default_logger = Logger.new("#{KnapsackPro::Config::Env.log_dir}/knapsack_pro_node_#{KnapsackPro::Config::Env.ci_node_index}.log")
|
|
115
|
-
default_logger.level = KnapsackPro::Config::Env.log_level
|
|
116
|
-
self.logger = default_logger
|
|
117
|
-
end
|
|
113
|
+
return @logger if @logger
|
|
118
114
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
log_dir = KnapsackPro::Config::Env.log_dir
|
|
116
|
+
default_logger =
|
|
117
|
+
if log_dir
|
|
118
|
+
::Logger.new("#{log_dir}/knapsack_pro_node_#{KnapsackPro::Config::Env.ci_node_index}.log")
|
|
119
|
+
else
|
|
120
|
+
::Logger.new(stdout)
|
|
121
|
+
end
|
|
122
|
+
default_logger.level = KnapsackPro::Config::Env.log_level
|
|
123
|
+
self.logger = default_logger
|
|
124
124
|
|
|
125
125
|
@logger
|
|
126
126
|
end
|