uttk 0.3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,158 @@
|
|
|
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/Collection.rb 22102 2006-02-21T23:03:39.538964Z pouillar $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
module Strategies
|
|
10
|
+
|
|
11
|
+
# I do the same job as the _Composite_ strategy, plus I provide the
|
|
12
|
+
# _attributes_ attribute which allow to share common attributes of the
|
|
13
|
+
# strategies I compose.
|
|
14
|
+
class Collection < Composite
|
|
15
|
+
include Abstract
|
|
16
|
+
|
|
17
|
+
attr_reader :internal_contents
|
|
18
|
+
protected :internal_contents
|
|
19
|
+
|
|
20
|
+
def initialize ( *a, &b )
|
|
21
|
+
@attributes = OHash.new
|
|
22
|
+
@internal_contents = []
|
|
23
|
+
super
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# Create a new test, using the current loader, and add it to the
|
|
28
|
+
# collection.
|
|
29
|
+
def create ( anObject=strategyclass, &block )
|
|
30
|
+
super do |t|
|
|
31
|
+
@log.debug{"assign collection attributes #{@attributes.size}"}
|
|
32
|
+
@attributes.each do |k,v|
|
|
33
|
+
@log.debug{"assign attribute: #{k}"}
|
|
34
|
+
next if k == :contents
|
|
35
|
+
t.assign_one(k, v, true)
|
|
36
|
+
end
|
|
37
|
+
if @attributes.has_key? :contents
|
|
38
|
+
t.assign_one(:contents, @attributes[:contents], true)
|
|
39
|
+
end
|
|
40
|
+
block[t] if block
|
|
41
|
+
@attributes.each do |k,v|
|
|
42
|
+
t.reject k if t.respond_to? k and t.send(k) == v
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def prologue
|
|
49
|
+
super
|
|
50
|
+
# Create sub tests
|
|
51
|
+
if @internal_contents.is_a? Hash
|
|
52
|
+
unless @internal_contents.ordered?
|
|
53
|
+
raise ArgumentError, 'hash not ordered'
|
|
54
|
+
end
|
|
55
|
+
@internal_contents.each do |name, doc|
|
|
56
|
+
if doc.is_a? Hash
|
|
57
|
+
internal_create(doc, name)
|
|
58
|
+
else
|
|
59
|
+
create(doc)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
elsif @internal_contents.is_a? Array
|
|
63
|
+
@internal_contents.each do |doc|
|
|
64
|
+
if doc.is_a? Hash
|
|
65
|
+
if doc.size == 1 and (tab = doc.to_a[0])[1].is_a? Hash
|
|
66
|
+
internal_create(tab[1], tab[0])
|
|
67
|
+
else
|
|
68
|
+
internal_create(doc)
|
|
69
|
+
end
|
|
70
|
+
elsif doc.is_a? String
|
|
71
|
+
internal_create(:name => doc)
|
|
72
|
+
else
|
|
73
|
+
create(doc)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
else
|
|
77
|
+
raise_error 'bad contents type'
|
|
78
|
+
end
|
|
79
|
+
# Dump the attributes
|
|
80
|
+
attr = @attributes.dup.delete_if do |k,v|
|
|
81
|
+
v.nil? or v.respond_to?(:hidden) or k == :aliases
|
|
82
|
+
end
|
|
83
|
+
unless attr.empty?
|
|
84
|
+
@log.new_node :attributes do
|
|
85
|
+
attr.each { |k, v| @log[k] = v }
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
protected :prologue
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def internal_create ( doc, name=nil )
|
|
93
|
+
doc[:name] ||= name unless name.nil?
|
|
94
|
+
doc[:strategy] ||= strategyclass
|
|
95
|
+
create(doc)
|
|
96
|
+
end
|
|
97
|
+
private :internal_create
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def contents= ( other ) # :nodoc:
|
|
101
|
+
@internal_contents = other
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def attributes(other=nil, &block)
|
|
106
|
+
if other.nil?
|
|
107
|
+
if block.nil?
|
|
108
|
+
@attributes
|
|
109
|
+
else
|
|
110
|
+
self.attributes = HashEval.new(&block).hash
|
|
111
|
+
end
|
|
112
|
+
else
|
|
113
|
+
self.attributes = other
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def attributes=(other) # :nodoc:
|
|
119
|
+
other.each { |k,v| @attributes[k] = v }
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def strategyclass= ( aClass )
|
|
124
|
+
@attributes[:strategy] = aClass
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def strategyclass
|
|
129
|
+
@attributes[:strategy]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def testify_options
|
|
134
|
+
super.update(:strategy => strategyclass)
|
|
135
|
+
end
|
|
136
|
+
protected :testify_options
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def method_missing(key, val=nil, *a) # :nodoc:
|
|
140
|
+
super unless a.empty?
|
|
141
|
+
key = key.to_s
|
|
142
|
+
if key =~ /^(.*)=$/
|
|
143
|
+
@attributes[$1] = val
|
|
144
|
+
else
|
|
145
|
+
@attributes[key]
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
attribute :attributes, 'the common part of the suite', :invisible do
|
|
151
|
+
OHash.new
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
end # class Collection
|
|
155
|
+
|
|
156
|
+
end # module Strategies
|
|
157
|
+
|
|
158
|
+
end # module Uttk
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Author:: Marco Tessari <marco.tessari@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/Compile.rb 22112 2006-02-22T08:30:11.236459Z pouillar $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
module Strategies
|
|
10
|
+
|
|
11
|
+
# I'm not maintained that much since the _Package_ strategy do a better
|
|
12
|
+
# job than I. Can be useful if you have only few files to compile and do
|
|
13
|
+
# not have a Makefile.
|
|
14
|
+
class Compile < Proxy
|
|
15
|
+
include Concrete
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def mk_command
|
|
19
|
+
# Build compiling command
|
|
20
|
+
command = ''
|
|
21
|
+
unless @source_dir.nil?
|
|
22
|
+
@source_dir = Pathname.new(@source_dir)
|
|
23
|
+
@source.map! { |file| @source_dir + file }
|
|
24
|
+
end
|
|
25
|
+
command << @compiler << ' ' << @flags
|
|
26
|
+
@include.each do |dir|
|
|
27
|
+
command << ' -I ' << dir
|
|
28
|
+
end
|
|
29
|
+
command << ' ' << @source.join(' ')
|
|
30
|
+
command << ' -o ' << @bin
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def prologue
|
|
34
|
+
super
|
|
35
|
+
test = create(self, Cmd)
|
|
36
|
+
test.name = 'internal command'
|
|
37
|
+
test.exit = 0
|
|
38
|
+
test.fatal = true
|
|
39
|
+
test.command = mk_command
|
|
40
|
+
|
|
41
|
+
# Configure output
|
|
42
|
+
test.reject :exit
|
|
43
|
+
test.reject :fatal
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
attribute :source, 'source file for the compiler', :mandatory do [] end
|
|
48
|
+
attribute :bin, 'the binary output', :mandatory
|
|
49
|
+
attribute :include, 'include directories' do [] end
|
|
50
|
+
attribute :flags, 'compilation flags',
|
|
51
|
+
'-Wall -W -Werror -ansi -pedantic -O -fomit-frame-pointer'
|
|
52
|
+
attribute :compiler, 'the compiler command', 'gcc'
|
|
53
|
+
attribute :source_dir, 'the source directory, prefix all source file'
|
|
54
|
+
|
|
55
|
+
end # class Compile
|
|
56
|
+
|
|
57
|
+
end # module Strategies
|
|
58
|
+
|
|
59
|
+
end # module Uttk
|
|
@@ -0,0 +1,201 @@
|
|
|
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/Composite.rb 22102 2006-02-21T23:03:39.538964Z pouillar $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
module Strategies
|
|
10
|
+
|
|
11
|
+
# I'm the super class of every strategy class that are composed by other
|
|
12
|
+
# strategies.
|
|
13
|
+
class Composite < Strategy
|
|
14
|
+
include Abstract
|
|
15
|
+
|
|
16
|
+
require 'uttk/strategies/Composite/contents_eval'
|
|
17
|
+
|
|
18
|
+
def initialize ( *a, &b )
|
|
19
|
+
@contents = []
|
|
20
|
+
@status_list = []
|
|
21
|
+
super
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def initialize_copy ( aTest )
|
|
26
|
+
super
|
|
27
|
+
aTest.contents = @contents.dup
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def initialize_test ( aTest )
|
|
32
|
+
aTest.wclass = @wclass
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def create ( anObject, &block )
|
|
37
|
+
res = anObject.testify(new_symtbl.merge!(testify_options)) do |aTest|
|
|
38
|
+
initialize_test(aTest)
|
|
39
|
+
raise "nil symtbl" if aTest.symtbl.nil?
|
|
40
|
+
block[aTest] if block
|
|
41
|
+
end
|
|
42
|
+
@contents << res
|
|
43
|
+
res
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def << ( anObject )
|
|
48
|
+
create(anObject)
|
|
49
|
+
self
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def new_symtbl
|
|
54
|
+
@symtbl.new_child
|
|
55
|
+
end
|
|
56
|
+
protected :new_symtbl
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def testify_options
|
|
60
|
+
{}
|
|
61
|
+
end
|
|
62
|
+
protected :testify_options
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def contents(other=nil, &block)
|
|
66
|
+
if other.nil?
|
|
67
|
+
if block.nil?
|
|
68
|
+
internal_contents
|
|
69
|
+
else
|
|
70
|
+
self.contents = ContentsEval.new(&block).contents
|
|
71
|
+
end
|
|
72
|
+
else
|
|
73
|
+
self.contents = other
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def internal_contents
|
|
79
|
+
@contents
|
|
80
|
+
end
|
|
81
|
+
protected :internal_contents
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def run_impl
|
|
85
|
+
skip if @contents.empty?
|
|
86
|
+
run_composite()
|
|
87
|
+
end
|
|
88
|
+
protected :run_impl
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def compute_final_weight
|
|
92
|
+
return if defined? @final_weight
|
|
93
|
+
@tmp_weight = @wclass.new(:START)
|
|
94
|
+
@status_list.each { |status| @tmp_weight += status.weight }
|
|
95
|
+
@final_weight = @tmp_weight.normalize(@weight)
|
|
96
|
+
end
|
|
97
|
+
private :compute_final_weight
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def assertion
|
|
101
|
+
compute_final_weight
|
|
102
|
+
fail @final_weight, @fatal_failure if defined? @fatal_failure
|
|
103
|
+
skip if @tmp_weight.start?
|
|
104
|
+
pass if @final_weight.pass?
|
|
105
|
+
fail @final_weight
|
|
106
|
+
end
|
|
107
|
+
protected :assertion
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def epilogue
|
|
111
|
+
compute_final_weight
|
|
112
|
+
super
|
|
113
|
+
end
|
|
114
|
+
protected :epilogue
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# Do some tasks before a test of the composite is run.
|
|
118
|
+
def prologue_test ( test, log )
|
|
119
|
+
end
|
|
120
|
+
protected :prologue_test
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
# Do some tasks at the moment where a test of the composite is run.
|
|
124
|
+
def run_impl_test ( test, log )
|
|
125
|
+
test.run(log)
|
|
126
|
+
end
|
|
127
|
+
protected :run_impl_test
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# Do some tasks after a test of the composite has been run.
|
|
131
|
+
def epilogue_test ( test, log )
|
|
132
|
+
st = test.status
|
|
133
|
+
if test.fatal and
|
|
134
|
+
not (st.pass? or (st.is_a? SkipStatus and st.weight.max?))
|
|
135
|
+
@fatal_failure = "Last test was fatal (#{test.name})"
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
protected :epilogue_test
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def run_test ( test, log )
|
|
142
|
+
prologue_test(test, log)
|
|
143
|
+
@status_list << run_impl_test(test, log)
|
|
144
|
+
epilogue_test(test, log)
|
|
145
|
+
end
|
|
146
|
+
protected :run_test
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def run_composite
|
|
150
|
+
@log.new_node :contents, :ordered => true do
|
|
151
|
+
@contents.each do |t|
|
|
152
|
+
if defined? @fatal_failure
|
|
153
|
+
st = FailStatus.new
|
|
154
|
+
st.weight *= t.weight
|
|
155
|
+
@status_list << st
|
|
156
|
+
else
|
|
157
|
+
run_test(t, @log)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
protected :run_composite
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def assign_at_last
|
|
166
|
+
:contents
|
|
167
|
+
end
|
|
168
|
+
protected :assign_at_last
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
attribute :contents, 'an array of tests', :invisible, :dont_expand do
|
|
172
|
+
[]
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
module Ordered
|
|
177
|
+
|
|
178
|
+
def self.included ( aClass )
|
|
179
|
+
|
|
180
|
+
aClass.module_eval do
|
|
181
|
+
|
|
182
|
+
def new_symtbl
|
|
183
|
+
if @contents.empty?
|
|
184
|
+
@symtbl.new_child
|
|
185
|
+
else
|
|
186
|
+
@contents.last.symtbl.new_child
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
protected :new_symtbl
|
|
190
|
+
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
end # module Ordered
|
|
196
|
+
|
|
197
|
+
end # class Composite
|
|
198
|
+
|
|
199
|
+
end # module Strategies
|
|
200
|
+
|
|
201
|
+
end # module Uttk
|
|
@@ -0,0 +1,40 @@
|
|
|
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: /fey/uttk/trunk/lib/uttk/strategies/Composite/contents_eval.rb 8788 2005-09-27T14:23:19.686215Z ertai $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
module Strategies
|
|
10
|
+
|
|
11
|
+
class Composite < Strategy
|
|
12
|
+
|
|
13
|
+
class ContentsEval
|
|
14
|
+
|
|
15
|
+
def initialize(contents=[], &block)
|
|
16
|
+
@contents = contents
|
|
17
|
+
if block
|
|
18
|
+
if block.arity == -1
|
|
19
|
+
instance_eval(&block)
|
|
20
|
+
else
|
|
21
|
+
block[self]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
attr_reader :contents
|
|
27
|
+
|
|
28
|
+
def name(item_name, &block)
|
|
29
|
+
contents << { item_name.to_s => HashEval.new(&block).hash }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end # class ContentsEval
|
|
33
|
+
|
|
34
|
+
end # class Composite
|
|
35
|
+
|
|
36
|
+
end # module Strategies
|
|
37
|
+
|
|
38
|
+
end # module Uttk
|
|
39
|
+
|
|
40
|
+
|