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.
Files changed (276) hide show
  1. data/AUTHORS +36 -0
  2. data/COPYING +18 -0
  3. data/ChangeLog +7673 -0
  4. data/GUIDELINES +86 -0
  5. data/LGPL +504 -0
  6. data/NEWS +158 -0
  7. data/NORM +137 -0
  8. data/README +180 -0
  9. data/Rakefile +8 -0
  10. data/SPEC.gemspec +15 -0
  11. data/SPEC.yml +60 -0
  12. data/TODO +23 -0
  13. data/TODO.old +31 -0
  14. data/VERSION +5 -0
  15. data/bin/getopts/uttk.rb +390 -0
  16. data/bin/uttk +188 -0
  17. data/bin/uttk-unit +125 -0
  18. data/lib/uttk.rb +288 -0
  19. data/lib/uttk/dumpers/Basic.rb +23 -0
  20. data/lib/uttk/dumpers/BasicColor.rb +35 -0
  21. data/lib/uttk/dumpers/Dumper.rb +77 -0
  22. data/lib/uttk/dumpers/Html.rb +271 -0
  23. data/lib/uttk/dumpers/Path.rb +24 -0
  24. data/lib/uttk/dumpers/Xml.rb +88 -0
  25. data/lib/uttk/dumpers/Yaml.rb +138 -0
  26. data/lib/uttk/filters.rb +128 -0
  27. data/lib/uttk/filters/Buffer.rb +119 -0
  28. data/lib/uttk/filters/Compact.rb +75 -0
  29. data/lib/uttk/filters/Default.rb +27 -0
  30. data/lib/uttk/filters/DefaultColor.rb +27 -0
  31. data/lib/uttk/filters/Filter.rb +53 -0
  32. data/lib/uttk/filters/Id.rb +30 -0
  33. data/lib/uttk/filters/JustStatus.rb +25 -0
  34. data/lib/uttk/filters/KeepSkipBased.rb +38 -0
  35. data/lib/uttk/filters/NodeCut.rb +97 -0
  36. data/lib/uttk/filters/RPathFilter.rb +134 -0
  37. data/lib/uttk/filters/Saver.rb +53 -0
  38. data/lib/uttk/filters/TextFilter.rb +69 -0
  39. data/lib/uttk/generators/dumper_generator.rb +28 -0
  40. data/lib/uttk/generators/filter_generator.rb +28 -0
  41. data/lib/uttk/generators/generator.rb +86 -0
  42. data/lib/uttk/generators/generator_generator.rb +26 -0
  43. data/lib/uttk/generators/loader_generator.rb +28 -0
  44. data/lib/uttk/generators/path_filter_generator.rb +28 -0
  45. data/lib/uttk/generators/strategy_generator.rb +28 -0
  46. data/lib/uttk/generators/templates/dumper.rb +50 -0
  47. data/lib/uttk/generators/templates/filter.rb +50 -0
  48. data/lib/uttk/generators/templates/generator.rb +28 -0
  49. data/lib/uttk/generators/templates/loader.rb +26 -0
  50. data/lib/uttk/generators/templates/path_filter.rb +28 -0
  51. data/lib/uttk/generators/templates/strategy.rb +59 -0
  52. data/lib/uttk/generators/templates/strategy.yml +28 -0
  53. data/lib/uttk/generators/templates/unit_test.rb +46 -0
  54. data/lib/uttk/loaders/Loader.rb +180 -0
  55. data/lib/uttk/loaders/Ruby.rb +28 -0
  56. data/lib/uttk/loaders/Yaml.rb +98 -0
  57. data/lib/uttk/logger.rb +306 -0
  58. data/lib/uttk/logger/backend.rb +170 -0
  59. data/lib/uttk/logger/path.rb +202 -0
  60. data/lib/uttk/logger/section_node.rb +214 -0
  61. data/lib/uttk/logger/severity.rb +63 -0
  62. data/lib/uttk/logger/to_uttk_log.rb +127 -0
  63. data/lib/uttk/logger/verbosity.rb +61 -0
  64. data/lib/uttk/logger_factory.rb +55 -0
  65. data/lib/uttk/path_filters/ColorStatus.rb +57 -0
  66. data/lib/uttk/path_filters/PathFilter.rb +27 -0
  67. data/lib/uttk/path_filters/RemoveTypes.rb +25 -0
  68. data/lib/uttk/status.rb +146 -0
  69. data/lib/uttk/strategies/Abort.rb +24 -0
  70. data/lib/uttk/strategies/Assert.rb +44 -0
  71. data/lib/uttk/strategies/Authors.rb +45 -0
  72. data/lib/uttk/strategies/Block.rb +113 -0
  73. data/lib/uttk/strategies/Bootstrap.rb +55 -0
  74. data/lib/uttk/strategies/Checkout.rb +64 -0
  75. data/lib/uttk/strategies/Clean.rb +29 -0
  76. data/lib/uttk/strategies/Cmd.rb +60 -0
  77. data/lib/uttk/strategies/CmdBase.rb +130 -0
  78. data/lib/uttk/strategies/Collection.rb +158 -0
  79. data/lib/uttk/strategies/Compile.rb +59 -0
  80. data/lib/uttk/strategies/Composite.rb +201 -0
  81. data/lib/uttk/strategies/Composite/contents_eval.rb +40 -0
  82. data/lib/uttk/strategies/Configure.rb +66 -0
  83. data/lib/uttk/strategies/Error.rb +23 -0
  84. data/lib/uttk/strategies/Fail.rb +26 -0
  85. data/lib/uttk/strategies/IOBased.rb +159 -0
  86. data/lib/uttk/strategies/Import.rb +60 -0
  87. data/lib/uttk/strategies/Iterate.rb +139 -0
  88. data/lib/uttk/strategies/JUnit.rb +205 -0
  89. data/lib/uttk/strategies/KillAll.rb +62 -0
  90. data/lib/uttk/strategies/Make.rb +94 -0
  91. data/lib/uttk/strategies/Package.rb +129 -0
  92. data/lib/uttk/strategies/PackageCollection.rb +78 -0
  93. data/lib/uttk/strategies/Pass.rb +24 -0
  94. data/lib/uttk/strategies/Pool.rb +104 -0
  95. data/lib/uttk/strategies/ProbabilityThreshold.rb +46 -0
  96. data/lib/uttk/strategies/Proxy.rb +42 -0
  97. data/lib/uttk/strategies/RMatch.rb +92 -0
  98. data/lib/uttk/strategies/RUnit.rb +132 -0
  99. data/lib/uttk/strategies/SignalCmd.rb +85 -0
  100. data/lib/uttk/strategies/Sleep.rb +36 -0
  101. data/lib/uttk/strategies/SqlQuery.rb +120 -0
  102. data/lib/uttk/strategies/Strategy.rb +683 -0
  103. data/lib/uttk/strategies/Stub.rb +37 -0
  104. data/lib/uttk/strategies/SubCmd.rb +77 -0
  105. data/lib/uttk/strategies/Suite.rb +71 -0
  106. data/lib/uttk/strategies/Test.rb +89 -0
  107. data/lib/uttk/streams.rb +69 -0
  108. data/lib/uttk/streams/Diff.rb +60 -0
  109. data/lib/uttk/streams/HexaDiff.rb +35 -0
  110. data/lib/uttk/streams/Stream.rb +76 -0
  111. data/lib/uttk/weights.rb +17 -0
  112. data/lib/uttk/weights/WExpr.rb +68 -0
  113. data/lib/uttk/weights/WFloat.rb +23 -0
  114. data/lib/uttk/weights/WMin.rb +22 -0
  115. data/lib/uttk/weights/Weight.rb +105 -0
  116. data/lib/www/javascripts/uttk.js +185 -0
  117. data/misc/expandtab.rb +29 -0
  118. data/misc/header.rb +44 -0
  119. data/misc/renaming +57 -0
  120. data/misc/textile_compiler +194 -0
  121. data/misc/uttk-grep.sh +8 -0
  122. data/misc/uttk-line-count.rb +143 -0
  123. data/test/examples-suite.yml +8 -0
  124. data/test/examples/README +68 -0
  125. data/test/examples/basic.rb +10 -0
  126. data/test/examples/basic.yml +9 -0
  127. data/test/examples/cache/cache_and_fatal.yml +5 -0
  128. data/test/examples/cache/simple.yml +30 -0
  129. data/test/examples/sql/basic.yml +24 -0
  130. data/test/examples/students-suite.yml +9 -0
  131. data/test/examples/students/ball.yml +11 -0
  132. data/test/examples/students/glob_stud.yml +20 -0
  133. data/test/examples/students/mini-lib.yml +61 -0
  134. data/test/examples/students/pool_stud.yml +31 -0
  135. data/test/examples/students/stud.yml +21 -0
  136. data/test/fixtures/ball/20040804-exam_a1-zapngo-tessar_m.tar.gz +0 -0
  137. data/test/fixtures/ball/Makefile +24 -0
  138. data/test/fixtures/ball/bar_p-mini-lib.tar.bz2 +0 -0
  139. data/test/fixtures/ball/bar_p-mini-lib/Makefile +20 -0
  140. data/test/fixtures/ball/bar_p-mini-lib/my_strlen.c +13 -0
  141. data/test/fixtures/ball/foo_s-mini-lib.tar.bz2 +0 -0
  142. data/test/fixtures/ball/foo_s-mini-lib/Makefile +20 -0
  143. data/test/fixtures/ball/foo_s-mini-lib/configure +2 -0
  144. data/test/fixtures/ball/foo_s-mini-lib/my_strlen.c +10 -0
  145. data/test/fixtures/ball/hello.tar.bz2 +0 -0
  146. data/test/fixtures/ball/hello.tar.gz +0 -0
  147. data/test/fixtures/ball/hello/Makefile +14 -0
  148. data/test/fixtures/ball/hello/hello.c +7 -0
  149. data/test/fixtures/ball/jack-exit.tar.bz2 +0 -0
  150. data/test/fixtures/ball/jack-exit/Makefile +14 -0
  151. data/test/fixtures/ball/jack-exit/exit.c +16 -0
  152. data/test/fixtures/ball/joe-exit.tar.bz2 +0 -0
  153. data/test/fixtures/ball/joe-exit/Makefile +14 -0
  154. data/test/fixtures/ball/joe-exit/exit.c +8 -0
  155. data/test/fixtures/ball/joe_i-mini-lib.tar.bz2 +0 -0
  156. data/test/fixtures/ball/joe_i-mini-lib/Makefile +20 -0
  157. data/test/fixtures/ball/joe_i-mini-lib/configure +2 -0
  158. data/test/fixtures/ball/joe_i-mini-lib/my_strlen.c +10 -0
  159. data/test/fixtures/ball/john-exit.tar.bz2 +0 -0
  160. data/test/fixtures/ball/john-exit/Makefile +14 -0
  161. data/test/fixtures/ball/john-exit/exit.c +6 -0
  162. data/test/fixtures/ball/qux_j-mini-lib.tar.bz2 +0 -0
  163. data/test/fixtures/ball/qux_j-mini-lib/Makefile +20 -0
  164. data/test/fixtures/ball/qux_j-mini-lib/my_strlen.c +12 -0
  165. data/test/fixtures/binaries/segv +0 -0
  166. data/test/fixtures/binaries/segv.c +10 -0
  167. data/test/fixtures/binaries/segv.rb +2 -0
  168. data/test/fixtures/demo/command-tutorial/steps/1/check.yml +5 -0
  169. data/test/fixtures/demo/command-tutorial/steps/1/pluralizer.rb +10 -0
  170. data/test/fixtures/demo/command-tutorial/steps/2/bad_check.yml +7 -0
  171. data/test/fixtures/demo/command-tutorial/steps/2/check.yml +7 -0
  172. data/test/fixtures/demo/command-tutorial/steps/2/pluralizer.rb +10 -0
  173. data/test/fixtures/demo/command-tutorial/steps/3.1/check.yml +12 -0
  174. data/test/fixtures/demo/command-tutorial/steps/3/check.yml +14 -0
  175. data/test/fixtures/demo/command-tutorial/steps/4.1/bird.txt +1 -0
  176. data/test/fixtures/demo/command-tutorial/steps/4.1/check.yml +12 -0
  177. data/test/fixtures/demo/command-tutorial/steps/4/check.yml +12 -0
  178. data/test/fixtures/demo/command-tutorial/steps/4/pluralizer.rb +12 -0
  179. data/test/fixtures/demo/command-tutorial/steps/5.1/bird.txt +1 -0
  180. data/test/fixtures/demo/command-tutorial/steps/5.1/check.yml +17 -0
  181. data/test/fixtures/demo/command-tutorial/steps/5.1/pluralizer.rb +17 -0
  182. data/test/fixtures/demo/command-tutorial/steps/5/bird.txt +1 -0
  183. data/test/fixtures/demo/command-tutorial/steps/5/check.yml +16 -0
  184. data/test/fixtures/demo/command-tutorial/steps/5/pluralizer.rb +16 -0
  185. data/test/fixtures/demo/command-tutorial/steps/6.1/bird.txt +1 -0
  186. data/test/fixtures/demo/command-tutorial/steps/6.1/check.yml +22 -0
  187. data/test/fixtures/demo/command-tutorial/steps/6.1/pluralizer.rb +17 -0
  188. data/test/fixtures/demo/command-tutorial/steps/6/bird.txt +1 -0
  189. data/test/fixtures/demo/command-tutorial/steps/6/check.yml +21 -0
  190. data/test/fixtures/demo/command-tutorial/steps/6/pluralizer.rb +17 -0
  191. data/test/fixtures/demo/command-tutorial/steps/7/bird.txt +1 -0
  192. data/test/fixtures/demo/command-tutorial/steps/7/check.yml +22 -0
  193. data/test/fixtures/demo/command-tutorial/steps/7/pluralizer.rb +17 -0
  194. data/test/fixtures/demo/filter-tutorial/check.yml +20 -0
  195. data/test/fixtures/demo/filter-tutorial/filters/CutSkip100.rb +19 -0
  196. data/test/fixtures/demo/filter-tutorial/pluralizer.rb +17 -0
  197. data/test/fixtures/java/unit/MultiRight/Foo/Foo.java +11 -0
  198. data/test/fixtures/java/unit/MultiRight/Foo/FooTest.java +15 -0
  199. data/test/fixtures/java/unit/MultiRight/MultiRight.java +13 -0
  200. data/test/fixtures/java/unit/MultiRight/MultiRightTest.java +12 -0
  201. data/test/fixtures/java/unit/MultiRight/bar/Bar.java +11 -0
  202. data/test/fixtures/java/unit/MultiRight/bar/BarTest.java +21 -0
  203. data/test/fixtures/java/unit/MultiRight/build.sh +7 -0
  204. data/test/fixtures/java/unit/SimpleException/SimpleExceptionTest.java +11 -0
  205. data/test/fixtures/java/unit/SimpleException/build.sh +4 -0
  206. data/test/fixtures/java/unit/build.sh +9 -0
  207. data/test/fixtures/java/unit/multibar.yml +6 -0
  208. data/test/fixtures/java/unit/multifoo.yml +6 -0
  209. data/test/fixtures/java/unit/multiright.yml +8 -0
  210. data/test/fixtures/java/unit/simple_exception.yml +6 -0
  211. data/test/fixtures/mini-lib/Makefile +9 -0
  212. data/test/fixtures/mini-lib/strlen.c +15 -0
  213. data/test/fixtures/package/pkg_foo.tar.gz +0 -0
  214. data/test/fixtures/package/pkg_foo/Makefile +20 -0
  215. data/test/fixtures/package/pkg_foo/bootstrap +3 -0
  216. data/test/fixtures/package/pkg_foo/configure +3 -0
  217. data/test/fixtures/package/pkg_foo/foo.sh +2 -0
  218. data/test/fixtures/text/1.txt +4 -0
  219. data/test/fixtures/unit/bad.rb +26 -0
  220. data/test/fixtures/unit/error.rb +6 -0
  221. data/test/fixtures/unit/good.rb +26 -0
  222. data/test/functional-suite.yml +10 -0
  223. data/test/functional/author.yml +11 -0
  224. data/test/functional/base.yml +119 -0
  225. data/test/functional/base_pool.yml +13 -0
  226. data/test/functional/block.yml +13 -0
  227. data/test/functional/cat.yml +16 -0
  228. data/test/functional/cmd.yml +17 -0
  229. data/test/functional/diff.yml +27 -0
  230. data/test/functional/env_cmd.yml +53 -0
  231. data/test/functional/exit.yml +15 -0
  232. data/test/functional/fatal.yml +23 -0
  233. data/test/functional/glob.yml +11 -0
  234. data/test/functional/hexa-diff.yml +25 -0
  235. data/test/functional/import.yml +41 -0
  236. data/test/functional/iterate.yml +99 -0
  237. data/test/functional/killall.yml +31 -0
  238. data/test/functional/pkg.yml +14 -0
  239. data/test/functional/probability_threshold.yml +35 -0
  240. data/test/functional/r_unit.yml +26 -0
  241. data/test/functional/rmatch.yml +122 -0
  242. data/test/functional/signal_cmd.yml +22 -0
  243. data/test/functional/sub.yml +15 -0
  244. data/test/functional/test.yml +25 -0
  245. data/test/functional/timeout.yml +20 -0
  246. data/test/functional/wc.yml +26 -0
  247. data/test/functional/weight.yml +152 -0
  248. data/test/pkg-suite.yml +8 -0
  249. data/test/pkg/cmdline.yml +80 -0
  250. data/test/pool-suite.yml +8 -0
  251. data/test/pool/base.yml +12 -0
  252. data/test/pool/pool.yml +25 -0
  253. data/test/ruby-suite.rb +10 -0
  254. data/test/ruby-suite.yml +5 -0
  255. data/test/ruby/base.rb +119 -0
  256. data/test/ruby/iterate.rb +21 -0
  257. data/test/ruby/wc.rb +43 -0
  258. data/test/unit-suite.yml +10 -0
  259. data/test/unit/dumpers/path_test.rb +46 -0
  260. data/test/unit/dumpers/xml_test.rb +65 -0
  261. data/test/unit/dumpers/yaml_test.rb +65 -0
  262. data/test/unit/filters/buffer_test.rb +168 -0
  263. data/test/unit/filters/keep_skip_based_test.rb +46 -0
  264. data/test/unit/filters/node_cut_test.rb +72 -0
  265. data/test/unit/filters/rpath_filter_test.rb +191 -0
  266. data/test/unit/filters/text_filter_test.rb +46 -0
  267. data/test/unit/filters_test.rb +119 -0
  268. data/test/unit/logger/section_node_test.rb +120 -0
  269. data/test/unit/logger/severity_test.rb +37 -0
  270. data/test/unit/logger/to_uttk_log_test.rb +113 -0
  271. data/test/unit/logger/verbosity_test.rb +44 -0
  272. data/test/unit/logger_test.rb +203 -0
  273. data/test/unit/strategies/suite_test.rb +151 -0
  274. data/test/uttk-check.yml +8 -0
  275. data/test/uttk-distcheck.yml +18 -0
  276. metadata +399 -0
