uttk 0.3.1.2

Sign up to get free protection for your applications and to get access to all the features.
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,72 @@
1
+ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
2
+ # Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
3
+ # License:: LGPL
4
+ # Revision:: $Id: /w/fey/uttk/trunk/test/unit/filters/node_cut_test.rb 21844 2006-02-17T17:26:59.771162Z pouillar $
5
+
6
+ test_section __FILE__ do
7
+
8
+ module Uttk
9
+
10
+ module Filters
11
+
12
+ class NodeCutTest < ::Test::Unit::TestCase
13
+ include Mocks::Assertions
14
+ include NodeCut::Assertions
15
+
16
+ @@output_string = "
17
+ |root:
18
+ | contents:
19
+ | - Test1:
20
+ | status: PASS
21
+ | - Test2:
22
+ | status: FAIL
23
+ | status: FAIL(50%)
24
+ ".head_cut!
25
+
26
+ @@output_tree = YAML.load(@@output_string)
27
+
28
+ @@original =
29
+ [[[:root, [:contents, {:ordered=>true}], :Test1, :status], "PASS"],
30
+ [[:root, [:contents, {:ordered=>true}], :Test2, :status], "FAIL"],
31
+ [[:root, :status], "FAIL(50%)"]]
32
+
33
+ @@without_contents =
34
+ [[[:root, :Test1, :status], "PASS"],
35
+ [[:root, :Test2, :status], "FAIL"],
36
+ [[:root, :status], "FAIL(50%)"]]
37
+
38
+ @@without_test1_prune =
39
+ [[[:root, [:contents, {:ordered=>true}], :Test2, :status], "FAIL"],
40
+ [[:root, :status], "FAIL(50%)"]]
41
+
42
+ #
43
+ # Methods
44
+ #
45
+
46
+ def setup
47
+ super
48
+ @mock_object = Mocks::Observer.new
49
+ end
50
+
51
+ def teardown
52
+ end
53
+
54
+ #
55
+ # Tests
56
+ #
57
+
58
+ def test_without_contents
59
+ assert_node_cut @@original, @@without_contents, :skip => %r{contents}
60
+ end
61
+
62
+ def test_without_test1_prune
63
+ assert_node_cut @@original, @@without_test1_prune, :skip => %r{Test1}, :prune => true
64
+ end
65
+
66
+ end # class NodeCutTest
67
+
68
+ end # module Filters
69
+
70
+ end # module Uttk
71
+
72
+ end
@@ -0,0 +1,191 @@
1
+ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
2
+ # Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
3
+ # License:: LGPL
4
+ # Revision:: $Id: /w/fey/uttk/trunk/test/unit/filters/rpath_filter_test.rb 22089 2006-02-21T16:03:00.498332Z pouillar $
5
+
6
+
7
+ test_section __FILE__ do
8
+
9
+ module Uttk
10
+
11
+ module Filters
12
+
13
+ class RPathFilterTest < ::Test::Unit::TestCase
14
+ include Mocks::Assertions
15
+ include RPathFilter::Assertions
16
+
17
+ #
18
+ # Data
19
+ #
20
+
21
+ @@output_string = "
22
+ |root:
23
+ | strategy: Suite
24
+ | contents:
25
+ | - noname:
26
+ | strategy: Suite
27
+ | contents:
28
+ | - Test login=joe:
29
+ | strategy: Pass
30
+ | status: PASS
31
+ | - Test login=bar:
32
+ | strategy: Pass
33
+ | status: PASS
34
+ | - Test login=foo:
35
+ | strategy: Fail
36
+ | status: FAIL
37
+ | reason: Fail always fails
38
+ | - Test login=yo:
39
+ | strategy: Abort
40
+ | status: ABORT
41
+ | reason: Abort strategy always aborts
42
+ | - Test login=yeah:
43
+ | strategy: Fail
44
+ | status: FAIL
45
+ | reason: Fail always fails
46
+ | status: FAIL(40%)
47
+ | status: FAIL(40%)
48
+ ".head_cut!
49
+
50
+ @@output_tree = YAML.load(@@output_string)
51
+
52
+ #
53
+ # Methods
54
+ #
55
+
56
+ def setup
57
+ super
58
+ self.logger = Logger.new
59
+ self.output_tree = @@output_tree
60
+ self.mock_object = Mocks::Observer.new
61
+ end
62
+
63
+ def teardown
64
+ super
65
+ # ...
66
+ end
67
+
68
+ class TestFilter1 < RPathFilter
69
+ # display login and status
70
+ # no bufferization needed
71
+ match '/root/contents/noname/contents/login=(.*)/status/(.*)', :run
72
+
73
+ def run ( tree, login, status )
74
+ # here the status and the tree are equal
75
+ @log[login] = status
76
+ end
77
+ end
78
+
79
+ class TestFilter2 < RPathFilter
80
+ match '/root/contents/noname/contents/login=(.*)/status/(.*)' do
81
+ |obj, tree, login, status|
82
+ obj.log[login] = status
83
+ end
84
+ end
85
+
86
+ class TestFilter3 < RPathFilter
87
+ # display login and status
88
+ # with a buffer (see the star before login)
89
+ match '/root/contents/noname/contents/login=(.*)/*status$', :yeah
90
+
91
+ def yeah ( tree, login )
92
+ @log[login] = tree.rpath_find :first, '/status/'
93
+ end
94
+ end
95
+
96
+ class TestFilter4 < RPathFilter
97
+ # with a buffer (see the star before status)
98
+ match '//cont//ents/lo.in=(.*)/()st.tus/FAIL' do |obj, tree, login|
99
+ obj.log[login] = tree.rpath_find :first, '/reason/'
100
+ end
101
+ end
102
+
103
+ # With two matchers
104
+ # FIXME try to use only one buffer
105
+ class TestFilter5 < RPathFilter
106
+ match '//contents//contents/login=(.*)/()status/PASS', :pass
107
+ match '//contents//contents/login=(.*)/()status/FAIL', :fail
108
+ def fail ( tree, login )
109
+ @log[login] = "FAIL, " + tree.rpath_find(:first, '/reason/.*')
110
+ end
111
+ def pass ( tree, login )
112
+ @log[login] = "PASS strategy: " +
113
+ tree.rpath_find(:first, '/strategy/.*')
114
+ end
115
+ end
116
+
117
+ class TestFilter6 < RPathFilter
118
+ # display the name of a test and it's status
119
+ match '(.*)/^status$/(.*)\Z', :yeah
120
+
121
+ def yeah ( tree, name, status )
122
+ @log[name] = status
123
+ end
124
+ end
125
+
126
+
127
+ #
128
+ # Tests
129
+ #
130
+
131
+ @@notifs1 = [
132
+ [[:joe], "PASS"],
133
+ [[:bar], "PASS"],
134
+ [[:foo], "FAIL"],
135
+ [[:yo], "ABORT"],
136
+ [[:yeah], "FAIL"]
137
+ ]
138
+
139
+ @@notifs2 = [
140
+ [[:foo], "Fail always fails"],
141
+ [[:yeah], "Fail always fails"]
142
+ ]
143
+
144
+ @@notifs3 = [
145
+ [[:joe], "PASS strategy: Pass"],
146
+ [[:bar], "PASS strategy: Pass"],
147
+ [[:foo], "FAIL, Fail always fails"],
148
+ [[:yeah], "FAIL, Fail always fails"]
149
+ ]
150
+
151
+ @@notifs4 = [
152
+ [[:root], "FAIL(40%)"],
153
+ [[:noname], "FAIL(40%)"],
154
+ [[:"Test login=joe"], "PASS"],
155
+ [[:"Test login=bar"], "PASS"],
156
+ [[:"Test login=foo"], "FAIL"],
157
+ [[:"Test login=yo"], "ABORT"],
158
+ [[:"Test login=yeah"], "FAIL"]
159
+ ]
160
+
161
+ def test_filter1
162
+ assert_rpath_filter(@@notifs1, TestFilter1)
163
+ end
164
+
165
+ def test_filter2
166
+ assert_rpath_filter(@@notifs1, TestFilter2)
167
+ end
168
+
169
+ def test_filter3
170
+ assert_rpath_filter(@@notifs1, TestFilter3)
171
+ end
172
+
173
+ def test_filter4
174
+ assert_rpath_filter(@@notifs2, TestFilter4)
175
+ end
176
+
177
+ def test_filter5
178
+ assert_rpath_filter(@@notifs3, TestFilter5)
179
+ end
180
+
181
+ def test_filter6
182
+ assert_rpath_filter(@@notifs4, TestFilter6)
183
+ end
184
+
185
+ end # class RPathFilterTest
186
+
187
+ end # module Filters
188
+
189
+ end # module Uttk
190
+
191
+ end
@@ -0,0 +1,46 @@
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/test/unit/filters/text_filter_test.rb 8778 2005-09-26T04:34:48.103938Z ertai $
5
+
6
+ test_section __FILE__ do
7
+
8
+ module Uttk
9
+
10
+ module Filters
11
+
12
+ class TextFilterTest < ::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 TextFilterTest
41
+
42
+ end # module Filters
43
+
44
+ end # module Uttk
45
+
46
+ end
@@ -0,0 +1,119 @@
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: /w/fey/uttk/trunk/test/unit/filters_test.rb 22057 2006-02-20T21:40:27.185401Z pouillar $
5
+
6
+
7
+ test_section __FILE__ do
8
+
9
+ module Uttk
10
+
11
+ # Test the method provided by the Filters module.
12
+ class FiltersTest < Test::Unit::TestCase
13
+
14
+ def test_backend
15
+ # test Yaml
16
+ backend = Uttk::Filters['Yaml']
17
+ assert_equal 1, backend.size
18
+ assert_dumper backend.first, Uttk::Dumpers::Yaml, STDOUT
19
+ # test Yaml: foo
20
+ TempPath.new('filters_test') do |tmp|
21
+ io = tmp.open('w')
22
+ backend = Uttk::Filters["Yaml: #{tmp}"]
23
+ assert_equal 1, backend.size
24
+ assert_dumper backend.first, Uttk::Dumpers::Yaml, io
25
+ end
26
+ # test Xml: foo, Yaml: bar
27
+ TempPath.new('filters_test') do |tmp1|
28
+ io1 = tmp1.open('w')
29
+ TempPath.new('filters_test') do |tmp2|
30
+ io2 = tmp2.open('w')
31
+ backend = Uttk::Filters["Xml: #{tmp1}, Yaml: #{tmp2}"]
32
+ assert_dumpers(backend, 2,
33
+ [ Uttk::Dumpers::Xml, io1 ],
34
+ [ Uttk::Dumpers::Yaml, io2 ])
35
+ end
36
+ end
37
+ # test [{Xml: foo}, {Xml: bar}]
38
+ TempPath.new('filters_test') do |tmp1|
39
+ io1 = tmp1.open('w')
40
+ TempPath.new('filters_test') do |tmp2|
41
+ io2 = tmp2.open('w')
42
+ backend = Uttk::Filters[" [{Xml: #{tmp1}}, {Xml: #{tmp2}}]"]
43
+ assert_equal 2, backend.size
44
+ assert_dumper backend.first, Uttk::Dumpers::Xml, io1
45
+ assert_dumper backend.last, Uttk::Dumpers::Xml, io2
46
+ end
47
+ end
48
+ # test Xml: [ foo, bar]
49
+ TempPath.new('filters_test') do |tmp1|
50
+ io1 = tmp1.open('w')
51
+ TempPath.new('filters_test') do |tmp2|
52
+ io2 = tmp2.open('w')
53
+ backend = Uttk::Filters["Xml: [#{tmp1}, #{tmp2}]"]
54
+ assert_equal 1, backend.size
55
+ assert_dumper backend.first, Uttk::Dumpers::Xml, io1, io2
56
+ end
57
+ end
58
+ # test Basic, Xml: log.xml
59
+ TempPath.new('filters_test') do |tmp|
60
+ io = tmp.open('w')
61
+ backend = Uttk::Filters["Basic, Xml: #{tmp}"]
62
+ assert_dumpers(backend, 2,
63
+ [ Uttk::Dumpers::Basic, STDOUT ],
64
+ [ Uttk::Dumpers::Xml, io ])
65
+ end
66
+ # test JustStatus: Basic
67
+ backend = Uttk::Filters["JustStatus: Basic"]
68
+ assert_equal 1, backend.size
69
+ observers = assert_filter backend.first, Uttk::Filters::JustStatus, 1
70
+ assert_dumper observers.first, Uttk::Dumpers::Basic, STDOUT
71
+ # test JustStatus: {Basic, Xml: log.xml}
72
+ TempPath.new('filters_test') do |tmp|
73
+ io = tmp.open('w')
74
+ backend = Uttk::Filters["JustStatus: {Basic, Xml: #{tmp}}"]
75
+ assert_equal 1, backend.size
76
+ observers = assert_filter backend.first, Uttk::Filters::JustStatus, 2
77
+ assert_dumpers(observers, 2,
78
+ [ Uttk::Dumpers::Yaml, STDOUT ],
79
+ [ Uttk::Dumpers::Xml, io ])
80
+ end
81
+ end
82
+
83
+ protected
84
+
85
+ def assert_dumper(dumper, dumper_class, *outputs)
86
+ assert_kind_of dumper_class, dumper
87
+ dumper.each_output do |output|
88
+ assert_equal output.inspect, outputs.shift.inspect
89
+ end
90
+ end
91
+
92
+ def assert_dumpers(dumpers, nb_dumpers, *descs)
93
+ assert_equal nb_dumpers, dumpers.size
94
+ dumpers.each { |dumper| check_dumper_desc(dumper, descs) }
95
+ end
96
+
97
+ def check_dumper_desc(dumper, descs)
98
+ descs.each do |desc|
99
+ if desc.first == dumper.class
100
+ assert_dumper(dumper, *desc)
101
+ return true
102
+ end
103
+ end
104
+ return false
105
+ end
106
+
107
+ def assert_filter(filter, filter_class, nb_observers)
108
+ assert_kind_of filter_class, filter
109
+ observers = []
110
+ filter.instance_eval { observers = @observer_peers }
111
+ assert_equal nb_observers, observers.size
112
+ observers
113
+ end
114
+
115
+ end # class Filters
116
+
117
+ end # module Uttk
118
+
119
+ end # test_section __FILE__
@@ -0,0 +1,120 @@
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: /w/fey/uttk/trunk/test/unit/logger/section_node_test.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
5
+
6
+
7
+ test_section __FILE__ do
8
+
9
+
10
+ module Uttk
11
+
12
+ class Logger
13
+
14
+ class SectionNodeTest < ::Test::Unit::TestCase
15
+
16
+ def setup
17
+ foo = SectionNode.new('foo',
18
+ SectionNode.new('baz',
19
+ SectionNode.new('son1'),
20
+ SectionNode.new('son2')),
21
+ SectionNode.new('goo'))
22
+ @tree = SectionNode.new('root',
23
+ foo,
24
+ SectionNode.new('bar'))
25
+ end
26
+
27
+ def test_name=
28
+ s = SectionNode.new('toto')
29
+ assert_equal('toto', s.name)
30
+ s.name = 'foo'
31
+ assert_equal('foo', s.name)
32
+ end
33
+
34
+ def test_sub_sections
35
+ assert_equal([], SectionNode.new('foo').sub_sections)
36
+ end
37
+
38
+ def test_label
39
+ s = SectionNode.new('foo',
40
+ SectionNode.new('bar'),
41
+ SectionNode.new('baz', SectionNode.new('goo')))
42
+ assert_equal('bar', s['bar'].name)
43
+ assert_equal('baz', s['baz'].name)
44
+ assert_equal('goo', s['baz']['goo'].name)
45
+ end
46
+
47
+ def test_find
48
+ goo = SectionNode.new('goo')
49
+ s = SectionNode.new('foo',
50
+ SectionNode.new('bar'),
51
+ SectionNode.new('baz', goo))
52
+ assert_equal(goo, s.find('goo'))
53
+ assert_nil(s.find('toto'))
54
+ end
55
+
56
+ def test_active_tree
57
+ s = SectionNode.new('foo',
58
+ SectionNode.new('bar'),
59
+ SectionNode.new('baz', SectionNode.new('goo')))
60
+ assert(! s.active?)
61
+ s.each_section { |ss| assert(! ss.active?) }
62
+ assert(! s['baz']['goo'].active?)
63
+ section_actived = s.active_tree(true)
64
+ expected_section = %w(foo bar baz goo)
65
+ expected_section.each do |x|
66
+ assert(section_actived.include?(x), "#{x} not actived")
67
+ end
68
+ assert_equal(expected_section.size, section_actived.size)
69
+ s.each_section { |ss| assert(ss.active?) }
70
+ assert(s['baz']['goo'].active?)
71
+ end
72
+
73
+ def test_active_section
74
+ assert_equal([], SectionNode.new('root').active_section('toto'))
75
+ assert_equal(['root'], SectionNode.new('root').active_section('root'))
76
+ assert_equal([], @tree.active_section('toto'))
77
+ section_actived = @tree.active_section('baz')
78
+ expected_section = %w(root foo baz son1 son2)
79
+ expected_section.each do |x|
80
+ assert(section_actived.include?(x), "#{x} not actived")
81
+ end
82
+ assert_equal(expected_section.size, section_actived.size)
83
+ end
84
+
85
+ def test_unactive_section__easy
86
+ assert_equal([], SectionNode.new('root').unactive_section('toto'))
87
+ assert_equal([], SectionNode.new('root').unactive_section('root'))
88
+ section_actived = @tree.active_section('baz')
89
+ section_actived = @tree.unactive_section('baz')
90
+ expected_section = %w(root foo baz son1 son2)
91
+ expected_section.each do |x|
92
+ assert(section_actived.include?(x), "#{x} not actived")
93
+ end
94
+ assert_equal(expected_section.size, section_actived.size)
95
+ end
96
+
97
+ def test_unactive_section__difficult
98
+ section_actived = @tree.active_section('baz')
99
+ section_actived = @tree.active_section('goo')
100
+ section_actived = @tree.unactive_section('baz')
101
+ expected_section = %w(baz son1 son2)
102
+ expected_section.each do |x|
103
+ assert(section_actived.include?(x), "#{x} not actived")
104
+ end
105
+ assert_equal(expected_section.size, section_actived.size)
106
+ section_actived = @tree.unactive_section('goo')
107
+ expected_section = %w(goo foo root)
108
+ expected_section.each do |x|
109
+ assert(section_actived.include?(x), "#{x} not actived")
110
+ end
111
+ assert_equal(expected_section.size, section_actived.size)
112
+ end
113
+
114
+ end # class SectionNodeTest
115
+
116
+ end # class Logger
117
+
118
+ end # module Uttk
119
+
120
+ end