parallel_cucumber 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21efcd236f18ea3ac32ac8fe307a3856701d45d227ad3edd05cb571bbf34ea83
4
- data.tar.gz: 35ddffec456a2add5916990eb77844039d6132dd5b5c4459c506a834bdc321e8
3
+ metadata.gz: 50176784f3a666778c3c6e4ebf590e9121a7aef8b054d0180841f2bf30320132
4
+ data.tar.gz: 8fa12b1fa391046c64cb0b7e175a557a7d8d3e202107b94ad42ac0a60dc851f0
5
5
  SHA512:
6
- metadata.gz: e37068e9ee2e6a8e754baf49cf29c92d909dd96f6625dc4eb17b4b9ac8fc932a58181a5210ee4fe14c6cd21f6e5197faf7d011ed3a681bdf21d8a4c93b5d001d
7
- data.tar.gz: 0ac4181e268d5868f797ec25b51539b63f6d6f9bd76338817f8240ecc29e2a680e55efd0a93127f785ff9e538dc5191952aedc817ee98c8c09c7f47e23c9286b
6
+ metadata.gz: ef3d82e89d50c8ee68553a55a51c7cebb24fec61223dd66cbb392c39090b5f42fcb101b618b16ae0dd068b3f4affbf1d863bf50b4a21497ff62df51c3cb7fd63
7
+ data.tar.gz: e8fc52cbf754cd46e0fb5b69aa5d75703008f6f71cb75202be2e964460cace827025f6af0ebd0d69fd6c6af742a2ae49a96d3b55762644d0f506fb8f6f65bc71
data/README.md CHANGED
@@ -11,9 +11,6 @@ Example: parallel_cucumber -n 4 -o "-f pretty -f html -o report.html" examples/i
11
11
  --directed-tests JSON Direct tests to specific workers, e.g. {"0": "-t @head"}
12
12
  --test-command COMMAND Command to run for test phase, default cucumber
13
13
  --pre-batch-check COMMAND Command causing worker to quit on exit failure
14
- --on-batch-error COMMAND Command to call on any error happened while running batch of tests.
15
- It will receive as argument json file with list of tests and error happened.
16
- --no-pretty Now a no-op for compatibility there is no default pretty
17
14
  --log-dir DIR Directory for worker logfiles
18
15
  --log-decoration JSON Block quoting for logs, e.g. {start: "#start %s", end: "#end %s"}
19
16
  --summary JSON Summary files, e.g. {failed: "./failed.txt", unknown: "./unknown.txt"}
@@ -89,14 +89,6 @@ module ParallelCucumber
89
89
  options[:pre_check] = pre_check
90
90
  end
91
91
 
92
- opts.on('--on-batch-error COMMAND',
93
- 'Command to call on any error happened while running batch of tests.
94
- It will receive as argument json file with list of tests and error happened.') do |on_batch_error|
95
- options[:on_batch_error] = on_batch_error
96
- end
97
-
98
- opts.on('--no-pretty', 'Now a no-op for compatibility there is no default pretty') {}
99
-
100
92
  opts.on('--log-dir DIR', 'Directory for worker logfiles') do |log_dir|
101
93
  options[:log_dir] = log_dir
102
94
  end
@@ -26,6 +26,10 @@ module ParallelCucumber
26
26
  def after_workers(&proc)
27
27
  Hooks.register_after_workers(proc)
28
28
  end
29
+
30
+ def on_batch_error(&proc)
31
+ Hooks.register_on_batch_error(proc)
32
+ end
29
33
  end
30
34
  end
31
35
  end
@@ -3,6 +3,7 @@ module ParallelCucumber
3
3
  @before_batch_hooks ||= []
4
4
  @after_batch_hooks ||= []
5
5
  @after_workers ||= []
6
+ @on_batch_error ||= []
6
7
 
7
8
  class << self
8
9
  def register_before_batch(proc)
@@ -20,6 +21,11 @@ module ParallelCucumber
20
21
  @after_workers << proc
21
22
  end
22
23
 
24
+ def register_on_batch_error(proc)
25
+ raise(ArgumentError, 'Please provide a valid callback') unless proc.respond_to?(:call)
26
+ @on_batch_error << proc
27
+ end
28
+
23
29
  def fire_before_batch_hooks(*args)
24
30
  @before_batch_hooks.each do |hook|
25
31
  hook.call(*args)
@@ -37,6 +43,12 @@ module ParallelCucumber
37
43
  hook.call(*args)
38
44
  end
39
45
  end
46
+
47
+ def fire_on_batch_error(*args)
48
+ @on_batch_error.each do |hook|
49
+ hook.call(*args)
50
+ end
51
+ end
40
52
  end
41
53
  end
42
54
  end
@@ -1,3 +1,3 @@
1
1
  module ParallelCucumber
2
- VERSION = '0.2.12'.freeze
2
+ VERSION = '0.2.13'.freeze
3
3
  end
@@ -33,7 +33,6 @@ module ParallelCucumber
33
33
  @cucumber_options = options[:cucumber_options]
34
34
  @test_command = options[:test_command]
35
35
  @pre_check = options[:pre_check]
36
- @on_batch_error = options[:on_batch_error]
37
36
  @index = index
38
37
  @queue_connection_params = options[:queue_connection_params]
39
38
  @setup_worker = options[:setup_worker]
@@ -177,31 +176,6 @@ module ParallelCucumber
177
176
  end
178
177
  end
179
178
 
180
- def on_batch_error(batch_env, batch_id, error_file, tests, error)
181
- return unless @on_batch_error
182
-
183
- begin
184
- error_info = {
185
- class: error.class,
186
- message: error.message,
187
- backtrace: error.backtrace
188
- }
189
- batch_error_info = {
190
- batch_id: batch_id,
191
- tests: tests,
192
- error: error_info
193
- }
194
- File.write(error_file, batch_error_info.to_json)
195
- command = "#{@on_batch_error} #{error_file}"
196
- Helper::Command.exec_command(
197
- batch_env, 'on_batch_error', command, @logger, @log_decoration, timeout: @batch_error_timeout
198
- )
199
- rescue => e
200
- message = "on-batch-error failed: #{e.message}"
201
- @logger.warn(message)
202
- end
203
- end
204
-
205
179
  def running_totals(batch_results, running_total)
206
180
  batch_info = Status.constants.map do |status|
207
181
  status = Status.const_get(status)
@@ -253,8 +227,14 @@ module ParallelCucumber
253
227
  )
254
228
  rescue => e
255
229
  @logger << "ERROR #{e} #{e.backtrace.first(5)}"
256
- error_file = "#{test_batch_dir}/error.json"
257
- on_batch_error(batch_env, batch_id, error_file, tests, e)
230
+
231
+ begin
232
+ Hooks.fire_on_batch_error(tests: tests, batch_id: batch_id, env: batch_env, exception: e)
233
+ rescue StandardError => exc
234
+ trace = exc.backtrace.join("\n\t")
235
+ @logger.warn("There was exception in on_batch_error hook #{exc.message} \n #{trace}")
236
+ end
237
+
258
238
  return tests.map { |t| [t, ::ParallelCucumber::Status::UNKNOWN] }.to_h
259
239
  end
260
240
  parse_results(test_state, tests)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Bayandin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-05 00:00:00.000000000 Z
11
+ date: 2018-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber