uttk 0.3.6.1 → 0.4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/BESTOF +13 -0
- data/ChangeLog +19 -0
- data/MATRIX +6 -0
- data/NEWS +34 -4
- data/PITFALLS +13 -0
- data/Rakefile +19 -2
- data/SPEC.gemspec +18 -0
- data/SPEC.yml +21 -7
- data/bin/getopts/uttk.rb +23 -10
- data/lib/uttk.rb +16 -12
- data/lib/uttk/dumpers/Mail.rb +41 -0
- data/lib/uttk/dumpers/Yaml.rb +2 -2
- data/lib/uttk/filters/KeepSkipBased.rb +1 -1
- data/lib/uttk/generators/templates/loader.rb +1 -1
- data/lib/uttk/generators/templates/strategy-command.rb +72 -0
- data/lib/uttk/generators/templates/strategy.rb +4 -3
- data/lib/uttk/generators/templates/unit_test.rb +1 -1
- data/lib/uttk/loaders/Loader.rb +1 -1
- data/lib/uttk/loaders/Ruby.rb +1 -1
- data/lib/uttk/loaders/Yaml.rb +2 -2
- data/lib/uttk/logger/section_node.rb +1 -1
- data/lib/uttk/logger/severity.rb +1 -1
- data/lib/uttk/logger/to_uttk_log.rb +2 -2
- data/lib/uttk/logger/verbosity.rb +1 -1
- data/lib/uttk/logger_factory.rb +1 -1
- data/lib/uttk/status.rb +1 -1
- data/lib/uttk/strategies/Abort.rb +1 -1
- data/lib/uttk/strategies/Assert.rb +1 -1
- data/lib/uttk/strategies/Authors.rb +2 -2
- data/lib/uttk/strategies/Bootstrap.rb +38 -11
- data/lib/uttk/strategies/Checkout.rb +3 -2
- data/lib/uttk/strategies/Clean.rb +1 -1
- data/lib/uttk/strategies/Collection.rb +3 -3
- data/lib/uttk/strategies/Command.rb +95 -0
- data/lib/uttk/strategies/Composite/contents_eval.rb +1 -1
- data/lib/uttk/strategies/Configure.rb +34 -25
- data/lib/uttk/strategies/Error.rb +1 -1
- data/lib/uttk/strategies/Fail.rb +1 -1
- data/lib/uttk/strategies/HostSelector.rb +143 -0
- data/lib/uttk/strategies/Import.rb +2 -2
- data/lib/uttk/strategies/Iterate.rb +1 -1
- data/lib/uttk/strategies/JUnit.rb +1 -1
- data/lib/uttk/strategies/Jump.rb +81 -0
- data/lib/uttk/strategies/Make.rb +28 -58
- data/lib/uttk/strategies/Package.rb +5 -6
- data/lib/uttk/strategies/PackageCollection.rb +1 -1
- data/lib/uttk/strategies/Pass.rb +1 -1
- data/lib/uttk/strategies/RUnit.rb +63 -49
- data/lib/uttk/strategies/SignalCmd.rb +1 -1
- data/lib/uttk/strategies/Sleep.rb +1 -1
- data/lib/uttk/strategies/SqlQuery.rb +1 -1
- data/lib/uttk/strategies/Strategy.rb +153 -3
- data/lib/uttk/strategies/SubCmd.rb +51 -31
- data/lib/uttk/strategies/Suite.rb +1 -1
- data/lib/uttk/strategies/Test.rb +1 -1
- data/lib/uttk/strategies/{ProbabilityThreshold.rb → Threshold.rb} +3 -3
- data/lib/uttk/streams.rb +1 -1
- data/lib/uttk/streams/Diff.rb +1 -1
- data/lib/uttk/streams/Stream.rb +1 -1
- data/lib/uttk/version_id.rb +1 -1
- data/lib/uttk/weights/WExpr.rb +1 -1
- data/lib/uttk/weights/WFloat.rb +1 -1
- data/lib/uttk/weights/WMin.rb +1 -1
- data/lib/uttk/weights/Weight.rb +1 -1
- data/lib/www/images/opentriangle.gif +0 -0
- data/lib/www/images/triangle.gif +0 -0
- data/lib/www/stylesheets/uttk.css +167 -0
- data/misc/expandtab.rb +1 -1
- data/test/examples/students/mini-lib.yml +1 -1
- data/test/fixtures/binaries/segv +0 -0
- data/test/functional/base.yml +29 -0
- data/test/functional/cat.yml +2 -2
- data/test/functional/cmd.yml +5 -0
- data/test/functional/command.yml +14 -0
- data/test/functional/diff.yml +2 -2
- data/test/functional/env_cmd.yml +3 -3
- data/test/functional/exit.yml +1 -1
- data/test/functional/host_selector.yml +30 -0
- data/test/functional/iterate.yml +31 -37
- data/test/functional/jump.yml +34 -0
- data/test/functional/pkg.yml +1 -1
- data/test/functional/{probability_threshold.yml → threshold.yml} +2 -2
- data/test/functional/timeout.yml +1 -1
- data/test/functional/wc.yml +2 -2
- data/test/unit/dumpers/mail_test.rb +46 -0
- data/test/unit/filters/keep_skip_based_test.rb +1 -1
- data/test/unit/filters/text_filter_test.rb +1 -1
- metadata +258 -253
- data/test/fixtures/demo/command-tutorial/steps/1/check.yml +0 -5
- data/test/fixtures/demo/command-tutorial/steps/1/pluralizer.rb +0 -10
- data/test/fixtures/demo/command-tutorial/steps/2/bad_check.yml +0 -7
- data/test/fixtures/demo/command-tutorial/steps/2/check.yml +0 -7
- data/test/fixtures/demo/command-tutorial/steps/2/pluralizer.rb +0 -10
- data/test/fixtures/demo/command-tutorial/steps/3.1/check.yml +0 -12
- data/test/fixtures/demo/command-tutorial/steps/3/check.yml +0 -14
- data/test/fixtures/demo/command-tutorial/steps/4.1/bird.txt +0 -1
- data/test/fixtures/demo/command-tutorial/steps/4.1/check.yml +0 -12
- data/test/fixtures/demo/command-tutorial/steps/4/check.yml +0 -12
- data/test/fixtures/demo/command-tutorial/steps/4/pluralizer.rb +0 -12
- data/test/fixtures/demo/command-tutorial/steps/5.1/bird.txt +0 -1
- data/test/fixtures/demo/command-tutorial/steps/5.1/check.yml +0 -17
- data/test/fixtures/demo/command-tutorial/steps/5.1/pluralizer.rb +0 -17
- data/test/fixtures/demo/command-tutorial/steps/5/bird.txt +0 -1
- data/test/fixtures/demo/command-tutorial/steps/5/check.yml +0 -16
- data/test/fixtures/demo/command-tutorial/steps/5/pluralizer.rb +0 -16
- data/test/fixtures/demo/command-tutorial/steps/6.1/bird.txt +0 -1
- data/test/fixtures/demo/command-tutorial/steps/6.1/check.yml +0 -22
- data/test/fixtures/demo/command-tutorial/steps/6.1/pluralizer.rb +0 -17
- data/test/fixtures/demo/command-tutorial/steps/6/bird.txt +0 -1
- data/test/fixtures/demo/command-tutorial/steps/6/check.yml +0 -21
- data/test/fixtures/demo/command-tutorial/steps/6/pluralizer.rb +0 -17
- data/test/fixtures/demo/command-tutorial/steps/7/bird.txt +0 -1
- data/test/fixtures/demo/command-tutorial/steps/7/check.yml +0 -22
- data/test/fixtures/demo/command-tutorial/steps/7/pluralizer.rb +0 -17
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
2
|
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
3
|
# License:: LGPL
|
4
|
-
# $Id: /fey/uttk/trunk/lib/uttk/strategies/Package.rb
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/Package.rb 24394 2006-07-10T07:38:58.276210Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
module Uttk
|
@@ -54,14 +54,13 @@ module Uttk
|
|
54
54
|
|
55
55
|
make = {}
|
56
56
|
|
57
|
-
[
|
58
|
-
|
59
|
-
next if skip_step? step_name
|
57
|
+
%w[ check distcheck install ].each do |step|
|
58
|
+
next if skip_step? step
|
60
59
|
create(Make) do |build|
|
61
|
-
build.name = "Building #{
|
60
|
+
build.name = "Building #{step}"
|
62
61
|
build.target = step
|
63
62
|
build.fatal = true
|
64
|
-
make[
|
63
|
+
make[step.to_sym] = build
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
2
|
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
3
|
# License:: LGPL
|
4
|
-
# $Id: /fey/uttk/trunk/lib/uttk/strategies/PackageCollection.rb 8789 2005-09-27T14:49:49.088376Z ertai $
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/PackageCollection.rb 8789 2005-09-27T14:49:49.088376Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
module Uttk
|
data/lib/uttk/strategies/Pass.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
2
|
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
3
|
# License:: LGPL
|
4
|
-
# $Id: /fey/uttk/trunk/lib/uttk/strategies/Pass.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/Pass.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
module Uttk
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: Nicolas Despres <nicolas.despres@gmail.com>.
|
2
2
|
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
3
|
# License:: LGPL
|
4
|
-
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/RUnit.rb
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/RUnit.rb 24394 2006-07-10T07:38:58.276210Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
require 'yaml'
|
@@ -55,64 +55,80 @@ module Uttk
|
|
55
55
|
# strategy into the YAML input file of Uttk, there is another way that is
|
56
56
|
# used in test/unit-suite.yml.
|
57
57
|
#
|
58
|
-
class RUnit <
|
58
|
+
class RUnit < Strategy
|
59
59
|
include Concrete
|
60
60
|
|
61
|
-
protected
|
62
61
|
def prologue
|
63
|
-
|
62
|
+
super
|
63
|
+
@runner = mk_system_runner
|
64
|
+
@command = '<<ruby>>'.to_ocmd << '--' << '<<uttk-unit>>'
|
64
65
|
if @verbose
|
65
|
-
@command
|
66
|
+
@command << '--verbose'
|
66
67
|
else
|
67
|
-
@command
|
68
|
-
end
|
69
|
-
@load_path.each { |x| @command += "-I #{x} " }
|
70
|
-
@requires = [@requires] unless @requires.respond_to? :each
|
71
|
-
@requires.each { |x| @command += "-r #{x} " }
|
72
|
-
unless @uttk_unit_options.empty?
|
73
|
-
opts = @uttk_unit_options
|
74
|
-
opts = [opts] unless opts.respond_to? :each
|
75
|
-
opts.each { |x| @command += "#{x} " }
|
68
|
+
@command << '--no-verbose'
|
76
69
|
end
|
77
|
-
@
|
78
|
-
@
|
79
|
-
|
70
|
+
@load_path.each { |x| @command << '-I' << x }
|
71
|
+
@requires.to_ocmd_args.each { |x| @command << '-r' << x }
|
72
|
+
@command += @uttk_unit_options.to_ocmd_args
|
73
|
+
@command << '--' << @input << '--' << '--runner' << 'yaml'
|
74
|
+
@command.dir = @dir
|
80
75
|
end
|
76
|
+
protected :prologue
|
77
|
+
|
78
|
+
def run_impl
|
79
|
+
@data = @command.run @runner
|
80
|
+
end
|
81
|
+
protected :run_impl
|
81
82
|
|
82
|
-
protected
|
83
83
|
def assertion
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
else
|
111
|
-
@error.my.open { |io| result = io.read }
|
112
|
-
raise "Some error occures while running the unit test:\n" + result
|
84
|
+
matcher_result = command_matcher[UM::StreamMatcher, {:error => ''}, @data]
|
85
|
+
@log << matcher_result
|
86
|
+
raise_error('Error output not empty') if matcher_result.failure?
|
87
|
+
|
88
|
+
if @data.output.zero?
|
89
|
+
skip('No result has been collected probably because no test ' +
|
90
|
+
'suite has been run')
|
91
|
+
end
|
92
|
+
|
93
|
+
output = YAML.load @data.output.read
|
94
|
+
@log[:result] = output
|
95
|
+
o = OpenStruct.new output
|
96
|
+
|
97
|
+
if o.tests_number.zero?
|
98
|
+
skip_pass 'No test suite in this file'
|
99
|
+
end
|
100
|
+
|
101
|
+
pass if o.failures_number.zero? and o.errors_number.zero?
|
102
|
+
|
103
|
+
rpath = '/^failures$/^default_test/No tests were specified'
|
104
|
+
if o.failures_number == 1 and output.rpath_find :first, rpath
|
105
|
+
skip 'No tests were specified'
|
106
|
+
elsif o.failures_number.zero?
|
107
|
+
fail 'There are errors'
|
108
|
+
elsif o.errors_number.zero?
|
109
|
+
fail 'There are failures'
|
113
110
|
end
|
111
|
+
|
112
|
+
fail 'There are failures and errors'
|
113
|
+
end
|
114
|
+
protected :assertion
|
115
|
+
|
116
|
+
def abort_hook
|
117
|
+
@runner.abort @data if @runner and defined? @data
|
118
|
+
super
|
114
119
|
end
|
120
|
+
protected :abort_hook
|
115
121
|
|
122
|
+
def epilogue
|
123
|
+
@data.clean if defined? @data
|
124
|
+
super
|
125
|
+
end
|
126
|
+
protected :epilogue
|
127
|
+
|
128
|
+
attribute :input, 'the input ruby unit test file',
|
129
|
+
nil, :invisible
|
130
|
+
attribute :dir, 'the directory where to launch the command',
|
131
|
+
[String, Pathname]
|
116
132
|
attribute :load_path, 'directories to add to the $LOAD_PATH variable',
|
117
133
|
:invisible do [] end
|
118
134
|
attribute :requires, 'features to require before load the input',
|
@@ -128,5 +144,3 @@ module Uttk
|
|
128
144
|
|
129
145
|
end # module Uttk
|
130
146
|
|
131
|
-
|
132
|
-
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: Vincent CUISSARD <cuissa_v@epita.fr>.
|
2
2
|
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
3
3
|
# License:: LGPL
|
4
|
-
# $Id: /fey/uttk/trunk/lib/uttk/strategies/SignalCmd.rb 8789 2005-09-27T14:49:49.088376Z ertai $
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/SignalCmd.rb 8789 2005-09-27T14:49:49.088376Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
module Uttk
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: Nicolas Despres <nicolas.despres@gmail.com>.
|
2
2
|
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
3
|
# License:: LGPL
|
4
|
-
# $Id: /fey/uttk/trunk/lib/uttk/strategies/Sleep.rb 8789 2005-09-27T14:49:49.088376Z ertai $
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/Sleep.rb 8789 2005-09-27T14:49:49.088376Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
module Uttk
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: Vincent Cuissard <cuissa_v@epita.fr>
|
2
2
|
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
3
|
# License:: LGPL
|
4
|
-
# $Id: /fey/uttk/trunk/lib/uttk/strategies/SqlQuery.rb 8789 2005-09-27T14:49:49.088376Z ertai $
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/SqlQuery.rb 8789 2005-09-27T14:49:49.088376Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
module Uttk
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: The Uttk Team.
|
2
2
|
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
3
|
# License:: LGPL
|
4
|
-
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/Strategy.rb
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/Strategy.rb 24392 2006-07-10T07:36:43.181560Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
require 'set'
|
@@ -463,6 +463,152 @@ module Uttk
|
|
463
463
|
protected :check_post_assertion
|
464
464
|
|
465
465
|
|
466
|
+
# FIXME move them to separate files
|
467
|
+
def mk_system_runner env={}
|
468
|
+
hooker = StrategyHooker.new @symtbl, @log, env
|
469
|
+
OCmd::Runners::System.new.hooker_subscribe hooker
|
470
|
+
end
|
471
|
+
|
472
|
+
class StrategyHooker
|
473
|
+
include Hooker
|
474
|
+
|
475
|
+
attr_reader :env, :symtbl, :log
|
476
|
+
|
477
|
+
def initialize symtbl, log, env={}
|
478
|
+
@env, @symtbl, @log = env, symtbl, log
|
479
|
+
end
|
480
|
+
|
481
|
+
def display_command cmd
|
482
|
+
cmd.do_symtbl_gsub! @symtbl
|
483
|
+
@log[:running] = cmd.to_sh
|
484
|
+
end
|
485
|
+
|
486
|
+
def before_exec cmd, data
|
487
|
+
env_sub = proc do |k,v|
|
488
|
+
ENV[k.to_s] = v.do_symtbl_gsub(@symtbl).gsub(/\$(\w+)/) { ENV[$1] }
|
489
|
+
end
|
490
|
+
@env.each(&env_sub)
|
491
|
+
@symtbl[:env].each(&env_sub) if @symtbl[:env]
|
492
|
+
end
|
493
|
+
|
494
|
+
def exception_raised_during_exec
|
495
|
+
@data.status = 127
|
496
|
+
fail 'exception raised during exec'
|
497
|
+
end
|
498
|
+
|
499
|
+
def already_killed data
|
500
|
+
@log.already_killed = data.pid
|
501
|
+
end
|
502
|
+
|
503
|
+
end # class StrategyHooker
|
504
|
+
|
505
|
+
|
506
|
+
class CommandMatcher < UM::UnifiedMatcher
|
507
|
+
make Concrete
|
508
|
+
cattr_accessor :stream_matcher
|
509
|
+
|
510
|
+
rule :to_ocmd
|
511
|
+
|
512
|
+
final(Hash, OCmd::Datas::Data) do |ref, my|
|
513
|
+
raise ArgumentError, 'ref is empty' if ref.empty?
|
514
|
+
result = UM::MatcherResults.new
|
515
|
+
for k,v in ref do
|
516
|
+
result << stream_matcher[v, my.send(k), k]
|
517
|
+
end
|
518
|
+
result
|
519
|
+
end
|
520
|
+
|
521
|
+
final(OCmd::Datas::Data, OCmd::Datas::Data) do |ref, my|
|
522
|
+
result = UM::MatcherResults.new
|
523
|
+
result << stream_matcher[ref.status, my.status, 'status']
|
524
|
+
result << stream_matcher[ref.output, my.output, 'output']
|
525
|
+
result << stream_matcher[ref.error, my.error, 'error']
|
526
|
+
result
|
527
|
+
end
|
528
|
+
|
529
|
+
def [] matcher, ref, my, name=nil
|
530
|
+
matcher = matcher.new if matcher.is_a? Class
|
531
|
+
self.stream_matcher = matcher
|
532
|
+
super(ref, my, name)
|
533
|
+
end
|
534
|
+
|
535
|
+
end
|
536
|
+
|
537
|
+
::UM::StreamMatcher.class_eval do
|
538
|
+
final(NilClass, Object, :message => '') { |ref, my| [ true, nil ] }
|
539
|
+
end
|
540
|
+
|
541
|
+
::UM::GnuDiffMatcher.runner = OCmd::Runners::System.new
|
542
|
+
|
543
|
+
::UM::MatcherResults.class_eval do
|
544
|
+
def to_uttk_log log
|
545
|
+
each do |r|
|
546
|
+
log << r
|
547
|
+
end
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
::UM::MatcherResult.class_eval do
|
552
|
+
if true
|
553
|
+
def to_uttk_log log
|
554
|
+
raise ArgumentError, "no name for this matcher result" if @name.nil?
|
555
|
+
log.new_node @name do
|
556
|
+
log.reason = message unless message.empty?
|
557
|
+
if data.nil? or data.is_a? MatchData
|
558
|
+
log.my = my.to_s_for_uttk_log unless my.nil?
|
559
|
+
log.ref = ref.to_s_for_uttk_log unless ref.nil?
|
560
|
+
else
|
561
|
+
log.diff = data.output.read
|
562
|
+
end
|
563
|
+
end
|
564
|
+
end
|
565
|
+
else
|
566
|
+
def to_uttk_log log
|
567
|
+
raise ArgumentError, "no name for this matcher result" if @name.nil?
|
568
|
+
log["#{@name}_reason"] = message unless message.empty?
|
569
|
+
if data.nil? or data.is_a? MatchData
|
570
|
+
log["my_#@name"] = my.to_s_for_uttk_log unless my.nil?
|
571
|
+
log["ref_#@name"] = ref.to_s_for_uttk_log unless ref.nil?
|
572
|
+
else
|
573
|
+
log["#{@name}_diff"] = data.output.read
|
574
|
+
end
|
575
|
+
end
|
576
|
+
end
|
577
|
+
end
|
578
|
+
|
579
|
+
::OCmd::Commands::Command.class_eval do
|
580
|
+
def symtbl_gsub! symtbl
|
581
|
+
res = @command.symtbl_gsub!(symtbl)
|
582
|
+
res = @args.symtbl_gsub!(symtbl) || res
|
583
|
+
res = @dir.symtbl_gsub!(symtbl) || res
|
584
|
+
(res)? self : nil
|
585
|
+
end
|
586
|
+
def symtbl_gsub symtbl
|
587
|
+
command = @command.symtbl_gsub symtbl
|
588
|
+
args = @args.symtbl_gsub symtbl
|
589
|
+
dir = @dir.symtbl_gsub symtbl
|
590
|
+
if command || args || dir
|
591
|
+
self.class.new(command || @command, args || @args, dir || @dir)
|
592
|
+
else
|
593
|
+
nil
|
594
|
+
end
|
595
|
+
end
|
596
|
+
end
|
597
|
+
|
598
|
+
cattr_accessor :command_matcher
|
599
|
+
self.command_matcher ||= CommandMatcher.new
|
600
|
+
|
601
|
+
# Examples:
|
602
|
+
# assert_cmd @matcher, @data, :output => /foo*/, :error => '', :exit => 0
|
603
|
+
# assert_cmd UM::StreamMatcher, @data, :output => 'foo.txt'.to_path
|
604
|
+
# The given matcher is used to match command data contents.
|
605
|
+
def assert_cmd matcher, my, ref
|
606
|
+
matcher_result = command_matcher[matcher, ref, my]
|
607
|
+
@log << matcher_result
|
608
|
+
fail if matcher_result.failure?
|
609
|
+
return matcher_result
|
610
|
+
end
|
611
|
+
|
466
612
|
# Display conclusions.
|
467
613
|
# Here you can finish some tasks even when the test fails.
|
468
614
|
# Exceptions are absolutly forbidden in this method.
|
@@ -500,7 +646,6 @@ module Uttk
|
|
500
646
|
protected :pass_hook
|
501
647
|
|
502
648
|
|
503
|
-
|
504
649
|
#
|
505
650
|
# Assertions
|
506
651
|
#
|
@@ -524,11 +669,16 @@ module Uttk
|
|
524
669
|
raise_status PassStatus.new
|
525
670
|
end
|
526
671
|
|
527
|
-
# Skip the test
|
672
|
+
# Skip the test (by default the weight is 0%)
|
528
673
|
def skip ( *args )
|
529
674
|
raise_status_custom SkipStatus, *args
|
530
675
|
end
|
531
676
|
|
677
|
+
# Skip the test: the weight is 100%.
|
678
|
+
def skip_pass ( message=nil )
|
679
|
+
raise_status SkipStatus.new(PassStatus.new.weight, message)
|
680
|
+
end
|
681
|
+
|
532
682
|
# Force an Error status
|
533
683
|
def raise_error ( message=nil )
|
534
684
|
@symtbl[:flow] << :error
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
2
|
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
3
|
# License:: LGPL
|
4
|
-
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/SubCmd.rb
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/SubCmd.rb 24394 2006-07-10T07:38:58.276210Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
module Uttk
|
@@ -9,66 +9,86 @@ module Uttk
|
|
9
9
|
module Strategies
|
10
10
|
|
11
11
|
# I run a sub Uttk or an another program that can behave like it.
|
12
|
-
class SubCmd <
|
12
|
+
class SubCmd < Strategy
|
13
13
|
include Concrete
|
14
14
|
|
15
15
|
def prologue
|
16
|
-
@command = @symtbl[:uttk]
|
17
|
-
@dir = @symtbl[:pwd]
|
18
|
-
@quiet_print = true
|
19
16
|
super
|
17
|
+
hooker = StrategyHooker.new @symtbl, @log, @env
|
18
|
+
@runner = OCmd::Runners::Popen.new.hooker_subscribe hooker
|
19
|
+
@command = @symtbl[:uttk].to_ocmd
|
20
|
+
@command.dir = @symtbl[:pwd]
|
21
|
+
@command.input = @input
|
22
|
+
@command += @args.to_ocmd_args
|
23
|
+
@command << '-F' << 'Path' << '--dump-status'
|
20
24
|
end
|
21
25
|
protected :prologue
|
22
26
|
|
23
27
|
|
24
28
|
def run_impl
|
25
|
-
|
26
|
-
|
27
|
-
status = nil
|
29
|
+
@data = @command.run @runner
|
30
|
+
@run_impl_status = nil
|
28
31
|
root_path = @log.path
|
29
|
-
@output
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
else
|
39
|
-
raise_error 'bad sub commad output' if stream.nil?
|
40
|
-
end
|
32
|
+
YAML.load_from_io @data.output do |notification|
|
33
|
+
case notification
|
34
|
+
when Array
|
35
|
+
path, leaf = notification
|
36
|
+
@log.update(:new_leaf, root_path + path, leaf)
|
37
|
+
when Status
|
38
|
+
@run_impl_status = notification
|
39
|
+
else
|
40
|
+
raise_error 'bad sub commad output'
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
44
|
-
raise_error 'uttk stderr not empty' unless @error.my.zero?
|
45
|
-
@status = status
|
46
|
-
raise_status @status
|
43
|
+
@data.waitpid
|
47
44
|
end
|
48
45
|
protected :run_impl
|
49
46
|
|
50
47
|
|
51
48
|
def assertion
|
52
|
-
|
53
|
-
|
49
|
+
@data_error_contents = @data.error.read
|
50
|
+
ref = { :exit => (/^[02]$/) }
|
51
|
+
matcher_result = command_matcher[UM::StreamMatcher, ref, @data]
|
52
|
+
raise_error 'bad exit status' if matcher_result.failure?
|
53
|
+
raise_error 'bad status output' unless @run_impl_status.is_a? Status
|
54
|
+
raise_error 'uttk stderr not empty' unless @data_error_contents.empty?
|
55
|
+
@status = @run_impl_status
|
56
|
+
raise_status @status
|
54
57
|
end
|
55
58
|
protected :assertion
|
56
59
|
|
57
60
|
|
61
|
+
def abort_hook
|
62
|
+
@runner.abort @data if @runner and defined? @data
|
63
|
+
super
|
64
|
+
end
|
65
|
+
protected :abort_hook
|
66
|
+
|
67
|
+
|
58
68
|
def error_hook
|
59
|
-
|
60
|
-
|
69
|
+
if defined? @data
|
70
|
+
@log.my_stdout = @data.output.to_s_for_uttk_log unless @data.output.nil?
|
71
|
+
if defined? @data_error_contents and not @data_error_contents.empty?
|
72
|
+
@log.my_stderr = @data_error_contents.to_s_for_uttk_log
|
73
|
+
end
|
74
|
+
@log.my_exit = @data.status.exitstatus unless @data.status.nil?
|
75
|
+
end
|
61
76
|
super
|
62
77
|
end
|
63
78
|
protected :error_hook
|
64
79
|
|
65
80
|
|
66
|
-
def
|
67
|
-
@
|
81
|
+
def epilogue
|
82
|
+
@data.clean if defined? @data
|
68
83
|
super
|
69
84
|
end
|
70
|
-
protected :
|
85
|
+
protected :epilogue
|
86
|
+
|
71
87
|
|
88
|
+
attribute :args, 'the arguments for the command',
|
89
|
+
[Array, String, Numeric]
|
90
|
+
attribute :input, 'the input reference', :invisible, nil
|
91
|
+
attribute :env, 'environment variables', Hash do {} end
|
72
92
|
|
73
93
|
end # class SubCmd
|
74
94
|
|