uttk 0.3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +36 -0
- data/COPYING +18 -0
- data/ChangeLog +7673 -0
- data/GUIDELINES +86 -0
- data/LGPL +504 -0
- data/NEWS +158 -0
- data/NORM +137 -0
- data/README +180 -0
- data/Rakefile +8 -0
- data/SPEC.gemspec +15 -0
- data/SPEC.yml +60 -0
- data/TODO +23 -0
- data/TODO.old +31 -0
- data/VERSION +5 -0
- data/bin/getopts/uttk.rb +390 -0
- data/bin/uttk +188 -0
- data/bin/uttk-unit +125 -0
- data/lib/uttk.rb +288 -0
- data/lib/uttk/dumpers/Basic.rb +23 -0
- data/lib/uttk/dumpers/BasicColor.rb +35 -0
- data/lib/uttk/dumpers/Dumper.rb +77 -0
- data/lib/uttk/dumpers/Html.rb +271 -0
- data/lib/uttk/dumpers/Path.rb +24 -0
- data/lib/uttk/dumpers/Xml.rb +88 -0
- data/lib/uttk/dumpers/Yaml.rb +138 -0
- data/lib/uttk/filters.rb +128 -0
- data/lib/uttk/filters/Buffer.rb +119 -0
- data/lib/uttk/filters/Compact.rb +75 -0
- data/lib/uttk/filters/Default.rb +27 -0
- data/lib/uttk/filters/DefaultColor.rb +27 -0
- data/lib/uttk/filters/Filter.rb +53 -0
- data/lib/uttk/filters/Id.rb +30 -0
- data/lib/uttk/filters/JustStatus.rb +25 -0
- data/lib/uttk/filters/KeepSkipBased.rb +38 -0
- data/lib/uttk/filters/NodeCut.rb +97 -0
- data/lib/uttk/filters/RPathFilter.rb +134 -0
- data/lib/uttk/filters/Saver.rb +53 -0
- data/lib/uttk/filters/TextFilter.rb +69 -0
- data/lib/uttk/generators/dumper_generator.rb +28 -0
- data/lib/uttk/generators/filter_generator.rb +28 -0
- data/lib/uttk/generators/generator.rb +86 -0
- data/lib/uttk/generators/generator_generator.rb +26 -0
- data/lib/uttk/generators/loader_generator.rb +28 -0
- data/lib/uttk/generators/path_filter_generator.rb +28 -0
- data/lib/uttk/generators/strategy_generator.rb +28 -0
- data/lib/uttk/generators/templates/dumper.rb +50 -0
- data/lib/uttk/generators/templates/filter.rb +50 -0
- data/lib/uttk/generators/templates/generator.rb +28 -0
- data/lib/uttk/generators/templates/loader.rb +26 -0
- data/lib/uttk/generators/templates/path_filter.rb +28 -0
- data/lib/uttk/generators/templates/strategy.rb +59 -0
- data/lib/uttk/generators/templates/strategy.yml +28 -0
- data/lib/uttk/generators/templates/unit_test.rb +46 -0
- data/lib/uttk/loaders/Loader.rb +180 -0
- data/lib/uttk/loaders/Ruby.rb +28 -0
- data/lib/uttk/loaders/Yaml.rb +98 -0
- data/lib/uttk/logger.rb +306 -0
- data/lib/uttk/logger/backend.rb +170 -0
- data/lib/uttk/logger/path.rb +202 -0
- data/lib/uttk/logger/section_node.rb +214 -0
- data/lib/uttk/logger/severity.rb +63 -0
- data/lib/uttk/logger/to_uttk_log.rb +127 -0
- data/lib/uttk/logger/verbosity.rb +61 -0
- data/lib/uttk/logger_factory.rb +55 -0
- data/lib/uttk/path_filters/ColorStatus.rb +57 -0
- data/lib/uttk/path_filters/PathFilter.rb +27 -0
- data/lib/uttk/path_filters/RemoveTypes.rb +25 -0
- data/lib/uttk/status.rb +146 -0
- data/lib/uttk/strategies/Abort.rb +24 -0
- data/lib/uttk/strategies/Assert.rb +44 -0
- data/lib/uttk/strategies/Authors.rb +45 -0
- data/lib/uttk/strategies/Block.rb +113 -0
- data/lib/uttk/strategies/Bootstrap.rb +55 -0
- data/lib/uttk/strategies/Checkout.rb +64 -0
- data/lib/uttk/strategies/Clean.rb +29 -0
- data/lib/uttk/strategies/Cmd.rb +60 -0
- data/lib/uttk/strategies/CmdBase.rb +130 -0
- data/lib/uttk/strategies/Collection.rb +158 -0
- data/lib/uttk/strategies/Compile.rb +59 -0
- data/lib/uttk/strategies/Composite.rb +201 -0
- data/lib/uttk/strategies/Composite/contents_eval.rb +40 -0
- data/lib/uttk/strategies/Configure.rb +66 -0
- data/lib/uttk/strategies/Error.rb +23 -0
- data/lib/uttk/strategies/Fail.rb +26 -0
- data/lib/uttk/strategies/IOBased.rb +159 -0
- data/lib/uttk/strategies/Import.rb +60 -0
- data/lib/uttk/strategies/Iterate.rb +139 -0
- data/lib/uttk/strategies/JUnit.rb +205 -0
- data/lib/uttk/strategies/KillAll.rb +62 -0
- data/lib/uttk/strategies/Make.rb +94 -0
- data/lib/uttk/strategies/Package.rb +129 -0
- data/lib/uttk/strategies/PackageCollection.rb +78 -0
- data/lib/uttk/strategies/Pass.rb +24 -0
- data/lib/uttk/strategies/Pool.rb +104 -0
- data/lib/uttk/strategies/ProbabilityThreshold.rb +46 -0
- data/lib/uttk/strategies/Proxy.rb +42 -0
- data/lib/uttk/strategies/RMatch.rb +92 -0
- data/lib/uttk/strategies/RUnit.rb +132 -0
- data/lib/uttk/strategies/SignalCmd.rb +85 -0
- data/lib/uttk/strategies/Sleep.rb +36 -0
- data/lib/uttk/strategies/SqlQuery.rb +120 -0
- data/lib/uttk/strategies/Strategy.rb +683 -0
- data/lib/uttk/strategies/Stub.rb +37 -0
- data/lib/uttk/strategies/SubCmd.rb +77 -0
- data/lib/uttk/strategies/Suite.rb +71 -0
- data/lib/uttk/strategies/Test.rb +89 -0
- data/lib/uttk/streams.rb +69 -0
- data/lib/uttk/streams/Diff.rb +60 -0
- data/lib/uttk/streams/HexaDiff.rb +35 -0
- data/lib/uttk/streams/Stream.rb +76 -0
- data/lib/uttk/weights.rb +17 -0
- data/lib/uttk/weights/WExpr.rb +68 -0
- data/lib/uttk/weights/WFloat.rb +23 -0
- data/lib/uttk/weights/WMin.rb +22 -0
- data/lib/uttk/weights/Weight.rb +105 -0
- data/lib/www/javascripts/uttk.js +185 -0
- data/misc/expandtab.rb +29 -0
- data/misc/header.rb +44 -0
- data/misc/renaming +57 -0
- data/misc/textile_compiler +194 -0
- data/misc/uttk-grep.sh +8 -0
- data/misc/uttk-line-count.rb +143 -0
- data/test/examples-suite.yml +8 -0
- data/test/examples/README +68 -0
- data/test/examples/basic.rb +10 -0
- data/test/examples/basic.yml +9 -0
- data/test/examples/cache/cache_and_fatal.yml +5 -0
- data/test/examples/cache/simple.yml +30 -0
- data/test/examples/sql/basic.yml +24 -0
- data/test/examples/students-suite.yml +9 -0
- data/test/examples/students/ball.yml +11 -0
- data/test/examples/students/glob_stud.yml +20 -0
- data/test/examples/students/mini-lib.yml +61 -0
- data/test/examples/students/pool_stud.yml +31 -0
- data/test/examples/students/stud.yml +21 -0
- data/test/fixtures/ball/20040804-exam_a1-zapngo-tessar_m.tar.gz +0 -0
- data/test/fixtures/ball/Makefile +24 -0
- data/test/fixtures/ball/bar_p-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/bar_p-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/bar_p-mini-lib/my_strlen.c +13 -0
- data/test/fixtures/ball/foo_s-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/foo_s-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/foo_s-mini-lib/configure +2 -0
- data/test/fixtures/ball/foo_s-mini-lib/my_strlen.c +10 -0
- data/test/fixtures/ball/hello.tar.bz2 +0 -0
- data/test/fixtures/ball/hello.tar.gz +0 -0
- data/test/fixtures/ball/hello/Makefile +14 -0
- data/test/fixtures/ball/hello/hello.c +7 -0
- data/test/fixtures/ball/jack-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/jack-exit/Makefile +14 -0
- data/test/fixtures/ball/jack-exit/exit.c +16 -0
- data/test/fixtures/ball/joe-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/joe-exit/Makefile +14 -0
- data/test/fixtures/ball/joe-exit/exit.c +8 -0
- data/test/fixtures/ball/joe_i-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/joe_i-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/joe_i-mini-lib/configure +2 -0
- data/test/fixtures/ball/joe_i-mini-lib/my_strlen.c +10 -0
- data/test/fixtures/ball/john-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/john-exit/Makefile +14 -0
- data/test/fixtures/ball/john-exit/exit.c +6 -0
- data/test/fixtures/ball/qux_j-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/qux_j-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/qux_j-mini-lib/my_strlen.c +12 -0
- data/test/fixtures/binaries/segv +0 -0
- data/test/fixtures/binaries/segv.c +10 -0
- data/test/fixtures/binaries/segv.rb +2 -0
- data/test/fixtures/demo/command-tutorial/steps/1/check.yml +5 -0
- data/test/fixtures/demo/command-tutorial/steps/1/pluralizer.rb +10 -0
- data/test/fixtures/demo/command-tutorial/steps/2/bad_check.yml +7 -0
- data/test/fixtures/demo/command-tutorial/steps/2/check.yml +7 -0
- data/test/fixtures/demo/command-tutorial/steps/2/pluralizer.rb +10 -0
- data/test/fixtures/demo/command-tutorial/steps/3.1/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/3/check.yml +14 -0
- data/test/fixtures/demo/command-tutorial/steps/4.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/4.1/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/4/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/4/pluralizer.rb +12 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/check.yml +17 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/5/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/5/check.yml +16 -0
- data/test/fixtures/demo/command-tutorial/steps/5/pluralizer.rb +16 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/check.yml +22 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/6/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/6/check.yml +21 -0
- data/test/fixtures/demo/command-tutorial/steps/6/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/7/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/7/check.yml +22 -0
- data/test/fixtures/demo/command-tutorial/steps/7/pluralizer.rb +17 -0
- data/test/fixtures/demo/filter-tutorial/check.yml +20 -0
- data/test/fixtures/demo/filter-tutorial/filters/CutSkip100.rb +19 -0
- data/test/fixtures/demo/filter-tutorial/pluralizer.rb +17 -0
- data/test/fixtures/java/unit/MultiRight/Foo/Foo.java +11 -0
- data/test/fixtures/java/unit/MultiRight/Foo/FooTest.java +15 -0
- data/test/fixtures/java/unit/MultiRight/MultiRight.java +13 -0
- data/test/fixtures/java/unit/MultiRight/MultiRightTest.java +12 -0
- data/test/fixtures/java/unit/MultiRight/bar/Bar.java +11 -0
- data/test/fixtures/java/unit/MultiRight/bar/BarTest.java +21 -0
- data/test/fixtures/java/unit/MultiRight/build.sh +7 -0
- data/test/fixtures/java/unit/SimpleException/SimpleExceptionTest.java +11 -0
- data/test/fixtures/java/unit/SimpleException/build.sh +4 -0
- data/test/fixtures/java/unit/build.sh +9 -0
- data/test/fixtures/java/unit/multibar.yml +6 -0
- data/test/fixtures/java/unit/multifoo.yml +6 -0
- data/test/fixtures/java/unit/multiright.yml +8 -0
- data/test/fixtures/java/unit/simple_exception.yml +6 -0
- data/test/fixtures/mini-lib/Makefile +9 -0
- data/test/fixtures/mini-lib/strlen.c +15 -0
- data/test/fixtures/package/pkg_foo.tar.gz +0 -0
- data/test/fixtures/package/pkg_foo/Makefile +20 -0
- data/test/fixtures/package/pkg_foo/bootstrap +3 -0
- data/test/fixtures/package/pkg_foo/configure +3 -0
- data/test/fixtures/package/pkg_foo/foo.sh +2 -0
- data/test/fixtures/text/1.txt +4 -0
- data/test/fixtures/unit/bad.rb +26 -0
- data/test/fixtures/unit/error.rb +6 -0
- data/test/fixtures/unit/good.rb +26 -0
- data/test/functional-suite.yml +10 -0
- data/test/functional/author.yml +11 -0
- data/test/functional/base.yml +119 -0
- data/test/functional/base_pool.yml +13 -0
- data/test/functional/block.yml +13 -0
- data/test/functional/cat.yml +16 -0
- data/test/functional/cmd.yml +17 -0
- data/test/functional/diff.yml +27 -0
- data/test/functional/env_cmd.yml +53 -0
- data/test/functional/exit.yml +15 -0
- data/test/functional/fatal.yml +23 -0
- data/test/functional/glob.yml +11 -0
- data/test/functional/hexa-diff.yml +25 -0
- data/test/functional/import.yml +41 -0
- data/test/functional/iterate.yml +99 -0
- data/test/functional/killall.yml +31 -0
- data/test/functional/pkg.yml +14 -0
- data/test/functional/probability_threshold.yml +35 -0
- data/test/functional/r_unit.yml +26 -0
- data/test/functional/rmatch.yml +122 -0
- data/test/functional/signal_cmd.yml +22 -0
- data/test/functional/sub.yml +15 -0
- data/test/functional/test.yml +25 -0
- data/test/functional/timeout.yml +20 -0
- data/test/functional/wc.yml +26 -0
- data/test/functional/weight.yml +152 -0
- data/test/pkg-suite.yml +8 -0
- data/test/pkg/cmdline.yml +80 -0
- data/test/pool-suite.yml +8 -0
- data/test/pool/base.yml +12 -0
- data/test/pool/pool.yml +25 -0
- data/test/ruby-suite.rb +10 -0
- data/test/ruby-suite.yml +5 -0
- data/test/ruby/base.rb +119 -0
- data/test/ruby/iterate.rb +21 -0
- data/test/ruby/wc.rb +43 -0
- data/test/unit-suite.yml +10 -0
- data/test/unit/dumpers/path_test.rb +46 -0
- data/test/unit/dumpers/xml_test.rb +65 -0
- data/test/unit/dumpers/yaml_test.rb +65 -0
- data/test/unit/filters/buffer_test.rb +168 -0
- data/test/unit/filters/keep_skip_based_test.rb +46 -0
- data/test/unit/filters/node_cut_test.rb +72 -0
- data/test/unit/filters/rpath_filter_test.rb +191 -0
- data/test/unit/filters/text_filter_test.rb +46 -0
- data/test/unit/filters_test.rb +119 -0
- data/test/unit/logger/section_node_test.rb +120 -0
- data/test/unit/logger/severity_test.rb +37 -0
- data/test/unit/logger/to_uttk_log_test.rb +113 -0
- data/test/unit/logger/verbosity_test.rb +44 -0
- data/test/unit/logger_test.rb +203 -0
- data/test/unit/strategies/suite_test.rb +151 -0
- data/test/uttk-check.yml +8 -0
- data/test/uttk-distcheck.yml +18 -0
- metadata +399 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
# Author:: Nicolas Despres <nicolas.despres@gmail.com>.
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/Stub.rb 22102 2006-02-21T23:03:39.538964Z pouillar $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Strategies
|
10
|
+
|
11
|
+
# I repeat to the log the hash of value given to my attribute
|
12
|
+
# _"returned_value"_
|
13
|
+
class Stub < Strategy
|
14
|
+
include Concrete
|
15
|
+
|
16
|
+
protected
|
17
|
+
def run_impl
|
18
|
+
@returned_value.each { |k, v| @log[k] = v }
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
def assertion
|
23
|
+
pass
|
24
|
+
end
|
25
|
+
|
26
|
+
attribute :returned_value, 'attribute which are going to be copied',
|
27
|
+
:mandatory,
|
28
|
+
:invisible do {} end
|
29
|
+
|
30
|
+
end # class Stub
|
31
|
+
|
32
|
+
end # module Strategies
|
33
|
+
|
34
|
+
end # module Uttk
|
35
|
+
|
36
|
+
|
37
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/SubCmd.rb 22112 2006-02-22T08:30:11.236459Z pouillar $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Strategies
|
10
|
+
|
11
|
+
# I run a sub Uttk or an another program that can behave like it.
|
12
|
+
class SubCmd < CmdBase
|
13
|
+
include Concrete
|
14
|
+
|
15
|
+
def prologue
|
16
|
+
@command = @symtbl[:uttk]
|
17
|
+
@dir = @symtbl[:pwd]
|
18
|
+
@quiet_print = true
|
19
|
+
super
|
20
|
+
end
|
21
|
+
protected :prologue
|
22
|
+
|
23
|
+
|
24
|
+
def run_impl
|
25
|
+
super
|
26
|
+
raise_error 'no uttk output' unless @output.my.exist?
|
27
|
+
status = nil
|
28
|
+
root_path = @log.path
|
29
|
+
@output.my.open do |out|
|
30
|
+
YAML::each_node(out) do |node|
|
31
|
+
notification = node.symbol_safe_transform
|
32
|
+
case notification
|
33
|
+
when Array
|
34
|
+
path, leaf = notification
|
35
|
+
@log.update(:new_leaf, root_path + path, leaf)
|
36
|
+
when Status
|
37
|
+
status = notification
|
38
|
+
else
|
39
|
+
raise_error 'bad sub commad output' if stream.nil?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
raise_error 'bad status output' unless status.is_a? Status
|
44
|
+
raise_error 'uttk stderr not empty' unless @error.my.zero?
|
45
|
+
@status = status
|
46
|
+
raise_status @status
|
47
|
+
end
|
48
|
+
protected :run_impl
|
49
|
+
|
50
|
+
|
51
|
+
def assertion
|
52
|
+
raise_error "bad exit status #@my_exit" unless [0, 2].include? @my_exit
|
53
|
+
super
|
54
|
+
end
|
55
|
+
protected :assertion
|
56
|
+
|
57
|
+
|
58
|
+
def error_hook
|
59
|
+
@log.my_stdout = @output.my.read if @output and @output.my.exist?
|
60
|
+
@log.my_stderr = @error.my.read if @error and @error.my.exist?
|
61
|
+
super
|
62
|
+
end
|
63
|
+
protected :error_hook
|
64
|
+
|
65
|
+
|
66
|
+
def mk_command
|
67
|
+
@args = "#@args -F Path --dump-status"
|
68
|
+
super
|
69
|
+
end
|
70
|
+
protected :mk_command
|
71
|
+
|
72
|
+
|
73
|
+
end # class SubCmd
|
74
|
+
|
75
|
+
end # module Strategies
|
76
|
+
|
77
|
+
end # module Uttk
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# $Id: /fey/uttk/trunk/lib/uttk/strategies/Suite.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Strategies
|
10
|
+
|
11
|
+
# An ordered collection of tests which can be #run.
|
12
|
+
#
|
13
|
+
# A the Suite class has two goals:
|
14
|
+
# - group a set of Strategy in a single object which is a Strategy.
|
15
|
+
# - factor some attributes which are identical in each tests of the
|
16
|
+
# the suite.
|
17
|
+
#
|
18
|
+
# == Example
|
19
|
+
# require 'uttk'
|
20
|
+
# include Uttk
|
21
|
+
#
|
22
|
+
# symtbl = SymTbl.new
|
23
|
+
# symtbl[:loader] = Loaders::Yaml.new
|
24
|
+
# aSuite = Strategies::Suite.new({
|
25
|
+
# :name => 'A set of tests',
|
26
|
+
# :symtbl => symtbl,
|
27
|
+
# :wclass => Weights::WFloat,
|
28
|
+
# :attributes => {
|
29
|
+
# :strategy => Strategies::Cmd,
|
30
|
+
# :exit => 0
|
31
|
+
# },
|
32
|
+
# :contents => OHash[
|
33
|
+
# "I'm suppose to pass 1", { :command => "true" },
|
34
|
+
# "I'm suppose to fail 2", { :command => "false", :weight => -1 },
|
35
|
+
# "I'm suppose to pass 3", { :command => "false",
|
36
|
+
# :exit => 1 }
|
37
|
+
# ]
|
38
|
+
# })
|
39
|
+
# aSuite.run(Logger.new(Dumpers::Yaml.new(STDOUT)))
|
40
|
+
#
|
41
|
+
# aSuite = Strategies::Suite.new
|
42
|
+
# aSuite.name = 'A set of tests'
|
43
|
+
# aSuite.symtbl = symtbl
|
44
|
+
# aSuite.wclass = Weights::WFloat
|
45
|
+
# aSuite.strategyclass = Strategies::Cmd
|
46
|
+
# aSuite.exit = 0 # a sugar when its unambiguous.
|
47
|
+
# t1 = aSuite.create
|
48
|
+
# t1.name = "I'm suppose to pass 4"
|
49
|
+
# t1.command = "true"
|
50
|
+
# aSuite.create({ :name => "I'm suppose to fail 5",
|
51
|
+
# :command => "false",
|
52
|
+
# :weight => -1 })
|
53
|
+
# io = Tempfile.new('uttk-example')
|
54
|
+
# io << << EOF
|
55
|
+
# ---
|
56
|
+
# name: I'm suppose to pass 6
|
57
|
+
# command: false
|
58
|
+
# exit: 1
|
59
|
+
# EOF
|
60
|
+
# io.rewind
|
61
|
+
# aSuite.create(io)
|
62
|
+
# aSuite.run(Logger.new(Dumpers::Yaml.new(STDOUT)))
|
63
|
+
class Suite < Collection
|
64
|
+
include Concrete
|
65
|
+
include Ordered
|
66
|
+
end # class Suite
|
67
|
+
|
68
|
+
end # module Strategies
|
69
|
+
|
70
|
+
end # module Uttk
|
71
|
+
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Author:: Nicolas Despres <nicolas.despres@gmail.com>.
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# $Id: /fey/uttk/trunk/lib/uttk/strategies/Test.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
5
|
+
|
6
|
+
|
7
|
+
require 'yaml'
|
8
|
+
require 'diff'
|
9
|
+
|
10
|
+
|
11
|
+
module Uttk
|
12
|
+
|
13
|
+
module Strategies
|
14
|
+
|
15
|
+
# A strategy to test them all.
|
16
|
+
class Test < Proxy
|
17
|
+
include Concrete
|
18
|
+
|
19
|
+
#FIXME: add support to test filter
|
20
|
+
|
21
|
+
def initialize(*a, &b)
|
22
|
+
super
|
23
|
+
@outfile = nil
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
def prologue
|
28
|
+
super
|
29
|
+
@outfile = TempPath.new
|
30
|
+
create(@test)
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
def run_impl_test(test, log)
|
35
|
+
test.reject :name, :status, :strategy # FIXME : Try to remove this if possible
|
36
|
+
my_log = nil
|
37
|
+
@outfile.open('w') do |io|
|
38
|
+
my_log = Logger.new(Dumpers::Yaml.new(io))
|
39
|
+
@returned_status = super(test, my_log)
|
40
|
+
my_log.close if my_log
|
41
|
+
end
|
42
|
+
@returned_status
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
def assertion
|
47
|
+
returned_log = nil
|
48
|
+
@outfile.open { |io| returned_log = YAML.load(io) }
|
49
|
+
unless returned_log.is_a?(Hash) or returned_log.is_a?(Array)
|
50
|
+
raise('the result must be either a hash or an array')
|
51
|
+
end
|
52
|
+
del_ignored_value(returned_log)
|
53
|
+
del_ignored_value(@expected_log)
|
54
|
+
diff = @expected_log.gen_diff(returned_log) {|a, b| a.to_s == b.to_s}
|
55
|
+
if diff.no_diff?
|
56
|
+
pass
|
57
|
+
else
|
58
|
+
@log[:differences] = diff
|
59
|
+
fail('there is differences')
|
60
|
+
end
|
61
|
+
super
|
62
|
+
end
|
63
|
+
|
64
|
+
protected
|
65
|
+
def epilogue
|
66
|
+
@outfile.clean if @outfile
|
67
|
+
super
|
68
|
+
end
|
69
|
+
|
70
|
+
protected
|
71
|
+
def del_ignored_value(hash)
|
72
|
+
hash.delete_if {|k, _| @ignored_value.include?(k.to_s)}
|
73
|
+
end
|
74
|
+
|
75
|
+
attribute :test, 'the test to test',
|
76
|
+
:mandatory, :dont_expand
|
77
|
+
attribute :expected_status, 'the expected status',
|
78
|
+
:mandatory
|
79
|
+
attribute :expected_log, 'the expected log result',
|
80
|
+
:mandatory, :invisible
|
81
|
+
attribute :ignored_value, 'the list of attributes for which the ' +
|
82
|
+
'value is not compared',
|
83
|
+
[], :invisible do [] end
|
84
|
+
|
85
|
+
end # class Test
|
86
|
+
|
87
|
+
end # module Strategies
|
88
|
+
|
89
|
+
end # module Uttk
|
data/lib/uttk/streams.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2005 Uttk team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# Revision:: $Id: /fey/uttk/trunk/lib/uttk/streams.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
5
|
+
|
6
|
+
module Uttk
|
7
|
+
|
8
|
+
module Streams
|
9
|
+
|
10
|
+
#
|
11
|
+
# Internal classes
|
12
|
+
#
|
13
|
+
|
14
|
+
autoloaded_module(__FILE__)
|
15
|
+
|
16
|
+
end # module Streams
|
17
|
+
|
18
|
+
end # module Uttk
|
19
|
+
|
20
|
+
class Object
|
21
|
+
def compare_stream ( stream )
|
22
|
+
to_s.compare_stream(stream)
|
23
|
+
end
|
24
|
+
def to_s_for_uttk_log
|
25
|
+
self
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class NilClass
|
30
|
+
def compare_stream ( stream )
|
31
|
+
true
|
32
|
+
end
|
33
|
+
def to_s_for_uttk_log
|
34
|
+
false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Regexp
|
39
|
+
def compare_stream ( stream )
|
40
|
+
stream.read =~ self
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class String
|
45
|
+
def compare_stream ( stream )
|
46
|
+
self == stream.read
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class Pathname
|
51
|
+
def compare_stream ( stream )
|
52
|
+
read.compare_stream(stream)
|
53
|
+
end
|
54
|
+
def to_s_for_uttk_log
|
55
|
+
read
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class IO
|
60
|
+
def compare_stream ( stream )
|
61
|
+
rewind
|
62
|
+
read.compare_stream(stream)
|
63
|
+
end
|
64
|
+
def to_s_for_uttk_log
|
65
|
+
rewind
|
66
|
+
read
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# $Id: /fey/uttk/trunk/lib/uttk/streams/Diff.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Streams
|
10
|
+
|
11
|
+
class Diff < Stream
|
12
|
+
|
13
|
+
def to_uttk_log ( log )
|
14
|
+
log["diff_#@name"] = @ref.to_diff_for_uttk_log(@my) if @ref.can_diff?
|
15
|
+
end
|
16
|
+
|
17
|
+
end # Diff
|
18
|
+
|
19
|
+
end # module Streams
|
20
|
+
|
21
|
+
end # module Uttk
|
22
|
+
|
23
|
+
class Object
|
24
|
+
def to_diff_for_uttk_log ( my )
|
25
|
+
IO.popen("diff -u --label my #{my} --label ref -", 'r+') do |diff|
|
26
|
+
diff << to_s
|
27
|
+
diff.close_write
|
28
|
+
diff.readlines.join
|
29
|
+
end
|
30
|
+
end
|
31
|
+
def can_diff?
|
32
|
+
true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class NilClass
|
37
|
+
def can_diff?
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Regexp
|
43
|
+
def can_diff?
|
44
|
+
false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class Pathname
|
49
|
+
def to_diff_for_uttk_log ( my )
|
50
|
+
open.to_diff_for_uttk_log(my)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class IO
|
55
|
+
def to_diff_for_uttk_log ( my )
|
56
|
+
rewind
|
57
|
+
readlines.join.to_diff_for_uttk_log(my)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Author:: Nicolas Despr�s <nicolas.despres@gmail.com>.
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# $Id: Diff.rb 720 2005-09-26 04:34:48Z ertai $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Streams
|
10
|
+
|
11
|
+
class HexaDiff < Diff
|
12
|
+
|
13
|
+
#FIXME: manage only !path :-(
|
14
|
+
def to_uttk_log ( log )
|
15
|
+
if @name == "output"
|
16
|
+
if @ref.can_diff?
|
17
|
+
TempPath.new('hexa-diff-output') do |hexa_my|
|
18
|
+
system "hexdump -C #@my > #{hexa_my}"
|
19
|
+
TempPath.new('hexa-diff-output') do |hexa_ref|
|
20
|
+
system "hexdump -C #@ref > #{hexa_ref}"
|
21
|
+
log["hexa_diff_#@name"] = hexa_ref.to_diff_for_uttk_log(hexa_my)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
else
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end # HexaDiff
|
31
|
+
|
32
|
+
end # module Streams
|
33
|
+
|
34
|
+
end # module Uttk
|
35
|
+
|