@@ -0,0 +1,66 @@
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/Configure.rb 22112 2006-02-22T08:30:11.236459Z pouillar $
5
+
6
+
7
+ module Uttk
8
+
9
+ module Strategies
10
+
11
+ # I run then check whether the configure stage of a compilation process fail.
12
+ # I used in the _Package_ strategy to handle the configuration stage.
13
+ class Configure < Proxy
14
+ include Concrete
15
+
16
+ CONFIGURE = /^configure(\.sh)?$/
17
+ CONFIGURE_INPUT = /^configure\.(ac|in)$/
18
+
19
+ def mk_command ( script )
20
+ cmd = script.to_s
21
+ cmd += " --prefix=#@prefix" if @prefix
22
+ if @flags.is_a? Array
23
+ @flags = @flags.join(' ')
24
+ else
25
+ @flags = @flags.to_s
26
+ end
27
+ symtbl_configure_flags = @symtbl[:configure_flags]
28
+ @flags += ' ' + symtbl_configure_flags unless symtbl_configure_flags.nil?
29
+ @symtbl[:configure_flags] = @flags
30
+ cmd + ' ' + @flags
31
+ end
32
+
33
+ def prologue
34
+ super
35
+ @dir = Pathname.new(@dir)
36
+ if script = self.class.have_configure?(@dir)
37
+ create(Cmd) do |test|
38
+ test.name = 'command'
39
+ test.exit = 0
40
+ test.dir = @dir
41
+ test.command = mk_command(script)
42
+ test.verbose_print = true
43
+ test.reject :strategy, :dir
44
+ end
45
+ end
46
+ end
47
+
48
+ def self.have_configure_input? ( dir=Pathname.new('.') )
49
+ res = dir.entries.find { |ent| ent.to_s =~ CONFIGURE_INPUT }
50
+ (res.nil?) ? nil : dir + res
51
+ end
52
+
53
+ def self.have_configure? ( dir=Pathname.new('.') )
54
+ res = dir.entries.find { |ent| ent.to_s =~ CONFIGURE }
55
+ (res.nil?) ? nil : dir + res
56
+ end
57
+
58
+ attribute :dir, 'configure directory', :mandatory
59
+ attribute :prefix, 'the prefix directory for --prefix'
60
+ attribute :flags, 'set flags for the configure script'
61
+
62
+ end # class Configure
63
+
64
+ end # module Strategies
65
+
66
+ end # module Uttk
@@ -0,0 +1,23 @@
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/Error.rb 8778 2005-09-26T04:34:48.103938Z ertai $
5
+
6
+
7
+ module Uttk
8
+
9
+ module Strategies
10
+
11
+ # A test class which always raise an error.
12
+ class Error < Strategy
13
+ include Concrete
14
+
15
+ def assertion
16
+ raise_error('Error always raises an error')
17
+ end
18
+
19
+ end # class Error
20
+
21
+ end # module Strategies
22
+
23
+ end # module Uttk
@@ -0,0 +1,26 @@
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/Fail.rb 8778 2005-09-26T04:34:48.103938Z ertai $
5
+
6
+
7
+ module Uttk
8
+
9
+ module Strategies
10
+
11
+ # A test class which always fails.
12
+ class Fail < Strategy
13
+ include Concrete
14
+
15
+ protected
16
+ def assertion
17
+ fail 'Fail always fails', Weights::Default.new(@value)
18
+ end
19
+
20
+ attribute :value, 'the returned weight', [Weights::Weight, Numeric], 0
21
+
22
+ end # class Fail
23
+
24
+ end # module Strategies
25
+
26
+ end # module Uttk
@@ -0,0 +1,159 @@
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/IOBased.rb 21844 2006-02-17T17:26:59.771162Z pouillar $
5
+
6
+ module Uttk
7
+
8
+ module Strategies
9
+
10
+ class IOBased < Strategy
11
+ include Abstract
12
+
13
+
14
+ #
15
+ # Constructor
16
+ #
17
+
18
+ def initialize ( *a, &b )
19
+ stream :input
20
+ stream :output
21
+ stream :error
22
+ super
23
+ end
24
+
25
+
26
+ #
27
+ # Methods
28
+ #
29
+
30
+ def prologue
31
+ super
32
+ make_streams
33
+ unless @input.nil?
34
+ if @input.ref.is_a? Pathname
35
+ @input.my = @input.ref
36
+ else
37
+ @input.my.open('w') do |my|
38
+ my.print @input.ref.to_s_for_uttk_log
39
+ end
40
+ end
41
+ end
42
+ end
43
+ protected :prologue
44
+
45
+
46
+ def assertion
47
+ @streams.each do |stream|
48
+ next if invalid_stream?(stream)
49
+ fail("#{stream.name} is different") unless stream.compare_streams
50
+ end
51
+ pass
52
+ end
53
+ protected :assertion
54
+
55
+
56
+ def epilogue
57
+ @streams.each { |strm| strm.clean unless strm.nil? }
58
+ super
59
+ end
60
+ protected :epilogue
61
+
62
+
63
+ def pass_hook
64
+ super
65
+ print_streams() if @verbose_print
66
+ end
67
+ protected :pass_hook
68
+
69
+
70
+ def failed_hook
71
+ super
72
+ @streams.each do |stream|
73
+ next if invalid_stream?(stream)
74
+ @log["#{stream.name}_status"] = stream.status
75
+ end
76
+ print_streams() unless @quiet_print
77
+ end
78
+ protected :failed_hook
79
+
80
+
81
+ def print_streams
82
+ @streams.each do |stream|
83
+ next if invalid_stream?(stream)
84
+ @log << stream
85
+ end
86
+ end
87
+ private :print_streams
88
+
89
+
90
+ def invalid_stream? ( stream )
91
+ stream.nil? or stream.ref.nil? or
92
+ stream.my.nil? or stream.name == 'input' or
93
+ (stream.my.is_a? Pathname and !stream.my.exist?) or
94
+ (stream.ref.is_a? Pathname and !stream.ref.exist?)
95
+ end
96
+ private :invalid_stream?
97
+
98
+ def stream ( name )
99
+ @streams ||= []
100
+ @streams_name ||= []
101
+ @streams_name << name
102
+ end
103
+
104
+
105
+ def make_streams
106
+ @streams = @streams_name.map do |name|
107
+ stream = nil
108
+ if instance_variables.include? "@#{name}"
109
+ val = instance_variable_get("@#{name}")
110
+ if val.nil?
111
+ stream = @stream_class.new(name)
112
+ else
113
+ val = val.do_symtbl_gsub(@symtbl)
114
+ if val.is_a? String
115
+ tmp = TempPath.new
116
+ tmp.open('w') { |res| res.print val }
117
+ val = tmp.open('r')
118
+ end
119
+ stream = @stream_class.new(name, val)
120
+ end
121
+ end
122
+ instance_variable_set "@#{name}", stream
123
+ stream
124
+ end
125
+ end
126
+ protected :make_streams
127
+
128
+ #
129
+ # Accessors
130
+ #
131
+
132
+ def stream_class= ( aClass )
133
+ if aClass.is_a? Class
134
+ @stream_class = aClass
135
+ else
136
+ @stream_class = Streams.const_get(aClass)
137
+ end
138
+ end
139
+
140
+
141
+ #
142
+ # Attributes
143
+ #
144
+
145
+ attribute :input, 'the input reference', :invisible, nil
146
+ attribute :output, 'the output reference', :invisible, nil
147
+ attribute :error, 'the error reference', :invisible, nil
148
+
149
+ attribute :stream_class, 'the stream class (< Streams::Stream)',
150
+ Class, Streams::Stream
151
+
152
+ attribute :verbose_print, 'print even if the test pass', false, :invisible
153
+ attribute :quiet_print, 'quiet even if the test fails', false, :invisible
154
+
155
+ end # class IOBased
156
+
157
+ end # module Strategies
158
+
159
+ end # module Uttk
@@ -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: /w/fey/uttk/trunk/lib/uttk/strategies/Import.rb 22102 2006-02-21T23:03:39.538964Z pouillar $
5
+
6
+
7
+ module Uttk
8
+
9
+ module Strategies
10
+
11
+ # I can import a strategy from on another file. Just tell me which file
12
+ # using my _import_ attribute and which loader to use using my _loader_
13
+ # attribute.
14
+ class Import < Proxy
15
+ include Concrete
16
+
17
+ def prologue
18
+ super
19
+ unless @import.exist?
20
+ raise ArgumentError, "the import file must exits (#@import)"
21
+ end
22
+ unless @loader.nil?
23
+ @save_loader = @symtbl[:loader]
24
+ @symtbl[:loader] = @loader
25
+ end
26
+ @old_pwd = @symtbl[:pwd]
27
+ create(@import) do |t|
28
+ t.symtbl[:loader] = @symtbl[:loader]
29
+ end
30
+ end
31
+ protected :prologue
32
+
33
+ def epilogue
34
+ @symtbl[:loader] = @save_loader unless @loader.nil?
35
+ @symtbl[:pwd] = @old_pwd
36
+ super
37
+ end
38
+ protected :epilogue
39
+
40
+ def import= ( aPath )
41
+ @import = aPath
42
+ @import = Pathname.new(aPath) unless aPath.is_a? Pathname
43
+ end
44
+
45
+ def loader= ( aLoader )
46
+ if aLoader.is_a? Loaders::Loader
47
+ @loader = aLoader
48
+ else
49
+ @loader = Loaders.const_get(aLoader).new
50
+ end
51
+ end
52
+
53
+ attribute :import, 'the file to import', :mandatory
54
+ attribute :loader, 'loader to use for the imported file'
55
+
56
+ end # class Import
57
+
58
+ end # module Strategies
59
+
60
+ end # module Uttk
@@ -0,0 +1,139 @@
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/strategies/Iterate.rb 8813 2005-10-12T08:41:50.904292Z ertai $
5
+
6
+
7
+ module Uttk
8
+
9
+ module Strategies
10
+
11
+ # _Iterate_ is a generic iteration strategy which bring the full power of
12
+ # Ruby to your test description.
13
+ #
14
+ # The common use case is somthing like that:
15
+ #
16
+ # my test:
17
+ # strategy: Iterate
18
+ # over: aStructureWichSupportTheMethodMyEach
19
+ # with: TheMethodMyEach # `uttk_each' by default
20
+ # iter: MyIterator
21
+ # test:
22
+ # my sub test <<MyIterator:i>>:
23
+ # strategy: AnotherStrategy
24
+ # argument: <<MyIterator>>
25
+ #
26
+ # In the real life you can use it like that:
27
+ #
28
+ # my test suite:
29
+ # strategy: Iterator
30
+ # over: !filelist **/(*).yml
31
+ # iter: [path, basename]
32
+ # test:
33
+ # my sub test <<basename>>:
34
+ # strategy: Import
35
+ # input: <<path>>
36
+ #
37
+ class Iterate < Collection
38
+ include Concrete
39
+ include Composite::Ordered
40
+
41
+ alias_method :make_new_symtbl, :new_symtbl
42
+ attr_reader :new_symtbl, :iterators
43
+ protected :new_symtbl, :iterators
44
+
45
+
46
+ #
47
+ # Methods
48
+ #
49
+
50
+ def prologue
51
+ super
52
+
53
+ if @test.is_a? Hash and @test.size == 1
54
+ name, @attributes = @test.to_a.first
55
+ @attributes[:name] = name
56
+ @test = {}
57
+ else
58
+ name = @test.name
59
+ end
60
+
61
+ iter1 = iterators.first
62
+ iteri = "#{iter1}:i"
63
+ iterstar = "*#{iter1}"
64
+ unless name.to_s =~ /<<.*>>/
65
+ raise ArgumentError,
66
+ "You cannot provide a static name like (#{name}) because when " +
67
+ 'iterating with this name all your tests will have the same ' +
68
+ "name, to avoid this you can add <<#{iteri}>> to your name"
69
+ end
70
+
71
+
72
+ # Iterate over the object `@over' with the method `@with'.
73
+ turn = 0
74
+ @over.send(@with) do |*args|
75
+ symtbl = make_new_symtbl
76
+ symtbl[iteri] = turn
77
+ symtbl[iterstar] = args
78
+ args.each_with_index do |arg, i|
79
+ symtbl["#{iter1}:#{i}"] = arg
80
+ symtbl["#{iterators[i]}"] = arg if i < iterators.size
81
+ end
82
+ @new_symtbl = symtbl
83
+ create @test
84
+ turn += 1
85
+ end
86
+
87
+ end
88
+ protected :prologue
89
+
90
+
91
+ def iter= ( iter )
92
+ @iter = iter
93
+ iter = iter.to_s if iter.is_a? Symbol
94
+ @iterators = case iter
95
+ when Array then iter.flatten
96
+ when /^\[.*\]$/ then eval iter
97
+ when /,/ then iter.split(/\s*,\s*/)
98
+ else [iter]
99
+ end
100
+ unless iterators.all? { |it| it.is_a? String }
101
+ raise ArgumentError, 'The iterator name or list of names ' +
102
+ "must be strings not (#{iterators.inspect})"
103
+ end
104
+ end
105
+
106
+
107
+ #
108
+ # Attributes
109
+ #
110
+
111
+ attribute :over, 'iterate *over* this object', :mandatory
112
+ attribute :with, 'iterate *with* this method', :uttk_each
113
+ attribute :iter, 'iterator name or list of names', :mandatory
114
+ attribute :test, 'the test to run at each time',
115
+ :mandatory, :invisible, :dont_expand
116
+
117
+ end # class Iterate
118
+
119
+ end # module Strategies
120
+
121
+ end # module Uttk
122
+
123
+
124
+ class Object
125
+
126
+ def uttk_each ( *a, &b )
127
+ each(*a, &b)
128
+ end
129
+
130
+ end # class Object
131
+
132
+
133
+ class Hash
134
+
135
+ def uttk_each ( *a, &b )
136
+ each(*a) { |k, v| b[k, v] }
137
+ end
138
+
139
+ end # class Hash