uttk 0.3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +36 -0
- data/COPYING +18 -0
- data/ChangeLog +7673 -0
- data/GUIDELINES +86 -0
- data/LGPL +504 -0
- data/NEWS +158 -0
- data/NORM +137 -0
- data/README +180 -0
- data/Rakefile +8 -0
- data/SPEC.gemspec +15 -0
- data/SPEC.yml +60 -0
- data/TODO +23 -0
- data/TODO.old +31 -0
- data/VERSION +5 -0
- data/bin/getopts/uttk.rb +390 -0
- data/bin/uttk +188 -0
- data/bin/uttk-unit +125 -0
- data/lib/uttk.rb +288 -0
- data/lib/uttk/dumpers/Basic.rb +23 -0
- data/lib/uttk/dumpers/BasicColor.rb +35 -0
- data/lib/uttk/dumpers/Dumper.rb +77 -0
- data/lib/uttk/dumpers/Html.rb +271 -0
- data/lib/uttk/dumpers/Path.rb +24 -0
- data/lib/uttk/dumpers/Xml.rb +88 -0
- data/lib/uttk/dumpers/Yaml.rb +138 -0
- data/lib/uttk/filters.rb +128 -0
- data/lib/uttk/filters/Buffer.rb +119 -0
- data/lib/uttk/filters/Compact.rb +75 -0
- data/lib/uttk/filters/Default.rb +27 -0
- data/lib/uttk/filters/DefaultColor.rb +27 -0
- data/lib/uttk/filters/Filter.rb +53 -0
- data/lib/uttk/filters/Id.rb +30 -0
- data/lib/uttk/filters/JustStatus.rb +25 -0
- data/lib/uttk/filters/KeepSkipBased.rb +38 -0
- data/lib/uttk/filters/NodeCut.rb +97 -0
- data/lib/uttk/filters/RPathFilter.rb +134 -0
- data/lib/uttk/filters/Saver.rb +53 -0
- data/lib/uttk/filters/TextFilter.rb +69 -0
- data/lib/uttk/generators/dumper_generator.rb +28 -0
- data/lib/uttk/generators/filter_generator.rb +28 -0
- data/lib/uttk/generators/generator.rb +86 -0
- data/lib/uttk/generators/generator_generator.rb +26 -0
- data/lib/uttk/generators/loader_generator.rb +28 -0
- data/lib/uttk/generators/path_filter_generator.rb +28 -0
- data/lib/uttk/generators/strategy_generator.rb +28 -0
- data/lib/uttk/generators/templates/dumper.rb +50 -0
- data/lib/uttk/generators/templates/filter.rb +50 -0
- data/lib/uttk/generators/templates/generator.rb +28 -0
- data/lib/uttk/generators/templates/loader.rb +26 -0
- data/lib/uttk/generators/templates/path_filter.rb +28 -0
- data/lib/uttk/generators/templates/strategy.rb +59 -0
- data/lib/uttk/generators/templates/strategy.yml +28 -0
- data/lib/uttk/generators/templates/unit_test.rb +46 -0
- data/lib/uttk/loaders/Loader.rb +180 -0
- data/lib/uttk/loaders/Ruby.rb +28 -0
- data/lib/uttk/loaders/Yaml.rb +98 -0
- data/lib/uttk/logger.rb +306 -0
- data/lib/uttk/logger/backend.rb +170 -0
- data/lib/uttk/logger/path.rb +202 -0
- data/lib/uttk/logger/section_node.rb +214 -0
- data/lib/uttk/logger/severity.rb +63 -0
- data/lib/uttk/logger/to_uttk_log.rb +127 -0
- data/lib/uttk/logger/verbosity.rb +61 -0
- data/lib/uttk/logger_factory.rb +55 -0
- data/lib/uttk/path_filters/ColorStatus.rb +57 -0
- data/lib/uttk/path_filters/PathFilter.rb +27 -0
- data/lib/uttk/path_filters/RemoveTypes.rb +25 -0
- data/lib/uttk/status.rb +146 -0
- data/lib/uttk/strategies/Abort.rb +24 -0
- data/lib/uttk/strategies/Assert.rb +44 -0
- data/lib/uttk/strategies/Authors.rb +45 -0
- data/lib/uttk/strategies/Block.rb +113 -0
- data/lib/uttk/strategies/Bootstrap.rb +55 -0
- data/lib/uttk/strategies/Checkout.rb +64 -0
- data/lib/uttk/strategies/Clean.rb +29 -0
- data/lib/uttk/strategies/Cmd.rb +60 -0
- data/lib/uttk/strategies/CmdBase.rb +130 -0
- data/lib/uttk/strategies/Collection.rb +158 -0
- data/lib/uttk/strategies/Compile.rb +59 -0
- data/lib/uttk/strategies/Composite.rb +201 -0
- data/lib/uttk/strategies/Composite/contents_eval.rb +40 -0
- data/lib/uttk/strategies/Configure.rb +66 -0
- data/lib/uttk/strategies/Error.rb +23 -0
- data/lib/uttk/strategies/Fail.rb +26 -0
- data/lib/uttk/strategies/IOBased.rb +159 -0
- data/lib/uttk/strategies/Import.rb +60 -0
- data/lib/uttk/strategies/Iterate.rb +139 -0
- data/lib/uttk/strategies/JUnit.rb +205 -0
- data/lib/uttk/strategies/KillAll.rb +62 -0
- data/lib/uttk/strategies/Make.rb +94 -0
- data/lib/uttk/strategies/Package.rb +129 -0
- data/lib/uttk/strategies/PackageCollection.rb +78 -0
- data/lib/uttk/strategies/Pass.rb +24 -0
- data/lib/uttk/strategies/Pool.rb +104 -0
- data/lib/uttk/strategies/ProbabilityThreshold.rb +46 -0
- data/lib/uttk/strategies/Proxy.rb +42 -0
- data/lib/uttk/strategies/RMatch.rb +92 -0
- data/lib/uttk/strategies/RUnit.rb +132 -0
- data/lib/uttk/strategies/SignalCmd.rb +85 -0
- data/lib/uttk/strategies/Sleep.rb +36 -0
- data/lib/uttk/strategies/SqlQuery.rb +120 -0
- data/lib/uttk/strategies/Strategy.rb +683 -0
- data/lib/uttk/strategies/Stub.rb +37 -0
- data/lib/uttk/strategies/SubCmd.rb +77 -0
- data/lib/uttk/strategies/Suite.rb +71 -0
- data/lib/uttk/strategies/Test.rb +89 -0
- data/lib/uttk/streams.rb +69 -0
- data/lib/uttk/streams/Diff.rb +60 -0
- data/lib/uttk/streams/HexaDiff.rb +35 -0
- data/lib/uttk/streams/Stream.rb +76 -0
- data/lib/uttk/weights.rb +17 -0
- data/lib/uttk/weights/WExpr.rb +68 -0
- data/lib/uttk/weights/WFloat.rb +23 -0
- data/lib/uttk/weights/WMin.rb +22 -0
- data/lib/uttk/weights/Weight.rb +105 -0
- data/lib/www/javascripts/uttk.js +185 -0
- data/misc/expandtab.rb +29 -0
- data/misc/header.rb +44 -0
- data/misc/renaming +57 -0
- data/misc/textile_compiler +194 -0
- data/misc/uttk-grep.sh +8 -0
- data/misc/uttk-line-count.rb +143 -0
- data/test/examples-suite.yml +8 -0
- data/test/examples/README +68 -0
- data/test/examples/basic.rb +10 -0
- data/test/examples/basic.yml +9 -0
- data/test/examples/cache/cache_and_fatal.yml +5 -0
- data/test/examples/cache/simple.yml +30 -0
- data/test/examples/sql/basic.yml +24 -0
- data/test/examples/students-suite.yml +9 -0
- data/test/examples/students/ball.yml +11 -0
- data/test/examples/students/glob_stud.yml +20 -0
- data/test/examples/students/mini-lib.yml +61 -0
- data/test/examples/students/pool_stud.yml +31 -0
- data/test/examples/students/stud.yml +21 -0
- data/test/fixtures/ball/20040804-exam_a1-zapngo-tessar_m.tar.gz +0 -0
- data/test/fixtures/ball/Makefile +24 -0
- data/test/fixtures/ball/bar_p-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/bar_p-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/bar_p-mini-lib/my_strlen.c +13 -0
- data/test/fixtures/ball/foo_s-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/foo_s-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/foo_s-mini-lib/configure +2 -0
- data/test/fixtures/ball/foo_s-mini-lib/my_strlen.c +10 -0
- data/test/fixtures/ball/hello.tar.bz2 +0 -0
- data/test/fixtures/ball/hello.tar.gz +0 -0
- data/test/fixtures/ball/hello/Makefile +14 -0
- data/test/fixtures/ball/hello/hello.c +7 -0
- data/test/fixtures/ball/jack-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/jack-exit/Makefile +14 -0
- data/test/fixtures/ball/jack-exit/exit.c +16 -0
- data/test/fixtures/ball/joe-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/joe-exit/Makefile +14 -0
- data/test/fixtures/ball/joe-exit/exit.c +8 -0
- data/test/fixtures/ball/joe_i-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/joe_i-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/joe_i-mini-lib/configure +2 -0
- data/test/fixtures/ball/joe_i-mini-lib/my_strlen.c +10 -0
- data/test/fixtures/ball/john-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/john-exit/Makefile +14 -0
- data/test/fixtures/ball/john-exit/exit.c +6 -0
- data/test/fixtures/ball/qux_j-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/qux_j-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/qux_j-mini-lib/my_strlen.c +12 -0
- data/test/fixtures/binaries/segv +0 -0
- data/test/fixtures/binaries/segv.c +10 -0
- data/test/fixtures/binaries/segv.rb +2 -0
- data/test/fixtures/demo/command-tutorial/steps/1/check.yml +5 -0
- data/test/fixtures/demo/command-tutorial/steps/1/pluralizer.rb +10 -0
- data/test/fixtures/demo/command-tutorial/steps/2/bad_check.yml +7 -0
- data/test/fixtures/demo/command-tutorial/steps/2/check.yml +7 -0
- data/test/fixtures/demo/command-tutorial/steps/2/pluralizer.rb +10 -0
- data/test/fixtures/demo/command-tutorial/steps/3.1/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/3/check.yml +14 -0
- data/test/fixtures/demo/command-tutorial/steps/4.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/4.1/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/4/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/4/pluralizer.rb +12 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/check.yml +17 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/5/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/5/check.yml +16 -0
- data/test/fixtures/demo/command-tutorial/steps/5/pluralizer.rb +16 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/check.yml +22 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/6/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/6/check.yml +21 -0
- data/test/fixtures/demo/command-tutorial/steps/6/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/7/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/7/check.yml +22 -0
- data/test/fixtures/demo/command-tutorial/steps/7/pluralizer.rb +17 -0
- data/test/fixtures/demo/filter-tutorial/check.yml +20 -0
- data/test/fixtures/demo/filter-tutorial/filters/CutSkip100.rb +19 -0
- data/test/fixtures/demo/filter-tutorial/pluralizer.rb +17 -0
- data/test/fixtures/java/unit/MultiRight/Foo/Foo.java +11 -0
- data/test/fixtures/java/unit/MultiRight/Foo/FooTest.java +15 -0
- data/test/fixtures/java/unit/MultiRight/MultiRight.java +13 -0
- data/test/fixtures/java/unit/MultiRight/MultiRightTest.java +12 -0
- data/test/fixtures/java/unit/MultiRight/bar/Bar.java +11 -0
- data/test/fixtures/java/unit/MultiRight/bar/BarTest.java +21 -0
- data/test/fixtures/java/unit/MultiRight/build.sh +7 -0
- data/test/fixtures/java/unit/SimpleException/SimpleExceptionTest.java +11 -0
- data/test/fixtures/java/unit/SimpleException/build.sh +4 -0
- data/test/fixtures/java/unit/build.sh +9 -0
- data/test/fixtures/java/unit/multibar.yml +6 -0
- data/test/fixtures/java/unit/multifoo.yml +6 -0
- data/test/fixtures/java/unit/multiright.yml +8 -0
- data/test/fixtures/java/unit/simple_exception.yml +6 -0
- data/test/fixtures/mini-lib/Makefile +9 -0
- data/test/fixtures/mini-lib/strlen.c +15 -0
- data/test/fixtures/package/pkg_foo.tar.gz +0 -0
- data/test/fixtures/package/pkg_foo/Makefile +20 -0
- data/test/fixtures/package/pkg_foo/bootstrap +3 -0
- data/test/fixtures/package/pkg_foo/configure +3 -0
- data/test/fixtures/package/pkg_foo/foo.sh +2 -0
- data/test/fixtures/text/1.txt +4 -0
- data/test/fixtures/unit/bad.rb +26 -0
- data/test/fixtures/unit/error.rb +6 -0
- data/test/fixtures/unit/good.rb +26 -0
- data/test/functional-suite.yml +10 -0
- data/test/functional/author.yml +11 -0
- data/test/functional/base.yml +119 -0
- data/test/functional/base_pool.yml +13 -0
- data/test/functional/block.yml +13 -0
- data/test/functional/cat.yml +16 -0
- data/test/functional/cmd.yml +17 -0
- data/test/functional/diff.yml +27 -0
- data/test/functional/env_cmd.yml +53 -0
- data/test/functional/exit.yml +15 -0
- data/test/functional/fatal.yml +23 -0
- data/test/functional/glob.yml +11 -0
- data/test/functional/hexa-diff.yml +25 -0
- data/test/functional/import.yml +41 -0
- data/test/functional/iterate.yml +99 -0
- data/test/functional/killall.yml +31 -0
- data/test/functional/pkg.yml +14 -0
- data/test/functional/probability_threshold.yml +35 -0
- data/test/functional/r_unit.yml +26 -0
- data/test/functional/rmatch.yml +122 -0
- data/test/functional/signal_cmd.yml +22 -0
- data/test/functional/sub.yml +15 -0
- data/test/functional/test.yml +25 -0
- data/test/functional/timeout.yml +20 -0
- data/test/functional/wc.yml +26 -0
- data/test/functional/weight.yml +152 -0
- data/test/pkg-suite.yml +8 -0
- data/test/pkg/cmdline.yml +80 -0
- data/test/pool-suite.yml +8 -0
- data/test/pool/base.yml +12 -0
- data/test/pool/pool.yml +25 -0
- data/test/ruby-suite.rb +10 -0
- data/test/ruby-suite.yml +5 -0
- data/test/ruby/base.rb +119 -0
- data/test/ruby/iterate.rb +21 -0
- data/test/ruby/wc.rb +43 -0
- data/test/unit-suite.yml +10 -0
- data/test/unit/dumpers/path_test.rb +46 -0
- data/test/unit/dumpers/xml_test.rb +65 -0
- data/test/unit/dumpers/yaml_test.rb +65 -0
- data/test/unit/filters/buffer_test.rb +168 -0
- data/test/unit/filters/keep_skip_based_test.rb +46 -0
- data/test/unit/filters/node_cut_test.rb +72 -0
- data/test/unit/filters/rpath_filter_test.rb +191 -0
- data/test/unit/filters/text_filter_test.rb +46 -0
- data/test/unit/filters_test.rb +119 -0
- data/test/unit/logger/section_node_test.rb +120 -0
- data/test/unit/logger/severity_test.rb +37 -0
- data/test/unit/logger/to_uttk_log_test.rb +113 -0
- data/test/unit/logger/verbosity_test.rb +44 -0
- data/test/unit/logger_test.rb +203 -0
- data/test/unit/strategies/suite_test.rb +151 -0
- data/test/uttk-check.yml +8 -0
- data/test/uttk-distcheck.yml +18 -0
- metadata +399 -0
@@ -0,0 +1,37 @@
|
|
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/severity_test.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
|
5
|
+
|
6
|
+
|
7
|
+
test_section __FILE__ do
|
8
|
+
|
9
|
+
module Uttk
|
10
|
+
|
11
|
+
class Logger
|
12
|
+
|
13
|
+
class SeverityTest < ::Test::Unit::TestCase
|
14
|
+
|
15
|
+
def test_unshift
|
16
|
+
assert_equal(Severity::DEBUG, Severity.lower)
|
17
|
+
Severity.unshift('DEBUG1')
|
18
|
+
assert_equal(Severity::DEBUG1, Severity.lower)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_push
|
22
|
+
assert_equal(Severity::UNKNOWN, Severity.higher)
|
23
|
+
Severity.push('UNKNOWN1')
|
24
|
+
assert_equal(Severity::UNKNOWN1, Severity.higher)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_label
|
28
|
+
assert_equal('WARN', Severity.label(3))
|
29
|
+
end
|
30
|
+
|
31
|
+
end # class SeverityTest
|
32
|
+
|
33
|
+
end # class Logger
|
34
|
+
|
35
|
+
end # module Uttk
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
+
# License:: LGPL
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/test/unit/logger/to_uttk_log_test.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
|
5
|
+
|
6
|
+
test_section __FILE__ do
|
7
|
+
|
8
|
+
module Uttk
|
9
|
+
|
10
|
+
class ToUttkLogTest < Test::Unit::TestCase
|
11
|
+
include Mocks::Assertions
|
12
|
+
|
13
|
+
@@ordered = { :ordered => true }.freeze
|
14
|
+
|
15
|
+
def setup
|
16
|
+
self.mock_object = Mocks::Observer.new
|
17
|
+
@l = Logger.new(mock_object)
|
18
|
+
|
19
|
+
@very_simple_tree_with_ohash =
|
20
|
+
{
|
21
|
+
:contents => OHash[:test1, :cmd1, :test2, :cmd2]
|
22
|
+
}
|
23
|
+
@very_simple_tree_with_array =
|
24
|
+
{
|
25
|
+
:contents => [{:test1 => :cmd1}, {:test2 => :cmd2}]
|
26
|
+
}
|
27
|
+
@very_simple_notifs = Logger.make_notifs [
|
28
|
+
[[[:contents, {:ordered=>true}], :test1], :cmd1],
|
29
|
+
[[[:contents, {:ordered=>true}], :test2], :cmd2]]
|
30
|
+
|
31
|
+
@simple_tree_with_ohash =
|
32
|
+
{
|
33
|
+
:contents => OHash[:test1, { :cmd => [:a] }]
|
34
|
+
}
|
35
|
+
@simple_notifs = Logger.make_notifs [
|
36
|
+
[[[:contents, {:ordered=>true}], :test1, :cmd], [:a]]]
|
37
|
+
|
38
|
+
@complex_tree_with_array =
|
39
|
+
{
|
40
|
+
:root =>
|
41
|
+
{
|
42
|
+
:strategy => [ :cmd ],
|
43
|
+
:contents =>
|
44
|
+
[
|
45
|
+
{
|
46
|
+
:test1 =>
|
47
|
+
{
|
48
|
+
:cmd => [:a],
|
49
|
+
:exit => [:aa]
|
50
|
+
},
|
51
|
+
},
|
52
|
+
{
|
53
|
+
:test2 =>
|
54
|
+
{
|
55
|
+
:cmd => :b,
|
56
|
+
:exit => :bb
|
57
|
+
},
|
58
|
+
}
|
59
|
+
]
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
@complex_tree_with_ohash =
|
64
|
+
{
|
65
|
+
:root =>
|
66
|
+
{
|
67
|
+
:strategy => :cmd,
|
68
|
+
:contents =>
|
69
|
+
OHash[
|
70
|
+
:test1, { :cmd => [:a], :exit=> [:aa] },
|
71
|
+
:test2, { :cmd => :b, :exit => :bb }
|
72
|
+
]
|
73
|
+
}
|
74
|
+
}
|
75
|
+
@complex_notifs = Logger.make_notifs [
|
76
|
+
[[[:root, {:type=>:cmd}], [:contents, {:ordered=>true}], :test1, :cmd], [:a]],
|
77
|
+
[[[:root, {:type=>:cmd}], [:contents, {:ordered=>true}], :test1, :exit], [:aa]],
|
78
|
+
[[[:root, {:type=>:cmd}], [:contents, {:ordered=>true}], :test2, :cmd], :b],
|
79
|
+
[[[:root, {:type=>:cmd}], [:contents, {:ordered=>true}], :test2, :exit], :bb]]
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_very_simple_with_ohash
|
83
|
+
@l << @very_simple_tree_with_ohash
|
84
|
+
assert_mock @very_simple_notifs
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_very_simple_with_array
|
88
|
+
@l << @very_simple_tree_with_array
|
89
|
+
assert_mock @very_simple_notifs
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_simple
|
93
|
+
@l << @simple_tree_with_ohash
|
94
|
+
assert_mock @simple_notifs
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_complex
|
98
|
+
@l << @complex_tree_with_ohash
|
99
|
+
args = mock_object.mock_args
|
100
|
+
@complex_notifs.each do |notif|
|
101
|
+
assert args.include?(notif), "args.include?(#{notif.inspect})"
|
102
|
+
end
|
103
|
+
test1 = []
|
104
|
+
args.each_with_index { |notif, i| test1 << i if notif.include? :test1 }
|
105
|
+
max_test1 = test1.max
|
106
|
+
args.each_with_index { |notif, i| assert(i > max_test1) if notif.include? :test2 }
|
107
|
+
end
|
108
|
+
|
109
|
+
end # class LoggerTest
|
110
|
+
|
111
|
+
end # module Uttk
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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/verbosity_test.rb 21975 2006-02-19T22:24:11.182512Z pouillar $
|
5
|
+
|
6
|
+
|
7
|
+
test_section __FILE__ do
|
8
|
+
|
9
|
+
module Uttk
|
10
|
+
|
11
|
+
class Logger
|
12
|
+
|
13
|
+
class VerbosityTest < ::Test::Unit::TestCase
|
14
|
+
|
15
|
+
class VerbosityEx < Verbosity
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_self_verbosity
|
19
|
+
assert_raises(ArgumentError) do
|
20
|
+
VerbosityEx.verbosity :foo, 42
|
21
|
+
end
|
22
|
+
assert_raises(ArgumentError) do
|
23
|
+
VerbosityEx.verbosity :sections, 0
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_self_level_fields
|
28
|
+
assert_equal([], Verbosity.level_fields(0))
|
29
|
+
assert_equal([:severity_level], Verbosity.level_fields(1))
|
30
|
+
assert_equal([:sections], Verbosity.level_fields(2))
|
31
|
+
assert_equal([:date], Verbosity.level_fields(3))
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_higher_level
|
35
|
+
assert_equal(3, VerbosityEx.higher_level)
|
36
|
+
end
|
37
|
+
|
38
|
+
end # class VerbosityTest
|
39
|
+
|
40
|
+
end # class Logger
|
41
|
+
|
42
|
+
end # module Uttk
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,203 @@
|
|
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_test.rb 22057 2006-02-20T21:40:27.185401Z pouillar $
|
5
|
+
|
6
|
+
|
7
|
+
test_section __FILE__ do
|
8
|
+
|
9
|
+
module Uttk
|
10
|
+
|
11
|
+
class LoggerTest < Test::Unit::TestCase
|
12
|
+
include Mocks::Assertions
|
13
|
+
|
14
|
+
def setup
|
15
|
+
self.mock_object = Mocks::Observer.new
|
16
|
+
@l = Logger.new(mock_object)
|
17
|
+
end
|
18
|
+
|
19
|
+
def assert_path ( ref )
|
20
|
+
assert_equal(ref, @l.path.to_s)
|
21
|
+
end
|
22
|
+
|
23
|
+
def assert_logger_mock ( *notifs )
|
24
|
+
assert_mock(*Logger.make_notifs(notifs))
|
25
|
+
end
|
26
|
+
|
27
|
+
@@ordered = { :ordered => true }.freeze
|
28
|
+
|
29
|
+
def test_path
|
30
|
+
assert_path '/'
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_new_leaf
|
34
|
+
assert_logger_mock
|
35
|
+
assert_path '/'
|
36
|
+
@l.new_leaf('foo')
|
37
|
+
assert_logger_mock [[], "foo"]
|
38
|
+
assert_path '/'
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_new_node
|
42
|
+
@l.new_node('foo') do
|
43
|
+
assert_logger_mock
|
44
|
+
@l.new_leaf('leaf_bar')
|
45
|
+
assert_path '/foo'
|
46
|
+
assert_logger_mock [[:foo], 'leaf_bar']
|
47
|
+
end
|
48
|
+
assert_mock_size 1
|
49
|
+
@l.close
|
50
|
+
assert_last_mock :close
|
51
|
+
assert_mock_size 2
|
52
|
+
assert_path '/'
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_log__basic
|
56
|
+
@l.log { 'foo' }
|
57
|
+
assert_logger_mock [[:UNKNOWN], 'foo']
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_severity_level
|
61
|
+
@l.severity_level = Logger::Severity::ERROR
|
62
|
+
@l.log(Logger::Severity::INFO) { 'foo' }
|
63
|
+
assert_logger_mock
|
64
|
+
@l.log(Logger::Severity::ERROR) { 'foo' }
|
65
|
+
assert_logger_mock [[:ERROR], 'foo']
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_block_returning_nil_with_severity_level
|
69
|
+
@l.severity_level = Logger::Severity::ERROR
|
70
|
+
x = 0
|
71
|
+
@l.log(Logger::Severity::INFO) { x = 1 }
|
72
|
+
assert_equal(0, x)
|
73
|
+
@l.log(Logger::Severity::ERROR) { x = 2 ; nil }
|
74
|
+
assert_logger_mock
|
75
|
+
assert_equal(2, x)
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_verbosity_level__simple
|
79
|
+
assert_raises(ArgumentError) { @l.verbosity_level = -1 }
|
80
|
+
@l.verbosity_level = 1
|
81
|
+
@l.log { 'foo' }
|
82
|
+
assert_logger_mock [[:UNKNOWN, :severity_level], 'UNKNOWN'],
|
83
|
+
[[:UNKNOWN, :message], 'foo']
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_verbosity_level__complex
|
87
|
+
assert_raises(ArgumentError) { @l.verbosity_level = -1 }
|
88
|
+
@l.verbosity_level = 2
|
89
|
+
@l.log { 'foo' }
|
90
|
+
assert_logger_mock [[:UNKNOWN, :severity_level], 'UNKNOWN'],
|
91
|
+
[[:UNKNOWN, :sections], []],
|
92
|
+
[[:UNKNOWN, :message], 'foo']
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_active_section
|
96
|
+
@l.section_tree.push(Logger::SectionNode.new('foo'),
|
97
|
+
Logger::SectionNode.new('bar',
|
98
|
+
Logger::SectionNode.new('baz'),
|
99
|
+
Logger::SectionNode.new('goo')))
|
100
|
+
%w(all foo bar baz goo).each do |s|
|
101
|
+
assert(! @l.active_section?(s), "section active #{s}")
|
102
|
+
end
|
103
|
+
@l.active_section(true, 'foo', 'baz')
|
104
|
+
expected_section = %w(all foo bar baz)
|
105
|
+
expected_section.each do |s|
|
106
|
+
assert(@l.active_section?(s), "section not active #{s}")
|
107
|
+
end
|
108
|
+
@l.severity_level = Logger::Severity::WARN
|
109
|
+
@l.verbosity_level = 2
|
110
|
+
@l.log(Logger::Severity::ERROR, 'foo', 'baz') { 'foo' }
|
111
|
+
assert_logger_mock [[:ERROR, :severity_level], 'ERROR'],
|
112
|
+
[[:ERROR, :sections], ['foo', 'baz']],
|
113
|
+
[[:ERROR, :message], 'foo']
|
114
|
+
mock_object.mock_clear
|
115
|
+
@l.log(Logger::Severity::FATAL, 'all') { 'toto' }
|
116
|
+
assert_logger_mock [[:FATAL_1, :severity_level], 'FATAL'],
|
117
|
+
[[:FATAL_1, :sections], ['all']],
|
118
|
+
[[:FATAL_1, :message], 'toto']
|
119
|
+
mock_object.mock_clear
|
120
|
+
@l.log(Logger::Severity::FATAL, 'goo') { 'titi' }
|
121
|
+
assert_logger_mock
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_make_log_arguments
|
125
|
+
assert_equal([Logger::Severity::FATAL],
|
126
|
+
@l.make_log_arguments('fatal'))
|
127
|
+
assert_equal([Logger::Severity::ERROR],
|
128
|
+
@l.make_log_arguments('erROr'))
|
129
|
+
assert_raises(NameError) { @l.make_log_arguments('foo') }
|
130
|
+
assert_equal([Logger::Severity::WARN, 'all', 'goo', 'foo', 'baz'],
|
131
|
+
@l.make_log_arguments('warN_all_goo_foo_baz'))
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_sugar
|
135
|
+
@l.section_tree.push(Logger::SectionNode.new('foo'),
|
136
|
+
Logger::SectionNode.new('bar',
|
137
|
+
Logger::SectionNode.new('baz'),
|
138
|
+
Logger::SectionNode.new('goo')))
|
139
|
+
%w(all foo bar baz goo).each do |s|
|
140
|
+
assert(! @l.active_section?(s), "section active #{s}")
|
141
|
+
end
|
142
|
+
@l.active_section(true, 'foo', 'baz')
|
143
|
+
expected_section = %w(all foo bar baz)
|
144
|
+
expected_section.each do |s|
|
145
|
+
assert(@l.active_section?(s), "section not active #{s}")
|
146
|
+
end
|
147
|
+
@l.severity_level = Logger::Severity::WARN
|
148
|
+
@l.verbosity_level = 2
|
149
|
+
@l.error_foo_baz{'foo'}
|
150
|
+
assert_logger_mock [[:ERROR, :severity_level], 'ERROR'],
|
151
|
+
[[:ERROR, :sections], ['foo', 'baz']],
|
152
|
+
[[:ERROR, :message], 'foo']
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_severity_level_writer
|
156
|
+
high_bad_value = Logger::Severity.higher + 1
|
157
|
+
assert_raises(ArgumentError) { @l.severity_level = high_bad_value }
|
158
|
+
low_bad_value = Logger::Severity.lower - 1
|
159
|
+
assert_raises(ArgumentError) { @l.severity_level = low_bad_value }
|
160
|
+
good_value = Logger::Severity.lower + 1
|
161
|
+
assert_nothing_raised { @l.severity_level = good_value }
|
162
|
+
assert_equal(good_value, @l.severity_level)
|
163
|
+
assert_raises(NameError) { @l.severity_level = 'toto' }
|
164
|
+
assert_nothing_raised { @l.severity_level = 'warn' }
|
165
|
+
assert_equal(Logger::Severity::WARN, @l.severity_level)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_log_complex_structure
|
169
|
+
hsh = OHash.new
|
170
|
+
hsh['foo'] = :bar
|
171
|
+
hsh[:goo] = { :bar => 42 }
|
172
|
+
hsh[:qux] = [42, 43]
|
173
|
+
|
174
|
+
in_ref =
|
175
|
+
{
|
176
|
+
:root =>
|
177
|
+
{
|
178
|
+
:rest => [
|
179
|
+
{ :'3' => hsh },
|
180
|
+
{ 'fu' => 'yu' }
|
181
|
+
]
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
out_ref =
|
187
|
+
[
|
188
|
+
[[:root, [:rest, {:ordered=>true}], [:'3', {:ordered=>true}], :foo], :bar],
|
189
|
+
[[:root, [:rest, {:ordered=>true}], [:'3', {:ordered=>true}], :goo, :bar], 42],
|
190
|
+
[[:root, [:rest, {:ordered=>true}], [:'3', {:ordered=>true}], :qux], [42, 43]],
|
191
|
+
[[:root, [:rest, {:ordered=>true}], :fu], "yu"]
|
192
|
+
]
|
193
|
+
|
194
|
+
@l << in_ref
|
195
|
+
|
196
|
+
assert_logger_mock(*out_ref)
|
197
|
+
end
|
198
|
+
|
199
|
+
end # class LoggerTest
|
200
|
+
|
201
|
+
end # module Uttk
|
202
|
+
|
203
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
3
|
+
# License:: LGPL
|
4
|
+
# $Id$
|
5
|
+
|
6
|
+
|
7
|
+
test_section __FILE__ do
|
8
|
+
|
9
|
+
module Uttk
|
10
|
+
|
11
|
+
module Strategies
|
12
|
+
|
13
|
+
class SuiteTest < ::Test::Unit::TestCase
|
14
|
+
|
15
|
+
#
|
16
|
+
# Tests
|
17
|
+
#
|
18
|
+
|
19
|
+
def test_example
|
20
|
+
output_ref = %q{
|
21
|
+
|---
|
22
|
+
|A set of tests: !S::Suite
|
23
|
+
| attributes:
|
24
|
+
| strategy: Uttk::Strategies::Cmd
|
25
|
+
| exit: 0
|
26
|
+
| contents:
|
27
|
+
| - I'm suppose to pass 1: !S::Cmd
|
28
|
+
| command: 'true'
|
29
|
+
| running: 'true'
|
30
|
+
| status: PASS
|
31
|
+
| - I'm suppose to fail 2: !S::Cmd
|
32
|
+
| weight: -1
|
33
|
+
| command: 'false'
|
34
|
+
| running: 'false'
|
35
|
+
| my_exit: 1
|
36
|
+
| status: FAIL
|
37
|
+
| reason: wrong exit value
|
38
|
+
| - I'm suppose to pass 3: !S::Cmd
|
39
|
+
| command: 'false'
|
40
|
+
| running: 'false'
|
41
|
+
| status: PASS
|
42
|
+
| status: PASS
|
43
|
+
|}.head_cut!
|
44
|
+
|
45
|
+
output_ref2 = %q{
|
46
|
+
|A set of tests: !S::Suite
|
47
|
+
| attributes:
|
48
|
+
| strategy: Uttk::Strategies::Cmd
|
49
|
+
| exit: 0
|
50
|
+
| contents:
|
51
|
+
| - I'm suppose to pass 4: !S::Cmd
|
52
|
+
| command: 'true'
|
53
|
+
| running: 'true'
|
54
|
+
| status: PASS
|
55
|
+
| - I'm suppose to fail 5: !S::Cmd
|
56
|
+
| weight: -1
|
57
|
+
| command: 'false'
|
58
|
+
| running: 'false'
|
59
|
+
| my_exit: 1
|
60
|
+
| status: FAIL
|
61
|
+
| reason: wrong exit value
|
62
|
+
| - I'm suppose to pass 6: !S::Cmd
|
63
|
+
| command: 'false'
|
64
|
+
| running: 'false'
|
65
|
+
| status: PASS
|
66
|
+
| status: PASS
|
67
|
+
|}.head_cut!
|
68
|
+
|
69
|
+
# Dynamically fix the reference output for ruby 1.8.2 since there is a
|
70
|
+
# strange bug with Yaml and/or Dumpers::Yaml
|
71
|
+
# But it's ok with ruby 1.8.3
|
72
|
+
unless HAVE_YAML_TAGURI
|
73
|
+
output_ref.gsub!(/'(true|false)'/, '\1')
|
74
|
+
output_ref2.gsub!(/'(true|false)'/, '\1')
|
75
|
+
end
|
76
|
+
|
77
|
+
TempPath.new do |tmp|
|
78
|
+
log = Logger.new(Dumpers::Yaml.new(tmp.open('w')))
|
79
|
+
log.severity_level = Logger::Severity::INFO
|
80
|
+
log.verbosity_level = 0
|
81
|
+
loader = Loaders::Yaml.new
|
82
|
+
symtbl = SymTbl.new
|
83
|
+
symtbl[:loader] = loader
|
84
|
+
symtbl[:log] = log
|
85
|
+
aDoc = {
|
86
|
+
:name => 'A set of tests',
|
87
|
+
:strategy => Strategies::Suite,
|
88
|
+
:symtbl => symtbl,
|
89
|
+
:wclass => Weights::WFloat,
|
90
|
+
:attributes => {
|
91
|
+
:strategy => Strategies::Cmd,
|
92
|
+
:exit => 0
|
93
|
+
},
|
94
|
+
:contents => OHash[
|
95
|
+
"I'm suppose to pass 1", { :command => 'true' },
|
96
|
+
"I'm suppose to fail 2", { :command => 'false', :weight => -1 },
|
97
|
+
"I'm suppose to pass 3", { :command => 'false', :exit => 1 }
|
98
|
+
]
|
99
|
+
}
|
100
|
+
aSuite = aDoc.testify(:loader => loader)
|
101
|
+
aSuite.run
|
102
|
+
# mini_diff(output_ref, tmp.read)
|
103
|
+
assert_nothing_raised { @my = YAML::load(tmp.read) }
|
104
|
+
assert_equal(YAML::load(output_ref), @my)
|
105
|
+
|
106
|
+
aSuite = Strategies::Suite.new
|
107
|
+
aSuite.name = 'A set of tests'
|
108
|
+
aSuite.symtbl = symtbl
|
109
|
+
aSuite.wclass = Weights::WFloat
|
110
|
+
aSuite.strategyclass = Strategies::Cmd
|
111
|
+
aSuite.exit = 0 # a sugar when its unambiguous.
|
112
|
+
t1 = aSuite.create
|
113
|
+
t1.name = "I'm suppose to pass 4"
|
114
|
+
t1.command = 'true'
|
115
|
+
aSuite.create(:name => "I'm suppose to fail 5",
|
116
|
+
:command => 'false',
|
117
|
+
:weight => -1)
|
118
|
+
|
119
|
+
io = StringIO.new
|
120
|
+
io << "|---
|
121
|
+
|I'm suppose to pass 6:
|
122
|
+
| command: 'false'
|
123
|
+
| exit: 1".gsub(/^\s*\|/, '')
|
124
|
+
|
125
|
+
io.rewind
|
126
|
+
aSuite.create(io)
|
127
|
+
|
128
|
+
aSuite.run
|
129
|
+
# mini_diff(output_ref, tmp.read)
|
130
|
+
assert_nothing_raised { @my = YAML::load(tmp.read) }
|
131
|
+
assert_equal(YAML::load(output_ref2), @my)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def mini_diff ( a, b )
|
136
|
+
a = a.split(/\n/)
|
137
|
+
b = b.split(/\n/)
|
138
|
+
d = a.zip(b).delete_if { |x, y| x == y }
|
139
|
+
d.each do |x, y|
|
140
|
+
puts "-#{x}"
|
141
|
+
puts "+#{y}"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
end # class SuiteTest
|
146
|
+
|
147
|
+
end # module Strategies
|
148
|
+
|
149
|
+
end # module Uttk
|
150
|
+
|
151
|
+
end
|