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
data/bin/uttk ADDED
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/env ruby
2
+ # Author:: The Uttk Team.
3
+ # Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
4
+ # License:: LGPL
5
+ # $Id: /w/fey/uttk/trunk/bin/uttk 22095 2006-02-21T17:17:56.386215Z pouillar $
6
+
7
+ begin
8
+ require 'pathname'
9
+
10
+ ME = Pathname.new($0).basename unless defined? ME
11
+ ME_DIR = Pathname.new(__FILE__).dirname unless defined? ME_DIR
12
+
13
+ $PROGRAME_NAME = ME
14
+ $PROGRAME_NAME.freeze
15
+ $VERBOSE = true # you can use 'export RUBYOPT="-w"' too
16
+
17
+ Uttk_BIN = true
18
+
19
+ require Pathname.new(__FILE__).dirname.parent + 'lib/uttk' unless defined? Uttk
20
+
21
+ module Uttk
22
+ SPEC_YML = ME_DIR.parent + 'SPEC.yml'
23
+ SPEC = YAML::load(SPEC_YML.read)
24
+ VERSION = SPEC['version']
25
+ VERSION_PATH = ME_DIR.parent + 'VERSION'
26
+ AUTHORS_PATH = ME_DIR.parent + 'AUTHORS'
27
+ require 'erb'
28
+ VERSION_TEXT = ERB.new(VERSION_PATH.read, nil, '<%>').result(binding)
29
+ end
30
+
31
+ require "#{ME_DIR}/getopts/uttk"
32
+
33
+ argv = ARGV.dup
34
+ opts = Uttk::Getopts::Uttk.parse(argv)
35
+
36
+ require 'profile' if opts[:profile]
37
+
38
+ if opts[:cache_dir] and opts[:cache_dir] != TempPath.tmpdir
39
+ TempPath.tmpdir.rmdir
40
+ opts[:cache_dir].mv(TempPath.tmpdir)
41
+ opts[:cache_dir] = TempPath.tmpdir
42
+ opts[:cache_mode] ||= true
43
+ end
44
+
45
+ symtbl = Uttk.default_symtbl(opts).new_child
46
+ log = symtbl[:log]
47
+ at_exit { log.close }
48
+
49
+ t = argv.uttk_testify(symtbl)
50
+
51
+ # Load the cache file if cache_dir is set.
52
+ if cache_dir = opts[:cache_dir]
53
+ cache = cache_dir + 'cache.yml'
54
+ t.symtbl[:use_cache] = YAML.parse(cache.read).symbol_safe_transform
55
+ end
56
+
57
+ # Disable the automatic cleaning of TempPath for the cache mode.
58
+ if opts[:cache_mode]
59
+ TempPath.auto_clean = false
60
+ end
61
+
62
+ # Run the root test.
63
+ status = t.run
64
+
65
+
66
+ # Generate the cache file.
67
+ if opts[:cache_mode]
68
+ cache_file = TempPath.tmpdir + 'cache.yml'
69
+ cache = t.symtbl[:cache]
70
+ t.symtbl.local.delete :cache
71
+ cache.each do |name, test|
72
+ todel = [:use_cache]
73
+ test[:symtbl].each do |k, v|
74
+ if [SynFlow, SynFlowFactory].any? { |klass| v.is_a? klass }
75
+ todel << k
76
+ end
77
+ end
78
+ todel.each { |k| test[:symtbl].delete(k) }
79
+ end
80
+ cache_file.open('w') { |f| f.puts cache.to_yaml }
81
+ end
82
+
83
+ relaunch = TempPath.tmpdir + 'relaunch'
84
+
85
+ if opts[:cache_mode]
86
+
87
+ # Update the argument for the cache mode
88
+ ARGV.delete '-C'
89
+ if ARGV.include? '--cache-dir'
90
+ ind = ARGV.index('--cache-dir') + 1
91
+ ARGV[ind] = TempPath.tmpdir.to_s
92
+ else
93
+ ARGV << '--cache-dir' << TempPath.tmpdir.to_s
94
+ end
95
+
96
+ end
97
+
98
+ if (opts[:cache_mode] or opts[:cache_dir]) and not status.pass?
99
+ raise 'HighLine is unavailable' unless defined? HighLine
100
+ h = HighLine.new
101
+ # Ask the user what to do.
102
+ if h.agree 'Would you relaunch the test suite now (use the cache) (y/n)', true
103
+ pid = Kernel.fork do
104
+ Kernel.exec Config::CONFIG['RUBY_INSTALL_PATH'], $0, *ARGV
105
+ end
106
+ Process.waitpid pid
107
+ exit
108
+ else
109
+ if h.agree 'Would you remove the temporary dir (y/n)', true
110
+ TempPath.auto_clean = true
111
+ else
112
+ TempPath.auto_clean = false
113
+ # Generate a little helper script to use the cache mode.
114
+ unless relaunch.exist?
115
+ relaunch.open('w') do |f|
116
+ f.puts '#!/usr/bin/env ruby'
117
+ f.puts "
118
+ |Kernel.exec #{Config::CONFIG['RUBY_INSTALL_PATH'].inspect},
119
+ | #{$0.inspect}, *#{ARGV.inspect}
120
+ |".head_cut!
121
+ end
122
+ relaunch.chmod(0500)
123
+ end
124
+
125
+ STDERR.puts "
126
+ |
127
+ |--- |
128
+ |
129
+ | /------------------------------------------------------------------.
130
+ | | Uttk was running in cache mode to re-run the same one just type: |
131
+ | | #{relaunch.to_s.ljust(63)}|
132
+ | `------------------------------------------------------------------/
133
+ |".head_cut!
134
+ end
135
+ end
136
+ else
137
+ TempPath.auto_clean = true
138
+ end
139
+
140
+ # Handle the --dump-status option.
141
+ STDOUT.puts status.to_yaml if opts[:dump_status]
142
+
143
+ unless status.pass?
144
+
145
+ if not opts[:dump_status] # FIXME and filter contains Default
146
+ STDERR.puts "
147
+ |
148
+ |--- |
149
+ | /-----------------------------------------------------------------------------.
150
+ | | *** Some tests failed *** |
151
+ | | The last status was not PASS but something like FAIL(42%) (just FAIL stands |
152
+ | | for FAIL(0%)). This means that 42% of tests *pass* but 100% was expected. |
153
+ | | To investigate results these different outputs are available: |
154
+ | | - the standard output is the shortest one (like a progression bar). |
155
+ | | - log.html contains an HTML/JavaScript page nice to display big outputs. |
156
+ | | - log.yml contains more information in the very readable YAML format. |
157
+ | | - log.xml contains the output as an XML document. |
158
+ | `-----------------------------------------------------------------------------/
159
+ |".head_cut!
160
+ end
161
+ exit(2)
162
+ end
163
+
164
+ rescue SystemExit
165
+ raise
166
+ rescue Exception => ex
167
+
168
+ TempPath.auto_clean = true if defined? TempPath
169
+ Thread.critical = true if defined? Thread
170
+ raise ex if ex.is_a? SystemExit
171
+ if defined? OptionParser and ex.is_a? OptionParser::ParseError
172
+ Uttk::Getopts::Uttk.usage
173
+ puts
174
+ if log.nil?
175
+ STDERR.puts "ERROR:\n #{ex.to_s} (OptionParser)"
176
+ else
177
+ log.error { ex }
178
+ end
179
+ elsif log.nil?
180
+ raise ex
181
+ else
182
+ log.error { ex }
183
+ end
184
+ exit(1)
185
+
186
+ end
187
+
188
+ exit(0)
data/bin/uttk-unit ADDED
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
3
+ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
4
+ # License:: Gnu General Public License.
5
+ # Revision:: $Id$
6
+
7
+
8
+ # FIXME add a configuration file
9
+ # conf:
10
+ # load_path: ../lib # relative to the place of the configuration file
11
+ # requires:
12
+ class UttkUnit
13
+
14
+ def initialize ( argv )
15
+ @argv = argv
16
+ end
17
+
18
+
19
+ def parse_options
20
+ @options = OpenStruct.new(:load_path => [],
21
+ :actions => [],
22
+ :uttk => nil,
23
+ :verbose => true,
24
+ :mode => :require)
25
+
26
+ OptionParser.new do |o|
27
+ o.on('-I', '--include DIR', 'Add this directory to $LOAD_PATH') do |dir|
28
+ @options.load_path << dir
29
+ @options.actions << proc { dir.to_path.load_path! if defined? CoreEx }
30
+ end
31
+ o.on('-r', '--require FEATURE', 'Require this file') do |file|
32
+ @options.actions << proc { require file }
33
+ end
34
+ o.on('--import NAME', 'Import this constant') do |const|
35
+ @options.actions << proc { const.constantize.import! }
36
+ end
37
+ o.on('--mode import|require|nothing', [:import, :require, :nothing],
38
+ 'Set the loading mode for unit tests [default: require]') do |mode|
39
+ @options.mode = mode
40
+ end
41
+ o.on('-w', '--[no-]verbose', 'Turn on/off the verbose mode [default: on]') do |b|
42
+ @options.verbose = b
43
+ end
44
+ o.on('--uttk FILE', 'Require this Uttk (`no\' to disable)') do |file|
45
+ @options.uttk = file
46
+ end
47
+ end.parse!(@argv)
48
+ end
49
+
50
+
51
+ def requires
52
+ require 'pathname'
53
+ require 'ostruct'
54
+ require 'optparse'
55
+ end
56
+
57
+
58
+ def run
59
+ raise 'Do not load CoreEx before uttk-unit' if defined? CoreEx
60
+
61
+ requires
62
+
63
+ parse_options
64
+
65
+ files = []
66
+ options = false
67
+ argv = ARGV.dup
68
+ ARGV.replace([])
69
+ argv.each do |arg|
70
+ if options
71
+ ARGV << arg
72
+ next
73
+ end
74
+ if arg == '--'
75
+ options = true
76
+ else
77
+ files << Pathname.new(arg).cleanpath
78
+ end
79
+ end
80
+
81
+ quoted_paths = files.map { |s| Regexp.quote(s) }
82
+ re_paths = Regexp.new("(#{quoted_paths.join '|'})")
83
+
84
+ Kernel.const_set(:EMBEDDED_TEST_MODE, re_paths)
85
+
86
+ @options.load_path.each { |dir| $LOAD_PATH << dir }
87
+
88
+ root = Pathname.new(__FILE__).dirname.parent
89
+
90
+ if @options.uttk.nil?
91
+ require((root + 'lib' + 'uttk').to_s)
92
+ elsif @options.uttk != 'no'
93
+ require @options.uttk
94
+ end
95
+
96
+ @options.actions.each { |block| block[] }
97
+
98
+ raise 'CoreEx not loaded' unless defined? CoreEx
99
+
100
+ Test::Unit::UI::Yaml::TestRunner.import!
101
+
102
+ $VERBOSE = @options.verbose
103
+
104
+ files.each do |arg|
105
+ path = Pathname.new(arg).ext.to_s
106
+
107
+ case @options.mode
108
+ when :import
109
+ path = path.camelize if path !~ /[A-Z]/ or path =~ /[.\/]/
110
+ path.constantize.import!
111
+ when :require
112
+ require path
113
+ when :nothing
114
+ else raise "Bad loading mode: #{@options.mode}"
115
+ end
116
+ end
117
+
118
+ run_embedded_test_sections
119
+ end
120
+
121
+
122
+ end # class UttkUnit
123
+
124
+
125
+ UttkUnit.new(ARGV).run
data/lib/uttk.rb ADDED
@@ -0,0 +1,288 @@
1
+ # Author:: The Uttk team
2
+ # Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
3
+ # License:: LGPL
4
+ # $Id: /w/fey/uttk/trunk/lib/uttk.rb 22081 2006-02-21T15:10:48.580983Z pouillar $
5
+
6
+ #
7
+ # = Description
8
+ #
9
+ # Interface module of the Uttk library. This file must be included by every
10
+ # Uttk's users.
11
+ #
12
+
13
+ #
14
+ # = Introduction
15
+ #
16
+ # This is the Uttk namespace. All Uttk is included into this namespace. This
17
+ # module provides some function to set up and run a Uttk pipeline.
18
+ #
19
+ # = How to use Uttk as a library
20
+ #
21
+ # FIXME: document me
22
+ module Uttk
23
+
24
+ require 'pathname'
25
+
26
+ lib = Pathname.new(__FILE__).dirname
27
+ vendor = lib.parent + 'vendor'
28
+ unless defined? RubyEx
29
+ $CORE_EX_VENDORS ||= []
30
+ $CORE_EX_VENDORS << vendor
31
+ file = vendor + 'ruby_ex' + 'lib' + 'ruby_ex.rb'
32
+ if file.exist?
33
+ require file.to_s
34
+ else
35
+ require 'rubygems'
36
+ require_gem 'ruby_ex'
37
+ require 'ruby_ex'
38
+ end
39
+ end
40
+ $LOADED_FEATURES << 'uttk.rb'
41
+ lib.load_path!
42
+ RubyEx.import!
43
+ mattr_accessor :dir, :load_path
44
+ self.dir = lib + 'uttk'
45
+ self.load_path = [dir]
46
+ silence_warnings { core_ex_require 'action_view', 'actionpack' }
47
+
48
+
49
+ # Standard library requirements
50
+ require 'stringio'
51
+ require 'ostruct'
52
+ require 'tmpdir'
53
+ require 'thread'
54
+ require 'mutex_m'
55
+ require 'benchmark'
56
+ require 'rbconfig'
57
+ conf = Config::CONFIG
58
+ conf['RUBY_INSTALL_PATH'] = "#{conf['bindir']}/#{conf['RUBY_INSTALL_NAME']}"
59
+
60
+ # RubyEx requirements
61
+ SymTblGsub.import!
62
+ SynFlow.import!
63
+ Module::InstanceMethodVisibility.import!
64
+ AutoloadTree.import!
65
+ OrderedHash.import!
66
+ Abstract.import!
67
+ ConstRegexp.import!
68
+ HashEval.import!
69
+ RPath.import!
70
+ Commands.import!
71
+ Version.import!
72
+ URI::GenericEx.import!
73
+
74
+ # Mother exception of every exception thrown by Uttk.
75
+ class UttkException < Exception
76
+ end
77
+
78
+ # Uttk library requirements
79
+ require 'uttk/logger'
80
+ require 'uttk/logger_factory'
81
+ require 'uttk/streams'
82
+
83
+ # Autoload modules
84
+ def pathname_to_class(p)
85
+ const = p.basename.to_s.sub(/\.rb$/, '')
86
+ if const =~ ConstRegexp::RB_CONST
87
+ const
88
+ else
89
+ raise(ArgumentError,
90
+ "`#{p.to_s}' - your file doesn't follow our convention, " +
91
+ "the filename must be equal to the class name you declared into.")
92
+ nil
93
+ end
94
+ end
95
+ module_function :pathname_to_class
96
+
97
+ UTTK_MODULES = []
98
+
99
+ class ::Module
100
+ def uttk_module
101
+ module_eval do
102
+ UTTK_MODULES << self
103
+
104
+ def self.module_dirs
105
+ mod = name.demodulize.underscore
106
+ Uttk.load_path.map { |path| path/mod }
107
+ end
108
+
109
+ def self.setup_autoload
110
+ module_dirs.each do |module_dir|
111
+ if module_dir.directory? and module_dir.readable? and module_dir.executable?
112
+ autoload_tree(module_dir, false) do |p|
113
+ Uttk.pathname_to_class(p)
114
+ end
115
+ end
116
+ end
117
+ end
118
+ setup_autoload
119
+
120
+ def self.define_module
121
+ module_dirs.each do |module_dir|
122
+ def_file = Pathname.new("#{module_dir}.rb")
123
+ if def_file.readable?
124
+ require def_file.to_s
125
+ end
126
+ end
127
+ end
128
+ define_module
129
+
130
+ def self.each_module_name ( &block )
131
+ Pathname.glob('{' + module_dirs.join(',') + '}/**/*.rb') do |path|
132
+ block[path.basename.ext.to_s.to_sym]
133
+ end
134
+ end
135
+
136
+ end
137
+ end
138
+ end
139
+
140
+ def self.setup_autoload_all
141
+ UTTK_MODULES.each do |uttk_module|
142
+ uttk_module.setup_autoload
143
+ end
144
+ end
145
+
146
+ class ObserverError < ArgumentError
147
+ def initialize ( anObject )
148
+ @obs = anObject
149
+ end
150
+ def to_s
151
+ "observer needs to respond to `update' (#{@obs.inspect})"
152
+ end
153
+ end
154
+
155
+ module Weights
156
+ uttk_module
157
+ end
158
+
159
+ require 'uttk/status'
160
+
161
+ module Dumpers
162
+ uttk_module
163
+ end
164
+
165
+ module Loaders
166
+ uttk_module
167
+ end
168
+
169
+ module PathFilters
170
+ uttk_module
171
+ end
172
+
173
+ module Filters
174
+ uttk_module
175
+ end
176
+
177
+ module Strategies
178
+ uttk_module
179
+ end
180
+
181
+ # Modules shortcuts
182
+ S = Strategies
183
+ L = Loaders
184
+ D = Dumpers
185
+ F = Filters
186
+ W = Weights
187
+
188
+ # Set default options
189
+ DEFAULT_OPTIONS = {
190
+ :observers => [],
191
+ :backend => STDOUT.tty? ? 'DefaultColor' : 'Default',
192
+ :loader => Loaders::Yaml,
193
+ :wclass => Weights::Default,
194
+ :attributes => {}, #FIXME: freeze
195
+ :symbols => {}, #FIXME: freeze
196
+ :log_severity => Logger::Severity::INFO,
197
+ :log_verbosity => 0,
198
+ :log_section => [], #FIXME: freeze
199
+ :benchmark => false,
200
+ :profile => false,
201
+ :dump_status => false,
202
+ :cache_mode => false,
203
+ :cache_proc => DumpableProc.new('|test, status|
204
+ status.pass? or (status.is_a? Uttk::SkipStatus and status.weight.pass?)'
205
+ ).freeze,
206
+ }.freeze
207
+
208
+ def self.default_options
209
+ DEFAULT_OPTIONS
210
+ end
211
+
212
+ # Return the default symbol table
213
+ def self.default_symtbl ( options=default_options,
214
+ log_factory=default_log_factory(options),
215
+ log=default_log(options, log_factory))
216
+ symtbl = SymTbl.new(options)
217
+ symtbl[:uttk] = Pathname.new($0).expand_path
218
+ symtbl[:ruby] = Config::CONFIG['RUBY_INSTALL_PATH']
219
+ symtbl[:'uttk-unit'] = symtbl[:uttk_unit] =
220
+ (Uttk.dir.parent.parent/'bin'/'uttk-unit').expand_path.cleanpath
221
+ symtbl[:core_ex] = CoreEx.dir
222
+ symtbl[:symtbl_class] = symtbl.class
223
+ symtbl[:pwd] = Pathname.pwd.expand_path
224
+ symtbl[:loader] = options[:loader].new
225
+ symtbl[:log_factory] = log_factory
226
+ symtbl[:log] = log
227
+ symtbl[:cache] = {}
228
+ symtbl[:cache_proc] = options[:cache_proc]
229
+ symtbl[:suite_name] = 'root'
230
+ symtbl
231
+ end
232
+
233
+ # Return the default logger factory
234
+ def self.default_log_factory ( options=default_options )
235
+ log_factory = LoggerFactory.new
236
+ if ENV.has_key?('UTTK_SEVERITY')
237
+ log_factory.severity_level = ENV['UTTK_SEVERITY']
238
+ else
239
+ log_factory.severity_level = options[:log_severity]
240
+ end
241
+ log_factory.verbosity_level = options[:log_verbosity]
242
+ log_factory.section_tree << Logger::SectionNode.new('basicObserver')
243
+ log_factory.active_section = options[:log_section]
244
+ log_factory
245
+ end
246
+
247
+ # Return the default logger factory
248
+ def self.default_log ( options=default_options,
249
+ log_factory=default_log_factory(options) )
250
+ log = log_factory.create
251
+ options[:observers] << options[:backend] if options[:observers].empty?
252
+ options[:observers].each do |backend|
253
+ Filters[backend].each do |obsv|
254
+ raise ObserverError, obsv unless obsv.respond_to? :update
255
+ log.add_observer(obsv)
256
+ end
257
+ end
258
+ log.info_basicObserver do
259
+ log.add_observer(Uttk::Dumpers::Basic.new(STDERR))
260
+ nil
261
+ end
262
+ log
263
+ end
264
+
265
+ # Evaluate code in the context of the Uttk module
266
+ def self.uttk_eval(string, symtbl, filename=__FILE__, lineno=1)
267
+ eval(string, binding, filename, lineno)
268
+ end
269
+
270
+ def self.bin
271
+ Config::CONFIG["RUBY_INSTALL_NAME"].to_cmd[dir.parent.parent + 'bin/uttk']
272
+ end
273
+
274
+ end # module Uttk
275
+
276
+ class Class
277
+ alias_method :old_to_yaml, :to_yaml
278
+ def to_yaml ( opts={} )
279
+ to_s.to_yaml(opts)
280
+ end
281
+ def is_complex_yaml?
282
+ false
283
+ end
284
+ end
285
+
286
+ if $0.to_path.basename.to_s == 'uttk' and not defined? Uttk_BIN
287
+ load Uttk::LIB_DIR.parent + 'bin/uttk'
288
+ end