onceover 3.12.0 → 3.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/run.feature +5 -0
- data/lib/onceover/rspec/formatters.rb +77 -30
- data/lib/onceover/runner.rb +6 -9
- data/lib/onceover/testconfig.rb +1 -1
- data/onceover.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf7fd944c3bc26e87d6fb637545e2a79f7913e88
|
4
|
+
data.tar.gz: af6d22e661957cae9092b623c9d337e949c4f219
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaab1848deba4d517a93debf8ed6d1ccf7d6251afc5974bb1240dcf341fbcfb096c2a88af5182578732bb817eaf78c638f0096073b6beb1193ce365c3af81100
|
7
|
+
data.tar.gz: ba295a61c754e4fd8c62a75ebacfc68b6fb724a90bc9484277065f1afbe542e3ce3fc50983be58c3adb34c4f1a9ae3629cabc0a9fcda4c1d38a7a311cae88595
|
data/features/run.feature
CHANGED
@@ -12,6 +12,11 @@ Feature: Run rspec and acceptance test suites
|
|
12
12
|
When I run onceover command "run spec"
|
13
13
|
Then I should not see any errors
|
14
14
|
|
15
|
+
Scenario: Run correct spec tests in parallel
|
16
|
+
Given initialized control repo "basic"
|
17
|
+
When I run onceover command "run spec --parallel"
|
18
|
+
Then I should not see any errors
|
19
|
+
|
15
20
|
Scenario: Using regexes to define tests
|
16
21
|
Given initialized control repo "caching"
|
17
22
|
When I run onceover command "run spec"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rspec'
|
1
2
|
require 'pathname'
|
2
3
|
|
3
4
|
class OnceoverFormatter
|
@@ -53,6 +54,21 @@ class OnceoverFormatter
|
|
53
54
|
def dump_failures notification
|
54
55
|
require 'onceover/controlrepo'
|
55
56
|
|
57
|
+
failures = extract_failures(notification)
|
58
|
+
|
59
|
+
# Put some spacing before the results
|
60
|
+
@output << "\n\n\n"
|
61
|
+
|
62
|
+
failures.each do |_name, role|
|
63
|
+
@output << Onceover::Controlrepo.evaluate_template('error_summary.yaml.erb', binding)
|
64
|
+
end
|
65
|
+
|
66
|
+
@output << "\n"
|
67
|
+
end
|
68
|
+
|
69
|
+
# This method takes a notification and formats it into a hash that can be
|
70
|
+
# printed easily
|
71
|
+
def extract_failures notification
|
56
72
|
# Group by role
|
57
73
|
grouped = notification.failed_examples.group_by { |e| e.metadata[:example_group][:parent_example_group][:description]}
|
58
74
|
|
@@ -61,17 +77,15 @@ class OnceoverFormatter
|
|
61
77
|
grouped[role] = failures.uniq { |f| f.metadata[:execution_result].exception.to_s }
|
62
78
|
end
|
63
79
|
|
64
|
-
#
|
65
|
-
@output << "\n\n\n"
|
66
|
-
|
80
|
+
# Extract the errors and remove all RSpec objects
|
67
81
|
grouped.each do |role, failures|
|
68
|
-
role = {
|
82
|
+
grouped[role] = {
|
69
83
|
name: role,
|
70
84
|
errors: failures.map { |f| parse_errors(f.metadata[:execution_result].exception.to_s)}.flatten,
|
71
85
|
}
|
72
|
-
|
73
|
-
@output << Onceover::Controlrepo.evaluate_template('error_summary.yaml.erb', binding)
|
74
86
|
end
|
87
|
+
|
88
|
+
grouped
|
75
89
|
end
|
76
90
|
|
77
91
|
def parse_errors(raw_error)
|
@@ -140,8 +154,6 @@ class OnceoverFormatter
|
|
140
154
|
file.relative_path_from(tempdir + environmentpath + "production").to_s
|
141
155
|
end
|
142
156
|
|
143
|
-
private
|
144
|
-
|
145
157
|
# Below are defined the styles for the output
|
146
158
|
def class_name(text)
|
147
159
|
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :bold)
|
@@ -189,34 +201,69 @@ class OnceoverFormatter
|
|
189
201
|
|
190
202
|
end
|
191
203
|
|
192
|
-
|
193
|
-
|
204
|
+
class OnceoverFormatterParallel < OnceoverFormatter
|
205
|
+
require 'yaml'
|
206
|
+
|
207
|
+
RSpec::Core::Formatters.register self, :example_group_started,
|
208
|
+
:example_passed, :example_failed, :example_pending, :dump_failures
|
209
|
+
|
210
|
+
def example_group_started notification
|
211
|
+
# Do nothing
|
212
|
+
end
|
213
|
+
|
214
|
+
def example_passed notification
|
215
|
+
@output << green('P')
|
216
|
+
@output.flush
|
217
|
+
end
|
218
|
+
|
219
|
+
def example_failed notification
|
220
|
+
@output << red('F')
|
221
|
+
@output.flush
|
222
|
+
end
|
223
|
+
|
224
|
+
def example_pending notification
|
225
|
+
@output << yellow('?')
|
226
|
+
@output.flush
|
227
|
+
end
|
228
|
+
|
229
|
+
def dump_failures notification
|
230
|
+
# Create a random string
|
231
|
+
require 'securerandom'
|
232
|
+
random_string = SecureRandom.hex
|
194
233
|
|
195
|
-
#
|
196
|
-
#
|
197
|
-
# end
|
234
|
+
# Ensure that the folder exists
|
235
|
+
FileUtils.mkdir_p "#{RSpec.configuration.onceover_tempdir}/parallel"
|
198
236
|
|
199
|
-
#
|
200
|
-
#
|
201
|
-
|
237
|
+
# Dump the notification to a unique file
|
238
|
+
File.open("#{RSpec.configuration.onceover_tempdir}/parallel/results-#{random_string}.yaml", "w") do |file|
|
239
|
+
file.write(extract_failures(notification).to_yaml)
|
240
|
+
end
|
241
|
+
end
|
202
242
|
|
203
|
-
|
204
|
-
|
205
|
-
#
|
243
|
+
def output_results(directory)
|
244
|
+
require 'rspec/core/example'
|
245
|
+
# Read all yaml files
|
246
|
+
results = {}
|
247
|
+
files = Dir["#{directory}/*.yaml"]
|
206
248
|
|
207
|
-
#
|
208
|
-
|
209
|
-
#
|
249
|
+
# Merge data
|
250
|
+
errors = files.reduce({}) do |errs, file|
|
251
|
+
# Read all files and merge them
|
252
|
+
errs.merge(YAML.load(File.read(file))) # rubocop:disable Security/YAMLLoad
|
253
|
+
end
|
254
|
+
|
255
|
+
# Delete files from the disk
|
256
|
+
files.each { |f| File.delete(f) }
|
210
257
|
|
211
|
-
|
212
|
-
# # TODO: This should write to a file and then get picked up and formatted by onceover itself
|
213
|
-
# # might need to use a module for the formatting
|
214
|
-
# require 'pry'
|
215
|
-
# binding.pry
|
216
|
-
# RSpec.configuration.onceover_tempdir
|
217
|
-
# end
|
258
|
+
@output << "\n\n\n"
|
218
259
|
|
219
|
-
#
|
260
|
+
# Output errors
|
261
|
+
errors.each do |_name, role|
|
262
|
+
@output << Onceover::Controlrepo.evaluate_template('error_summary.yaml.erb', binding)
|
263
|
+
end
|
264
|
+
@output << "\n"
|
265
|
+
end
|
266
|
+
end
|
220
267
|
|
221
268
|
class FailureCollector
|
222
269
|
RSpec::Core::Formatters.register self, :dump_failures
|
data/lib/onceover/runner.rb
CHANGED
@@ -84,15 +84,12 @@ class Onceover
|
|
84
84
|
logger.debug "Running #{@command_prefix}rake spec_standalone from #{@repo.tempdir}"
|
85
85
|
result = Backticks::Runner.new(interactive:true).run(@command_prefix.strip.split, 'rake', 'spec_standalone').join
|
86
86
|
end
|
87
|
-
|
88
|
-
if
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
else
|
94
|
-
puts 'No failures detected'
|
95
|
-
end
|
87
|
+
|
88
|
+
# Print a summary if we were running ion parallel
|
89
|
+
if @config.formatters.include? 'OnceoverFormatterParallel'
|
90
|
+
require 'onceover/rspec/formatters'
|
91
|
+
formatter = OnceoverFormatterParallel.new(STDOUT)
|
92
|
+
formatter.output_results("#{repo.tempdir}/parallel")
|
96
93
|
end
|
97
94
|
|
98
95
|
# Finally exit and preserve the exit code
|
data/lib/onceover/testconfig.rb
CHANGED
@@ -53,7 +53,7 @@ class Onceover
|
|
53
53
|
|
54
54
|
# Set dynamic defaults for format
|
55
55
|
if opts[:format] == [:defaults]
|
56
|
-
@formatters = opts[:parallel] ? ['
|
56
|
+
@formatters = opts[:parallel] ? ['OnceoverFormatterParallel'] : ['OnceoverFormatter']
|
57
57
|
else
|
58
58
|
@formatters = opts[:format]
|
59
59
|
end
|
data/onceover.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "onceover"
|
7
|
-
s.version = "3.12.
|
7
|
+
s.version = "3.12.1"
|
8
8
|
s.authors = ["Dylan Ratcliffe"]
|
9
9
|
s.email = ["dylan.ratcliffe@puppet.com"]
|
10
10
|
s.homepage = "https://github.com/dylanratcliffe/onceover"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onceover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.12.
|
4
|
+
version: 3.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Ratcliffe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|