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,26 @@
|
|
1
|
+
# Author:: <%= fullname %> <<%= email %>>.
|
2
|
+
# Copyright:: Copyright (c) <%= year %> Uttk Team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# Revision:: $Id: /fey/uttk/trunk/lib/uttk/generators/templates/loader.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
5
|
+
|
6
|
+
module Uttk
|
7
|
+
|
8
|
+
module Loaders
|
9
|
+
|
10
|
+
class <%= class_name %> < Loader
|
11
|
+
include Concrete
|
12
|
+
|
13
|
+
def initialize ( *a, &b )
|
14
|
+
super
|
15
|
+
# ...
|
16
|
+
end
|
17
|
+
|
18
|
+
def load ( aString, aSymtbl=nil )
|
19
|
+
# ...
|
20
|
+
end
|
21
|
+
|
22
|
+
end # class <%= class_name %>
|
23
|
+
|
24
|
+
end # module Loaders
|
25
|
+
|
26
|
+
end # module Uttk
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Author:: <%= fullname %> <<%= email %>>.
|
2
|
+
# Copyright:: Copyright (c) <%= year %> Uttk Team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/generators/templates/path_filter.rb 21844 2006-02-17T17:26:59.771162Z pouillar $
|
5
|
+
|
6
|
+
module Uttk
|
7
|
+
|
8
|
+
module PathFilters
|
9
|
+
|
10
|
+
class <%= class_name %> < PathFilter
|
11
|
+
include Concrete
|
12
|
+
|
13
|
+
def initialize ( *a, &b )
|
14
|
+
super
|
15
|
+
# ...
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def filter ( path, leaf )
|
20
|
+
# ...
|
21
|
+
[filtered_path, filtered_leaf]
|
22
|
+
end
|
23
|
+
|
24
|
+
end # class <%= class_name %>
|
25
|
+
|
26
|
+
end # module PathFilters
|
27
|
+
|
28
|
+
end # module Uttk
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Author:: <%= fullname %> <<%= email %>>.
|
2
|
+
# Copyright:: Copyright (c) <%= year %> Uttk Team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# Revision:: $Id: /fey/uttk/trunk/lib/uttk/generators/templates/strategy.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Strategies
|
10
|
+
|
11
|
+
class <%= class_name %> < Strategy
|
12
|
+
include Concrete
|
13
|
+
|
14
|
+
#
|
15
|
+
# Methods
|
16
|
+
#
|
17
|
+
|
18
|
+
def prologue
|
19
|
+
super
|
20
|
+
# ...
|
21
|
+
end
|
22
|
+
protected :prologue
|
23
|
+
|
24
|
+
|
25
|
+
def run_impl
|
26
|
+
# ...
|
27
|
+
super
|
28
|
+
# ...
|
29
|
+
end
|
30
|
+
protected :run_impl
|
31
|
+
|
32
|
+
|
33
|
+
def assertion
|
34
|
+
# ...
|
35
|
+
super
|
36
|
+
end
|
37
|
+
protected :assertion
|
38
|
+
|
39
|
+
|
40
|
+
def epilogue
|
41
|
+
# ...
|
42
|
+
super
|
43
|
+
end
|
44
|
+
protected :epilogue
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
#
|
49
|
+
# Attributes
|
50
|
+
#
|
51
|
+
|
52
|
+
attribute :an_attribute, 'a description', THE_CLASS, DEFAULT_VALUE,
|
53
|
+
:mandatory, :invisible
|
54
|
+
|
55
|
+
end # class <%= class_name %>
|
56
|
+
|
57
|
+
end # module Strategies
|
58
|
+
|
59
|
+
end # module Uttk
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
Test the <%= class_name %> strategy: !S::Suite
|
3
|
+
contents:
|
4
|
+
- good test 1: !S::RMatch
|
5
|
+
test: !S::<%= class_name %>
|
6
|
+
# ...
|
7
|
+
match:
|
8
|
+
- // # ...
|
9
|
+
- //
|
10
|
+
- //
|
11
|
+
dont_match:
|
12
|
+
- // # ...
|
13
|
+
- //
|
14
|
+
- //
|
15
|
+
|
16
|
+
- bad test 1: !S::RMatch
|
17
|
+
test: !S::<%= class_name %>
|
18
|
+
# ...
|
19
|
+
match:
|
20
|
+
- // # ...
|
21
|
+
- //
|
22
|
+
- //
|
23
|
+
dont_match:
|
24
|
+
- // # ...
|
25
|
+
- //
|
26
|
+
- //
|
27
|
+
|
28
|
+
- # ...
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Author:: <%= fullname %> <<%= email %>>.
|
2
|
+
# Copyright:: Copyright (c) <%= year %> Uttk Team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# Revision:: $Id: /fey/uttk/trunk/lib/uttk/generators/templates/unit_test.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
5
|
+
|
6
|
+
test_section __FILE__ do
|
7
|
+
|
8
|
+
module Uttk
|
9
|
+
|
10
|
+
module <%= module_name %>
|
11
|
+
|
12
|
+
class <%= class_name %>Test < ::Test::Unit::TestCase
|
13
|
+
|
14
|
+
#
|
15
|
+
# Methods
|
16
|
+
#
|
17
|
+
|
18
|
+
def setup
|
19
|
+
super
|
20
|
+
# ...
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
super
|
25
|
+
# ...
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Tests
|
30
|
+
#
|
31
|
+
|
32
|
+
def test_xxx
|
33
|
+
# ...
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_yyy
|
37
|
+
# ...
|
38
|
+
end
|
39
|
+
|
40
|
+
end # class <%= class_name %>Test
|
41
|
+
|
42
|
+
end # module <%= module_name %>
|
43
|
+
|
44
|
+
end # module Uttk
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,180 @@
|
|
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/loaders/Loader.rb 8788 2005-09-27T14:23:19.686215Z ertai $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
# Uttk::Loaders are design to help you to make tests.
|
10
|
+
#
|
11
|
+
# The `testify' method is here to provide a usefull way
|
12
|
+
# to convert anything to a test.
|
13
|
+
#
|
14
|
+
# For example Hash#testify instanciate a test from a hash:
|
15
|
+
#
|
16
|
+
# doc = {
|
17
|
+
# :strategy => Cmd,
|
18
|
+
# :command => 'echo -n foo',
|
19
|
+
# :output => 'foo',
|
20
|
+
# :symtbl => SYMTBL
|
21
|
+
# }
|
22
|
+
#
|
23
|
+
# test = doc.testify
|
24
|
+
# test.run
|
25
|
+
#
|
26
|
+
# You can also load a test from a string, an io or a file.
|
27
|
+
# In this case the format can change (YAML, XML...).
|
28
|
+
# To manage this you can use Uttk::Loaders to add new loader easily.
|
29
|
+
#
|
30
|
+
# To implement a loader you just need to subclass the abstract
|
31
|
+
# loader (Uttk::Loaders::Loader), and implement the `load'
|
32
|
+
# method.
|
33
|
+
#
|
34
|
+
# The `load' method take an IO as argument and return
|
35
|
+
# something which can be testified.
|
36
|
+
module Loaders
|
37
|
+
|
38
|
+
def self.get_class ( aClassName )
|
39
|
+
return aClassName if aClassName.is_a? Class
|
40
|
+
aClassName = "Uttk::Strategies::#{aClassName}" unless aClassName =~ /::/
|
41
|
+
return eval(aClassName) if aClassName =~ /[\w:]+/
|
42
|
+
raise NameError, "not a valid class name #{aClassName}"
|
43
|
+
end
|
44
|
+
|
45
|
+
# FIXME: document me
|
46
|
+
class Loader
|
47
|
+
include Abstract
|
48
|
+
|
49
|
+
# Override this method in subclasses. It must returns an object which
|
50
|
+
# respond to testify. The argument _aString_ contains the contents of the
|
51
|
+
# loaded file. The _symtbl_ argument is the current table of symbols.
|
52
|
+
def load ( aString, symtbl=nil )
|
53
|
+
raise NotImplementedError
|
54
|
+
end
|
55
|
+
|
56
|
+
end # class Loader
|
57
|
+
|
58
|
+
end # module Loaders
|
59
|
+
|
60
|
+
end # module Uttk
|
61
|
+
|
62
|
+
|
63
|
+
class Object
|
64
|
+
|
65
|
+
def uttk_testify ( symtbl=nil, &block )
|
66
|
+
symtbl = Uttk.default_symtbl if symtbl.nil?
|
67
|
+
testify(symtbl.new_child, &block)
|
68
|
+
end
|
69
|
+
|
70
|
+
end # class Object
|
71
|
+
|
72
|
+
|
73
|
+
class Pathname
|
74
|
+
|
75
|
+
def testify ( symtbl, &block )
|
76
|
+
symtbl[:pwd] = self.expand_path.dirname
|
77
|
+
symtbl[:basename] = self.basename
|
78
|
+
symtbl[:realname] = self
|
79
|
+
open { |f| f.testify(symtbl, &block) }
|
80
|
+
end
|
81
|
+
|
82
|
+
end # class Pathname
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
class String
|
87
|
+
|
88
|
+
def testify ( symtbl, &block )
|
89
|
+
unless symtbl.has_key? :loader
|
90
|
+
raise ArgumentError, "No loader found in options (:loader)"
|
91
|
+
end
|
92
|
+
symtbl[:loader].load(self, symtbl).testify(symtbl, &block)
|
93
|
+
end
|
94
|
+
|
95
|
+
end # class String
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
class IO
|
100
|
+
|
101
|
+
def testify ( symtbl, &block )
|
102
|
+
read.testify(symtbl, &block)
|
103
|
+
end
|
104
|
+
|
105
|
+
end # class IO
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
class StringIO
|
110
|
+
|
111
|
+
def testify ( symtbl, &block )
|
112
|
+
read.testify(symtbl, &block)
|
113
|
+
end
|
114
|
+
|
115
|
+
end # class StringIO
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
class Class
|
120
|
+
|
121
|
+
def testify ( symtbl, &block )
|
122
|
+
raise ArgumentError, "nil symtbl" if symtbl.nil?
|
123
|
+
unless self < Uttk::Strategies::Strategy
|
124
|
+
raise ArgumentError, "Need a subclass of Strategy not #{name}"
|
125
|
+
end
|
126
|
+
new do |t|
|
127
|
+
t.symtbl ||= symtbl
|
128
|
+
block[t] if block
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
end # class Class
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
class Hash
|
137
|
+
|
138
|
+
def testify ( symtbl, &block )
|
139
|
+
|
140
|
+
if size == 1 and (tab = to_a[0])[1].is_a? Hash
|
141
|
+
name, doc = tab
|
142
|
+
doc[:name] = name
|
143
|
+
return doc.testify(symtbl, &block)
|
144
|
+
end
|
145
|
+
|
146
|
+
raise ArgumentError, "nil symtbl" if symtbl.nil?
|
147
|
+
|
148
|
+
strategy = self[:strategy] || symtbl[:strategy]
|
149
|
+
|
150
|
+
if strategy.nil?
|
151
|
+
raise ArgumentError, "no strategy for this test (#{inspect})"
|
152
|
+
end
|
153
|
+
|
154
|
+
Uttk::Loaders.get_class(strategy).new do |t|
|
155
|
+
t.symtbl ||= symtbl
|
156
|
+
block[t] if block
|
157
|
+
t.assign(self)
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
end # class Hash
|
163
|
+
|
164
|
+
|
165
|
+
class Array
|
166
|
+
|
167
|
+
def testify ( symtbl, &block )
|
168
|
+
raise ArgumentError, "nil symtbl" if symtbl.nil?
|
169
|
+
Uttk::Strategies::Suite.new do |t|
|
170
|
+
t.symtbl = symtbl
|
171
|
+
t.name = symtbl[:suite_name]
|
172
|
+
t.wclass = symtbl[:wclass]
|
173
|
+
t.attributes = symtbl[:attributes]
|
174
|
+
t.symbols = symtbl[:symbols]
|
175
|
+
t.contents = self
|
176
|
+
block[t] if block
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
end # class Array
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Author:: Nicolas Despr�s <nicolas.despres@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# $Id: /fey/uttk/trunk/lib/uttk/loaders/Ruby.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
5
|
+
|
6
|
+
|
7
|
+
module Uttk
|
8
|
+
|
9
|
+
module Loaders
|
10
|
+
|
11
|
+
class Ruby < Loader
|
12
|
+
include Concrete
|
13
|
+
|
14
|
+
def load ( aString, symtbl )
|
15
|
+
test = Uttk.uttk_eval(aString, symtbl, symtbl[:realname].to_s)
|
16
|
+
test.symtbl = symtbl if test.symtbl.nil?
|
17
|
+
test
|
18
|
+
end
|
19
|
+
|
20
|
+
end # class Ruby
|
21
|
+
|
22
|
+
end # module Loaders
|
23
|
+
|
24
|
+
end # module Uttk
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/loaders/Yaml.rb 21931 2006-02-19T14:37:25.597406Z pouillar $
|
5
|
+
|
6
|
+
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
module Uttk
|
10
|
+
|
11
|
+
module Loaders
|
12
|
+
|
13
|
+
class Yaml < Loader
|
14
|
+
include Concrete
|
15
|
+
|
16
|
+
def load ( aString, symtbl=nil )
|
17
|
+
tree = YAML::parse(aString)
|
18
|
+
return nil unless tree
|
19
|
+
tree.uttk_loader_yaml_transform
|
20
|
+
end
|
21
|
+
|
22
|
+
end # class Yaml
|
23
|
+
|
24
|
+
end # module Loaders
|
25
|
+
|
26
|
+
end # module Uttk
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
module YAML
|
31
|
+
|
32
|
+
module Syck
|
33
|
+
class Scalar
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module BaseNode
|
38
|
+
|
39
|
+
CLASS_KEY_LIST = [:strategy, :wclass, :symtbl_class]
|
40
|
+
|
41
|
+
def key_transform ( t, k, v )
|
42
|
+
k = k.uttk_loader_yaml_transform if k.is_a? BaseNode
|
43
|
+
case k
|
44
|
+
when Symbol
|
45
|
+
when Integer
|
46
|
+
when /^:"(.*)"/, /^:(.*)/ then k = $1.to_sym
|
47
|
+
else k = k.to_s.to_sym
|
48
|
+
end
|
49
|
+
if CLASS_KEY_LIST.include?(k) and (val = v.value) =~ /^[A-Z]/
|
50
|
+
t[k] = Uttk::Loaders.get_class(val)
|
51
|
+
elsif v.is_a? BaseNode
|
52
|
+
t[k] = v.uttk_loader_yaml_transform
|
53
|
+
else
|
54
|
+
t[k] = v
|
55
|
+
end
|
56
|
+
end
|
57
|
+
private :key_transform
|
58
|
+
|
59
|
+
def uttk_loader_yaml_transform
|
60
|
+
@type_id = nil unless defined? @type_id
|
61
|
+
t = nil
|
62
|
+
case @value
|
63
|
+
when Hash
|
64
|
+
t = Hash.new
|
65
|
+
if HAVE_YAML_TAGURI
|
66
|
+
@value.each do |k, v|
|
67
|
+
key_transform(t, k, v)
|
68
|
+
end
|
69
|
+
else
|
70
|
+
children_with_index.each do |v, k|
|
71
|
+
key_transform(t, k, v)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
when Array
|
75
|
+
if not @value.empty? and @value.all? { |x| x.is_a? Hash and x.size == 1 }
|
76
|
+
t = OHash.new
|
77
|
+
@value.each do |x|
|
78
|
+
k, v = x.to_a
|
79
|
+
key_transform(t, k, v)
|
80
|
+
end
|
81
|
+
else
|
82
|
+
t = Array.new
|
83
|
+
@value.each do |v|
|
84
|
+
t.push v.uttk_loader_yaml_transform
|
85
|
+
end
|
86
|
+
end
|
87
|
+
when /^:"(.*)"/, /^:(.*)/
|
88
|
+
@type_id = nil
|
89
|
+
t = $1.to_sym
|
90
|
+
else
|
91
|
+
return transform
|
92
|
+
end
|
93
|
+
YAML.transfer(@type_id, t)
|
94
|
+
end
|
95
|
+
|
96
|
+
end # module BaseNode
|
97
|
+
|
98
|
+
end # module YAML
|