atp 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/version.rb +1 -1
- data/lib/atp/ast/node.rb +12 -2
- data/lib/atp/flow.rb +199 -170
- 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: 30f27f563d7be5bb5ac2fdadeb075aff8254e631
|
4
|
+
data.tar.gz: 116ddc493b873bb4680a559e488de2e65cb62698
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1183ef2bc0e85b638c5d50c75b2dd9f433017ea71cdef4c92d7eadaf084d361448b3e36ba91fb674a1a145a1ca80e85bfaeec4d5be291b7cada572699813db15
|
7
|
+
data.tar.gz: b4b41aca1916c7053bc91b5851caf18d4a47aeba3e25e0c794d6f79b9c45d5cf52db9ac75e2ba223bb73d844074cbdd13c24a7f8f6effbb355745daf81a5af6a
|
data/config/version.rb
CHANGED
data/lib/atp/ast/node.rb
CHANGED
@@ -77,9 +77,19 @@ module ATP
|
|
77
77
|
children.find { |c| types.include?(c.try(:type)) }
|
78
78
|
end
|
79
79
|
|
80
|
-
# Returns an array containing all child nodes of the given type(s)
|
80
|
+
# Returns an array containing all child nodes of the given type(s), by default only considering
|
81
|
+
# the immediate children of the node on which this was called.
|
82
|
+
#
|
83
|
+
# To find all children of the given type by recursively searching through all child nodes, pass
|
84
|
+
# recursive: true when calling this method.
|
81
85
|
def find_all(*types)
|
82
|
-
|
86
|
+
options = types.pop if types.last.is_a?(Hash)
|
87
|
+
options ||= {}
|
88
|
+
if options[:recursive]
|
89
|
+
Extractor.new.process(self, types)
|
90
|
+
else
|
91
|
+
children.select { |c| types.include?(c.try(:type)) }
|
92
|
+
end
|
83
93
|
end
|
84
94
|
|
85
95
|
# Returns an array containing all flags which are set within the given node
|
data/lib/atp/flow.rb
CHANGED
@@ -4,8 +4,6 @@ module ATP
|
|
4
4
|
class Flow
|
5
5
|
attr_reader :program, :name
|
6
6
|
|
7
|
-
attr_accessor :source_file, :source_line_number, :description
|
8
|
-
|
9
7
|
CONDITION_KEYS = {
|
10
8
|
if_enabled: :if_enabled,
|
11
9
|
if_enable: :if_enabled,
|
@@ -64,10 +62,14 @@ module ATP
|
|
64
62
|
|
65
63
|
def initialize(program, name = nil, options = {})
|
66
64
|
name, options = nil, name if name.is_a?(Hash)
|
67
|
-
|
65
|
+
@source_file = []
|
66
|
+
@source_line_number = []
|
67
|
+
@description = []
|
68
68
|
@program = program
|
69
69
|
@name = name
|
70
|
-
|
70
|
+
extract_meta!(options) do
|
71
|
+
@pipeline = [n1(:flow, n1(:name, name))]
|
72
|
+
end
|
71
73
|
end
|
72
74
|
|
73
75
|
# @api private
|
@@ -213,14 +215,15 @@ module ATP
|
|
213
215
|
# flow.test ...
|
214
216
|
# end
|
215
217
|
def group(name, options = {})
|
216
|
-
extract_meta!(options)
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
218
|
+
extract_meta!(options) do
|
219
|
+
apply_conditions(options) do
|
220
|
+
children = [n1(:name, name)]
|
221
|
+
children << id(options[:id]) if options[:id]
|
222
|
+
children << on_fail(options[:on_fail]) if options[:on_fail]
|
223
|
+
children << on_pass(options[:on_pass]) if options[:on_pass]
|
224
|
+
g = n(:group, children)
|
225
|
+
append_to(g) { yield }
|
226
|
+
end
|
224
227
|
end
|
225
228
|
end
|
226
229
|
|
@@ -234,130 +237,131 @@ module ATP
|
|
234
237
|
# @option options [Hash] :on_pass What action to take if the test passes
|
235
238
|
# @option options [Hash] :conditions What conditions must be met to execute the test
|
236
239
|
def test(instance, options = {})
|
237
|
-
extract_meta!(options)
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
240
|
+
extract_meta!(options) do
|
241
|
+
apply_conditions(options) do
|
242
|
+
# Allows any continue, bin, or soft bin argument passed in at the options top-level to be assumed
|
243
|
+
# to be the action to take if the test fails
|
244
|
+
if b = options.delete(:bin)
|
245
|
+
options[:on_fail] ||= {}
|
246
|
+
options[:on_fail][:bin] = b
|
247
|
+
end
|
248
|
+
if b = options.delete(:bin_description)
|
249
|
+
options[:on_fail] ||= {}
|
250
|
+
options[:on_fail][:bin_description] = b
|
251
|
+
end
|
252
|
+
if b = options.delete(:softbin) || b = options.delete(:sbin) || b = options.delete(:soft_bin)
|
253
|
+
options[:on_fail] ||= {}
|
254
|
+
options[:on_fail][:softbin] = b
|
255
|
+
end
|
256
|
+
if b = options.delete(:softbin_description) || options.delete(:sbin_description) || options.delete(:soft_bin_description)
|
257
|
+
options[:on_fail] ||= {}
|
258
|
+
options[:on_fail][:softbin_description] = b
|
259
|
+
end
|
260
|
+
if options.delete(:continue)
|
261
|
+
options[:on_fail] ||= {}
|
262
|
+
options[:on_fail][:continue] = true
|
263
|
+
end
|
264
|
+
if options.key?(:delayed)
|
265
|
+
options[:on_fail] ||= {}
|
266
|
+
options[:on_fail][:delayed] = options.delete(:delayed)
|
267
|
+
end
|
268
|
+
if f = options.delete(:flag_pass)
|
269
|
+
options[:on_pass] ||= {}
|
270
|
+
options[:on_pass][:set_flag] = f
|
271
|
+
end
|
272
|
+
if f = options.delete(:flag_fail)
|
273
|
+
options[:on_fail] ||= {}
|
274
|
+
options[:on_fail][:set_flag] = f
|
275
|
+
end
|
273
276
|
|
274
|
-
|
277
|
+
children = [n1(:object, instance)]
|
275
278
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
279
|
+
name = (options[:name] || options[:tname] || options[:test_name])
|
280
|
+
unless name
|
281
|
+
[:name, :tname, :test_name].each do |m|
|
282
|
+
name ||= instance.respond_to?(m) ? instance.send(m) : nil
|
283
|
+
end
|
280
284
|
end
|
281
|
-
|
282
|
-
children << n1(:name, name) if name
|
285
|
+
children << n1(:name, name) if name
|
283
286
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
287
|
+
num = (options[:number] || options[:num] || options[:tnum] || options[:test_number])
|
288
|
+
unless num
|
289
|
+
[:number, :num, :tnum, :test_number].each do |m|
|
290
|
+
num ||= instance.respond_to?(m) ? instance.send(m) : nil
|
291
|
+
end
|
288
292
|
end
|
289
|
-
|
290
|
-
children << number(num) if num
|
293
|
+
children << number(num) if num
|
291
294
|
|
292
|
-
|
295
|
+
children << id(options[:id]) if options[:id]
|
293
296
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
297
|
+
if levels = options[:level] || options[:levels]
|
298
|
+
levels = [levels] unless levels.is_a?(Array)
|
299
|
+
levels.each do |l|
|
300
|
+
children << level(l[:name], l[:value], l[:unit] || l[:units])
|
301
|
+
end
|
298
302
|
end
|
299
|
-
end
|
300
303
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
304
|
+
lims = options[:limit] || options[:limits]
|
305
|
+
if lims || options[:lo] || options[:low] || options[:hi] || options[:high]
|
306
|
+
if lims == :none || lims == 'none'
|
307
|
+
children << n0(:nolimits)
|
308
|
+
else
|
309
|
+
lims = Array(lims) unless lims.is_a?(Array)
|
310
|
+
if lo = options[:lo] || options[:low]
|
311
|
+
lims << { value: lo, rule: :gte }
|
312
|
+
end
|
313
|
+
if hi = options[:hi] || options[:high]
|
314
|
+
lims << { value: hi, rule: :lte }
|
315
|
+
end
|
316
|
+
lims.each do |l|
|
317
|
+
if l.is_a?(Hash)
|
318
|
+
children << n(:limit, [l[:value], l[:rule], l[:unit] || l[:units], l[:selector]])
|
319
|
+
end
|
316
320
|
end
|
317
321
|
end
|
318
322
|
end
|
319
|
-
end
|
320
323
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
324
|
+
if pins = options[:pin] || options[:pins]
|
325
|
+
pins = [pins] unless pins.is_a?(Array)
|
326
|
+
pins.each do |p|
|
327
|
+
if p.is_a?(Hash)
|
328
|
+
children << pin(p[:name])
|
329
|
+
else
|
330
|
+
children << pin(p)
|
331
|
+
end
|
328
332
|
end
|
329
333
|
end
|
330
|
-
end
|
331
334
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
335
|
+
if pats = options[:pattern] || options[:patterns]
|
336
|
+
pats = [pats] unless pats.is_a?(Array)
|
337
|
+
pats.each do |p|
|
338
|
+
if p.is_a?(Hash)
|
339
|
+
children << pattern(p[:name], p[:path])
|
340
|
+
else
|
341
|
+
children << pattern(p)
|
342
|
+
end
|
339
343
|
end
|
340
344
|
end
|
341
|
-
end
|
342
345
|
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
346
|
+
if options[:meta]
|
347
|
+
attrs = []
|
348
|
+
options[:meta].each { |k, v| attrs << attribute(k, v) }
|
349
|
+
children << n(:meta, attrs)
|
350
|
+
end
|
348
351
|
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
352
|
+
if subs = options[:sub_test] || options[:sub_tests]
|
353
|
+
subs = [subs] unless subs.is_a?(Array)
|
354
|
+
subs.each do |s|
|
355
|
+
children << s.updated(:sub_test, nil)
|
356
|
+
end
|
353
357
|
end
|
354
|
-
end
|
355
358
|
|
356
|
-
|
357
|
-
|
359
|
+
children << on_fail(options[:on_fail]) if options[:on_fail]
|
360
|
+
children << on_pass(options[:on_pass]) if options[:on_pass]
|
358
361
|
|
359
|
-
|
360
|
-
|
362
|
+
save_conditions
|
363
|
+
n(:test, children)
|
364
|
+
end
|
361
365
|
end
|
362
366
|
end
|
363
367
|
|
@@ -374,12 +378,13 @@ module ATP
|
|
374
378
|
fail 'The bin number must be passed as the first argument'
|
375
379
|
end
|
376
380
|
options[:bin_description] ||= options.delete(:description)
|
377
|
-
extract_meta!(options)
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
381
|
+
extract_meta!(options) do
|
382
|
+
apply_conditions(options) do
|
383
|
+
options[:type] ||= :fail
|
384
|
+
options[:bin] = number
|
385
|
+
options[:softbin] ||= options[:soft_bin] || options[:sbin]
|
386
|
+
set_result(options[:type], options)
|
387
|
+
end
|
383
388
|
end
|
384
389
|
end
|
385
390
|
|
@@ -392,57 +397,64 @@ module ATP
|
|
392
397
|
end
|
393
398
|
|
394
399
|
def cz(instance, cz_setup, options = {})
|
395
|
-
extract_meta!(options)
|
396
|
-
|
397
|
-
|
398
|
-
|
400
|
+
extract_meta!(options) do
|
401
|
+
apply_conditions(options) do
|
402
|
+
node = n1(:cz, cz_setup)
|
403
|
+
append_to(node) { test(instance, options) }
|
404
|
+
end
|
399
405
|
end
|
400
406
|
end
|
401
407
|
alias_method :characterize, :cz
|
402
408
|
|
403
409
|
# Append a log message line to the flow
|
404
410
|
def log(message, options = {})
|
405
|
-
extract_meta!(options)
|
406
|
-
|
407
|
-
|
411
|
+
extract_meta!(options) do
|
412
|
+
apply_conditions(options) do
|
413
|
+
n1(:log, message.to_s)
|
414
|
+
end
|
408
415
|
end
|
409
416
|
end
|
410
417
|
|
411
418
|
# Enable a flow control variable
|
412
419
|
def enable(var, options = {})
|
413
|
-
extract_meta!(options)
|
414
|
-
|
415
|
-
|
420
|
+
extract_meta!(options) do
|
421
|
+
apply_conditions(options) do
|
422
|
+
n1(:enable, var)
|
423
|
+
end
|
416
424
|
end
|
417
425
|
end
|
418
426
|
|
419
427
|
# Disable a flow control variable
|
420
428
|
def disable(var, options = {})
|
421
|
-
extract_meta!(options)
|
422
|
-
|
423
|
-
|
429
|
+
extract_meta!(options) do
|
430
|
+
apply_conditions(options) do
|
431
|
+
n1(:disable, var)
|
432
|
+
end
|
424
433
|
end
|
425
434
|
end
|
426
435
|
|
427
436
|
def set_flag(flag, options = {})
|
428
|
-
extract_meta!(options)
|
429
|
-
|
430
|
-
|
437
|
+
extract_meta!(options) do
|
438
|
+
apply_conditions(options) do
|
439
|
+
set_flag_node(flag)
|
440
|
+
end
|
431
441
|
end
|
432
442
|
end
|
433
443
|
|
434
444
|
# Insert explicitly rendered content in to the flow
|
435
445
|
def render(str, options = {})
|
436
|
-
extract_meta!(options)
|
437
|
-
|
438
|
-
|
446
|
+
extract_meta!(options) do
|
447
|
+
apply_conditions(options) do
|
448
|
+
n1(:render, str)
|
449
|
+
end
|
439
450
|
end
|
440
451
|
end
|
441
452
|
|
442
453
|
def continue(options = {})
|
443
|
-
extract_meta!(options)
|
444
|
-
|
445
|
-
|
454
|
+
extract_meta!(options) do
|
455
|
+
apply_conditions(options) do
|
456
|
+
n0(:continue)
|
457
|
+
end
|
446
458
|
end
|
447
459
|
end
|
448
460
|
|
@@ -489,37 +501,50 @@ module ATP
|
|
489
501
|
|
490
502
|
private
|
491
503
|
|
504
|
+
def description
|
505
|
+
@description.last
|
506
|
+
end
|
507
|
+
|
508
|
+
def source_file
|
509
|
+
@source_file.last
|
510
|
+
end
|
511
|
+
|
512
|
+
def source_line_number
|
513
|
+
@source_line_number.last
|
514
|
+
end
|
515
|
+
|
492
516
|
def flow_control_method(name, flag, options = {}, &block)
|
493
|
-
extract_meta!(options)
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
end
|
498
|
-
if name == :if_failed
|
499
|
-
fail 'if_failed only accepts one ID, use if_any_failed or if_all_failed for multiple IDs'
|
500
|
-
end
|
501
|
-
end
|
502
|
-
apply_conditions(options) do
|
503
|
-
if block
|
504
|
-
node = n1(name, flag)
|
505
|
-
open_conditions << [name, flag]
|
506
|
-
node = append_to(node) { block.call }
|
507
|
-
open_conditions.pop
|
508
|
-
else
|
509
|
-
unless options[:then] || options[:else]
|
510
|
-
fail "You must supply a :then or :else option when calling #{name} like this!"
|
517
|
+
extract_meta!(options) do
|
518
|
+
if flag.is_a?(Array)
|
519
|
+
if name == :if_passed
|
520
|
+
fail 'if_passed only accepts one ID, use if_any_passed or if_all_passed for multiple IDs'
|
511
521
|
end
|
512
|
-
|
513
|
-
|
514
|
-
node = append_to(node) { options[:then].call }
|
522
|
+
if name == :if_failed
|
523
|
+
fail 'if_failed only accepts one ID, use if_any_failed or if_all_failed for multiple IDs'
|
515
524
|
end
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
node =
|
525
|
+
end
|
526
|
+
apply_conditions(options) do
|
527
|
+
if block
|
528
|
+
node = n1(name, flag)
|
529
|
+
open_conditions << [name, flag]
|
530
|
+
node = append_to(node) { block.call }
|
531
|
+
open_conditions.pop
|
532
|
+
else
|
533
|
+
unless options[:then] || options[:else]
|
534
|
+
fail "You must supply a :then or :else option when calling #{name} like this!"
|
535
|
+
end
|
536
|
+
node = n1(name, flag)
|
537
|
+
if options[:then]
|
538
|
+
node = append_to(node) { options[:then].call }
|
539
|
+
end
|
540
|
+
if options[:else]
|
541
|
+
e = n0(:else)
|
542
|
+
e = append_to(e) { options[:else].call }
|
543
|
+
node = node.updated(nil, node.children + [e])
|
544
|
+
end
|
520
545
|
end
|
546
|
+
node
|
521
547
|
end
|
522
|
-
node
|
523
548
|
end
|
524
549
|
end
|
525
550
|
|
@@ -629,9 +654,13 @@ module ATP
|
|
629
654
|
end
|
630
655
|
|
631
656
|
def extract_meta!(options)
|
632
|
-
|
633
|
-
|
634
|
-
|
657
|
+
@source_file << options.delete(:source_file)
|
658
|
+
@source_line_number << options.delete(:source_line_number)
|
659
|
+
@description << options.delete(:description)
|
660
|
+
yield
|
661
|
+
@source_file.pop
|
662
|
+
@source_line_number.pop
|
663
|
+
@description.pop
|
635
664
|
end
|
636
665
|
|
637
666
|
def id(name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen McGinty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: origen
|