uttk 0.3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +36 -0
- data/COPYING +18 -0
- data/ChangeLog +7673 -0
- data/GUIDELINES +86 -0
- data/LGPL +504 -0
- data/NEWS +158 -0
- data/NORM +137 -0
- data/README +180 -0
- data/Rakefile +8 -0
- data/SPEC.gemspec +15 -0
- data/SPEC.yml +60 -0
- data/TODO +23 -0
- data/TODO.old +31 -0
- data/VERSION +5 -0
- data/bin/getopts/uttk.rb +390 -0
- data/bin/uttk +188 -0
- data/bin/uttk-unit +125 -0
- data/lib/uttk.rb +288 -0
- data/lib/uttk/dumpers/Basic.rb +23 -0
- data/lib/uttk/dumpers/BasicColor.rb +35 -0
- data/lib/uttk/dumpers/Dumper.rb +77 -0
- data/lib/uttk/dumpers/Html.rb +271 -0
- data/lib/uttk/dumpers/Path.rb +24 -0
- data/lib/uttk/dumpers/Xml.rb +88 -0
- data/lib/uttk/dumpers/Yaml.rb +138 -0
- data/lib/uttk/filters.rb +128 -0
- data/lib/uttk/filters/Buffer.rb +119 -0
- data/lib/uttk/filters/Compact.rb +75 -0
- data/lib/uttk/filters/Default.rb +27 -0
- data/lib/uttk/filters/DefaultColor.rb +27 -0
- data/lib/uttk/filters/Filter.rb +53 -0
- data/lib/uttk/filters/Id.rb +30 -0
- data/lib/uttk/filters/JustStatus.rb +25 -0
- data/lib/uttk/filters/KeepSkipBased.rb +38 -0
- data/lib/uttk/filters/NodeCut.rb +97 -0
- data/lib/uttk/filters/RPathFilter.rb +134 -0
- data/lib/uttk/filters/Saver.rb +53 -0
- data/lib/uttk/filters/TextFilter.rb +69 -0
- data/lib/uttk/generators/dumper_generator.rb +28 -0
- data/lib/uttk/generators/filter_generator.rb +28 -0
- data/lib/uttk/generators/generator.rb +86 -0
- data/lib/uttk/generators/generator_generator.rb +26 -0
- data/lib/uttk/generators/loader_generator.rb +28 -0
- data/lib/uttk/generators/path_filter_generator.rb +28 -0
- data/lib/uttk/generators/strategy_generator.rb +28 -0
- data/lib/uttk/generators/templates/dumper.rb +50 -0
- data/lib/uttk/generators/templates/filter.rb +50 -0
- data/lib/uttk/generators/templates/generator.rb +28 -0
- data/lib/uttk/generators/templates/loader.rb +26 -0
- data/lib/uttk/generators/templates/path_filter.rb +28 -0
- data/lib/uttk/generators/templates/strategy.rb +59 -0
- data/lib/uttk/generators/templates/strategy.yml +28 -0
- data/lib/uttk/generators/templates/unit_test.rb +46 -0
- data/lib/uttk/loaders/Loader.rb +180 -0
- data/lib/uttk/loaders/Ruby.rb +28 -0
- data/lib/uttk/loaders/Yaml.rb +98 -0
- data/lib/uttk/logger.rb +306 -0
- data/lib/uttk/logger/backend.rb +170 -0
- data/lib/uttk/logger/path.rb +202 -0
- data/lib/uttk/logger/section_node.rb +214 -0
- data/lib/uttk/logger/severity.rb +63 -0
- data/lib/uttk/logger/to_uttk_log.rb +127 -0
- data/lib/uttk/logger/verbosity.rb +61 -0
- data/lib/uttk/logger_factory.rb +55 -0
- data/lib/uttk/path_filters/ColorStatus.rb +57 -0
- data/lib/uttk/path_filters/PathFilter.rb +27 -0
- data/lib/uttk/path_filters/RemoveTypes.rb +25 -0
- data/lib/uttk/status.rb +146 -0
- data/lib/uttk/strategies/Abort.rb +24 -0
- data/lib/uttk/strategies/Assert.rb +44 -0
- data/lib/uttk/strategies/Authors.rb +45 -0
- data/lib/uttk/strategies/Block.rb +113 -0
- data/lib/uttk/strategies/Bootstrap.rb +55 -0
- data/lib/uttk/strategies/Checkout.rb +64 -0
- data/lib/uttk/strategies/Clean.rb +29 -0
- data/lib/uttk/strategies/Cmd.rb +60 -0
- data/lib/uttk/strategies/CmdBase.rb +130 -0
- data/lib/uttk/strategies/Collection.rb +158 -0
- data/lib/uttk/strategies/Compile.rb +59 -0
- data/lib/uttk/strategies/Composite.rb +201 -0
- data/lib/uttk/strategies/Composite/contents_eval.rb +40 -0
- data/lib/uttk/strategies/Configure.rb +66 -0
- data/lib/uttk/strategies/Error.rb +23 -0
- data/lib/uttk/strategies/Fail.rb +26 -0
- data/lib/uttk/strategies/IOBased.rb +159 -0
- data/lib/uttk/strategies/Import.rb +60 -0
- data/lib/uttk/strategies/Iterate.rb +139 -0
- data/lib/uttk/strategies/JUnit.rb +205 -0
- data/lib/uttk/strategies/KillAll.rb +62 -0
- data/lib/uttk/strategies/Make.rb +94 -0
- data/lib/uttk/strategies/Package.rb +129 -0
- data/lib/uttk/strategies/PackageCollection.rb +78 -0
- data/lib/uttk/strategies/Pass.rb +24 -0
- data/lib/uttk/strategies/Pool.rb +104 -0
- data/lib/uttk/strategies/ProbabilityThreshold.rb +46 -0
- data/lib/uttk/strategies/Proxy.rb +42 -0
- data/lib/uttk/strategies/RMatch.rb +92 -0
- data/lib/uttk/strategies/RUnit.rb +132 -0
- data/lib/uttk/strategies/SignalCmd.rb +85 -0
- data/lib/uttk/strategies/Sleep.rb +36 -0
- data/lib/uttk/strategies/SqlQuery.rb +120 -0
- data/lib/uttk/strategies/Strategy.rb +683 -0
- data/lib/uttk/strategies/Stub.rb +37 -0
- data/lib/uttk/strategies/SubCmd.rb +77 -0
- data/lib/uttk/strategies/Suite.rb +71 -0
- data/lib/uttk/strategies/Test.rb +89 -0
- data/lib/uttk/streams.rb +69 -0
- data/lib/uttk/streams/Diff.rb +60 -0
- data/lib/uttk/streams/HexaDiff.rb +35 -0
- data/lib/uttk/streams/Stream.rb +76 -0
- data/lib/uttk/weights.rb +17 -0
- data/lib/uttk/weights/WExpr.rb +68 -0
- data/lib/uttk/weights/WFloat.rb +23 -0
- data/lib/uttk/weights/WMin.rb +22 -0
- data/lib/uttk/weights/Weight.rb +105 -0
- data/lib/www/javascripts/uttk.js +185 -0
- data/misc/expandtab.rb +29 -0
- data/misc/header.rb +44 -0
- data/misc/renaming +57 -0
- data/misc/textile_compiler +194 -0
- data/misc/uttk-grep.sh +8 -0
- data/misc/uttk-line-count.rb +143 -0
- data/test/examples-suite.yml +8 -0
- data/test/examples/README +68 -0
- data/test/examples/basic.rb +10 -0
- data/test/examples/basic.yml +9 -0
- data/test/examples/cache/cache_and_fatal.yml +5 -0
- data/test/examples/cache/simple.yml +30 -0
- data/test/examples/sql/basic.yml +24 -0
- data/test/examples/students-suite.yml +9 -0
- data/test/examples/students/ball.yml +11 -0
- data/test/examples/students/glob_stud.yml +20 -0
- data/test/examples/students/mini-lib.yml +61 -0
- data/test/examples/students/pool_stud.yml +31 -0
- data/test/examples/students/stud.yml +21 -0
- data/test/fixtures/ball/20040804-exam_a1-zapngo-tessar_m.tar.gz +0 -0
- data/test/fixtures/ball/Makefile +24 -0
- data/test/fixtures/ball/bar_p-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/bar_p-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/bar_p-mini-lib/my_strlen.c +13 -0
- data/test/fixtures/ball/foo_s-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/foo_s-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/foo_s-mini-lib/configure +2 -0
- data/test/fixtures/ball/foo_s-mini-lib/my_strlen.c +10 -0
- data/test/fixtures/ball/hello.tar.bz2 +0 -0
- data/test/fixtures/ball/hello.tar.gz +0 -0
- data/test/fixtures/ball/hello/Makefile +14 -0
- data/test/fixtures/ball/hello/hello.c +7 -0
- data/test/fixtures/ball/jack-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/jack-exit/Makefile +14 -0
- data/test/fixtures/ball/jack-exit/exit.c +16 -0
- data/test/fixtures/ball/joe-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/joe-exit/Makefile +14 -0
- data/test/fixtures/ball/joe-exit/exit.c +8 -0
- data/test/fixtures/ball/joe_i-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/joe_i-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/joe_i-mini-lib/configure +2 -0
- data/test/fixtures/ball/joe_i-mini-lib/my_strlen.c +10 -0
- data/test/fixtures/ball/john-exit.tar.bz2 +0 -0
- data/test/fixtures/ball/john-exit/Makefile +14 -0
- data/test/fixtures/ball/john-exit/exit.c +6 -0
- data/test/fixtures/ball/qux_j-mini-lib.tar.bz2 +0 -0
- data/test/fixtures/ball/qux_j-mini-lib/Makefile +20 -0
- data/test/fixtures/ball/qux_j-mini-lib/my_strlen.c +12 -0
- data/test/fixtures/binaries/segv +0 -0
- data/test/fixtures/binaries/segv.c +10 -0
- data/test/fixtures/binaries/segv.rb +2 -0
- data/test/fixtures/demo/command-tutorial/steps/1/check.yml +5 -0
- data/test/fixtures/demo/command-tutorial/steps/1/pluralizer.rb +10 -0
- data/test/fixtures/demo/command-tutorial/steps/2/bad_check.yml +7 -0
- data/test/fixtures/demo/command-tutorial/steps/2/check.yml +7 -0
- data/test/fixtures/demo/command-tutorial/steps/2/pluralizer.rb +10 -0
- data/test/fixtures/demo/command-tutorial/steps/3.1/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/3/check.yml +14 -0
- data/test/fixtures/demo/command-tutorial/steps/4.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/4.1/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/4/check.yml +12 -0
- data/test/fixtures/demo/command-tutorial/steps/4/pluralizer.rb +12 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/check.yml +17 -0
- data/test/fixtures/demo/command-tutorial/steps/5.1/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/5/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/5/check.yml +16 -0
- data/test/fixtures/demo/command-tutorial/steps/5/pluralizer.rb +16 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/check.yml +22 -0
- data/test/fixtures/demo/command-tutorial/steps/6.1/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/6/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/6/check.yml +21 -0
- data/test/fixtures/demo/command-tutorial/steps/6/pluralizer.rb +17 -0
- data/test/fixtures/demo/command-tutorial/steps/7/bird.txt +1 -0
- data/test/fixtures/demo/command-tutorial/steps/7/check.yml +22 -0
- data/test/fixtures/demo/command-tutorial/steps/7/pluralizer.rb +17 -0
- data/test/fixtures/demo/filter-tutorial/check.yml +20 -0
- data/test/fixtures/demo/filter-tutorial/filters/CutSkip100.rb +19 -0
- data/test/fixtures/demo/filter-tutorial/pluralizer.rb +17 -0
- data/test/fixtures/java/unit/MultiRight/Foo/Foo.java +11 -0
- data/test/fixtures/java/unit/MultiRight/Foo/FooTest.java +15 -0
- data/test/fixtures/java/unit/MultiRight/MultiRight.java +13 -0
- data/test/fixtures/java/unit/MultiRight/MultiRightTest.java +12 -0
- data/test/fixtures/java/unit/MultiRight/bar/Bar.java +11 -0
- data/test/fixtures/java/unit/MultiRight/bar/BarTest.java +21 -0
- data/test/fixtures/java/unit/MultiRight/build.sh +7 -0
- data/test/fixtures/java/unit/SimpleException/SimpleExceptionTest.java +11 -0
- data/test/fixtures/java/unit/SimpleException/build.sh +4 -0
- data/test/fixtures/java/unit/build.sh +9 -0
- data/test/fixtures/java/unit/multibar.yml +6 -0
- data/test/fixtures/java/unit/multifoo.yml +6 -0
- data/test/fixtures/java/unit/multiright.yml +8 -0
- data/test/fixtures/java/unit/simple_exception.yml +6 -0
- data/test/fixtures/mini-lib/Makefile +9 -0
- data/test/fixtures/mini-lib/strlen.c +15 -0
- data/test/fixtures/package/pkg_foo.tar.gz +0 -0
- data/test/fixtures/package/pkg_foo/Makefile +20 -0
- data/test/fixtures/package/pkg_foo/bootstrap +3 -0
- data/test/fixtures/package/pkg_foo/configure +3 -0
- data/test/fixtures/package/pkg_foo/foo.sh +2 -0
- data/test/fixtures/text/1.txt +4 -0
- data/test/fixtures/unit/bad.rb +26 -0
- data/test/fixtures/unit/error.rb +6 -0
- data/test/fixtures/unit/good.rb +26 -0
- data/test/functional-suite.yml +10 -0
- data/test/functional/author.yml +11 -0
- data/test/functional/base.yml +119 -0
- data/test/functional/base_pool.yml +13 -0
- data/test/functional/block.yml +13 -0
- data/test/functional/cat.yml +16 -0
- data/test/functional/cmd.yml +17 -0
- data/test/functional/diff.yml +27 -0
- data/test/functional/env_cmd.yml +53 -0
- data/test/functional/exit.yml +15 -0
- data/test/functional/fatal.yml +23 -0
- data/test/functional/glob.yml +11 -0
- data/test/functional/hexa-diff.yml +25 -0
- data/test/functional/import.yml +41 -0
- data/test/functional/iterate.yml +99 -0
- data/test/functional/killall.yml +31 -0
- data/test/functional/pkg.yml +14 -0
- data/test/functional/probability_threshold.yml +35 -0
- data/test/functional/r_unit.yml +26 -0
- data/test/functional/rmatch.yml +122 -0
- data/test/functional/signal_cmd.yml +22 -0
- data/test/functional/sub.yml +15 -0
- data/test/functional/test.yml +25 -0
- data/test/functional/timeout.yml +20 -0
- data/test/functional/wc.yml +26 -0
- data/test/functional/weight.yml +152 -0
- data/test/pkg-suite.yml +8 -0
- data/test/pkg/cmdline.yml +80 -0
- data/test/pool-suite.yml +8 -0
- data/test/pool/base.yml +12 -0
- data/test/pool/pool.yml +25 -0
- data/test/ruby-suite.rb +10 -0
- data/test/ruby-suite.yml +5 -0
- data/test/ruby/base.rb +119 -0
- data/test/ruby/iterate.rb +21 -0
- data/test/ruby/wc.rb +43 -0
- data/test/unit-suite.yml +10 -0
- data/test/unit/dumpers/path_test.rb +46 -0
- data/test/unit/dumpers/xml_test.rb +65 -0
- data/test/unit/dumpers/yaml_test.rb +65 -0
- data/test/unit/filters/buffer_test.rb +168 -0
- data/test/unit/filters/keep_skip_based_test.rb +46 -0
- data/test/unit/filters/node_cut_test.rb +72 -0
- data/test/unit/filters/rpath_filter_test.rb +191 -0
- data/test/unit/filters/text_filter_test.rb +46 -0
- data/test/unit/filters_test.rb +119 -0
- data/test/unit/logger/section_node_test.rb +120 -0
- data/test/unit/logger/severity_test.rb +37 -0
- data/test/unit/logger/to_uttk_log_test.rb +113 -0
- data/test/unit/logger/verbosity_test.rb +44 -0
- data/test/unit/logger_test.rb +203 -0
- data/test/unit/strategies/suite_test.rb +151 -0
- data/test/uttk-check.yml +8 -0
- data/test/uttk-distcheck.yml +18 -0
- metadata +399 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Author:: Nicolas Despres <nicolas.despres@gmail.com>.
|
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# $Id: /fey/uttk/trunk/lib/uttk/strategies/Abort.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
module Strategies
|
|
10
|
+
|
|
11
|
+
# A test strategy class which always abort.
|
|
12
|
+
class Abort < Strategy
|
|
13
|
+
include Concrete
|
|
14
|
+
|
|
15
|
+
def run_impl
|
|
16
|
+
abort('Abort strategy always aborts')
|
|
17
|
+
end
|
|
18
|
+
protected :run_impl
|
|
19
|
+
|
|
20
|
+
end # class Abort
|
|
21
|
+
|
|
22
|
+
end # module Strategies
|
|
23
|
+
|
|
24
|
+
end # module Uttk
|
|
@@ -0,0 +1,44 @@
|
|
|
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/Assert.rb 8789 2005-09-27T14:49:49.088376Z ertai $
|
|
5
|
+
|
|
6
|
+
require 'test/unit'
|
|
7
|
+
Test::Unit.run = true
|
|
8
|
+
# require 'test/unit/testcase' # FIXME require just this 'test/unit/assertions'
|
|
9
|
+
|
|
10
|
+
module Uttk
|
|
11
|
+
|
|
12
|
+
module Strategies
|
|
13
|
+
|
|
14
|
+
class Assert < Block
|
|
15
|
+
include Concrete
|
|
16
|
+
include ::Test::Unit::Assertions
|
|
17
|
+
|
|
18
|
+
#
|
|
19
|
+
# Methods
|
|
20
|
+
#
|
|
21
|
+
|
|
22
|
+
def prologue
|
|
23
|
+
super
|
|
24
|
+
@assertion_count = 0
|
|
25
|
+
end
|
|
26
|
+
protected :prologue
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def assertion
|
|
30
|
+
fail @raised_exception if @raised_exception
|
|
31
|
+
pass
|
|
32
|
+
end
|
|
33
|
+
protected :assertion
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def add_assertion
|
|
37
|
+
@assertion_count += 1
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end # class Assert
|
|
41
|
+
|
|
42
|
+
end # module Strategies
|
|
43
|
+
|
|
44
|
+
end # module Uttk
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Author:: Marco Tessari <marco.tessari@epita.fr>.
|
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/Authors.rb 22102 2006-02-21T23:03:39.538964Z pouillar $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
module Strategies
|
|
10
|
+
|
|
11
|
+
# I check whether a student has well written his _AUTHORS_ file. I'm very
|
|
12
|
+
# specific to the test of Epita's student tarballs.
|
|
13
|
+
class Authors < Strategy
|
|
14
|
+
include Concrete
|
|
15
|
+
|
|
16
|
+
def run_impl
|
|
17
|
+
author = "#{@dir}/#{@file}"
|
|
18
|
+
|
|
19
|
+
unless File.exists?(author)
|
|
20
|
+
fail "No '#{author}' file found"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
authors = []
|
|
24
|
+
IO.foreach(author) do |line|
|
|
25
|
+
authors << $1 if line =~ /^\* ([-a-z]{1,6}_[-_a-zA-Z\d]).*$/
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
unless authors.include?(@author)
|
|
29
|
+
fail "AUTHORS not well formatted"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
pass
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
attribute :author, 'the author to match', :mandatory
|
|
36
|
+
attribute :dir, 'the directory where the AUTHORS file is located',
|
|
37
|
+
:mandatory
|
|
38
|
+
attribute :file, 'the name of the AUTHORS file, appended to "dir" path',
|
|
39
|
+
'AUTHORS'
|
|
40
|
+
|
|
41
|
+
end # class Authors
|
|
42
|
+
|
|
43
|
+
end # module Strategies
|
|
44
|
+
|
|
45
|
+
end # module Uttk
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/strategies/Block.rb 22117 2006-02-22T08:56:22.146625Z pouillar $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
module Strategies
|
|
10
|
+
|
|
11
|
+
# I can evaluate a Ruby block. The test fails if block raise an
|
|
12
|
+
# excption or return a false/nil value.
|
|
13
|
+
class Block < IOBased
|
|
14
|
+
include Concrete
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def self.create ( *a, &block )
|
|
18
|
+
raise ArgumentError, 'need a block' if block.nil?
|
|
19
|
+
strategy = new(*a)
|
|
20
|
+
strategy.test = block
|
|
21
|
+
strategy
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test=(block1=nil, &block2)
|
|
26
|
+
if block2
|
|
27
|
+
@test = block2
|
|
28
|
+
elsif not block1.nil?
|
|
29
|
+
@test = block1
|
|
30
|
+
else
|
|
31
|
+
raise ArgumentError, 'no block given'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def prologue
|
|
37
|
+
super
|
|
38
|
+
|
|
39
|
+
if @test.is_a?(String)
|
|
40
|
+
str = @test.dup
|
|
41
|
+
@test = lambda { eval str.do_symtbl_gsub(@symtbl) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
@result, @raised_exception = nil, nil
|
|
45
|
+
end
|
|
46
|
+
protected :prologue
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def run_impl
|
|
50
|
+
begin
|
|
51
|
+
@result = @test[*@args]
|
|
52
|
+
rescue Status => ex
|
|
53
|
+
raise ex
|
|
54
|
+
rescue Exception => ex
|
|
55
|
+
@raised_exception = ex
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
protected :run_impl
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def assertion
|
|
62
|
+
fail @raised_exception if @raised_exception
|
|
63
|
+
pass if @result
|
|
64
|
+
fail @result
|
|
65
|
+
end
|
|
66
|
+
protected :assertion
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
attribute :test, 'a Proc to call with args', :mandatory, :invisible
|
|
70
|
+
attribute :args, 'arguments for the `test\' proc', []
|
|
71
|
+
|
|
72
|
+
end # closs Block
|
|
73
|
+
|
|
74
|
+
end # module Strategies
|
|
75
|
+
|
|
76
|
+
end # module Uttk
|
|
77
|
+
|
|
78
|
+
#FIXME: adapt me to a real unit test suite
|
|
79
|
+
# if defined? TEST_MODE or __FILE__ == $0
|
|
80
|
+
|
|
81
|
+
# include Uttk
|
|
82
|
+
# include Strategies
|
|
83
|
+
|
|
84
|
+
# $x = 0
|
|
85
|
+
# suite = Suite.new
|
|
86
|
+
# suite.strategyclass = Block
|
|
87
|
+
# suite.name = 'Test the Block strategy'
|
|
88
|
+
# suite.symtbl = SymTbl.new
|
|
89
|
+
# suite.symtbl[:loader] = Loaders::Yaml.new
|
|
90
|
+
|
|
91
|
+
# t1 = Block.create { $x = $x.succ }
|
|
92
|
+
# t1.name = 'test 1'
|
|
93
|
+
# suite.create t1
|
|
94
|
+
|
|
95
|
+
# t2 = suite.create
|
|
96
|
+
# t2.name = 'test 2'
|
|
97
|
+
# t2.test = proc { $x = $x.succ }
|
|
98
|
+
|
|
99
|
+
# t3 = suite.create
|
|
100
|
+
# t3.name = 'test 3'
|
|
101
|
+
# t3.test = '$x = $x.succ'
|
|
102
|
+
|
|
103
|
+
# t4 = suite.create(Block.create { $x == 3 || fail("x != 3 (with x == #$x)") })
|
|
104
|
+
# t4.name = 'test 4 PASS'
|
|
105
|
+
|
|
106
|
+
# t5 = suite.create(Block.create { fail("x != 3 (with x == #$x)") })
|
|
107
|
+
# t5.name = 'test 5 FAIL'
|
|
108
|
+
# t5.weight = -1
|
|
109
|
+
|
|
110
|
+
# log = Logger.new(Dumpers::Yaml.new(STDOUT))
|
|
111
|
+
# suite.run(log)
|
|
112
|
+
|
|
113
|
+
# end
|
|
@@ -0,0 +1,55 @@
|
|
|
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/Bootstrap.rb 22117 2006-02-22T08:56:22.146625Z pouillar $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
module Strategies
|
|
10
|
+
|
|
11
|
+
# Run the bootstrap(.sh)? script or a classic autoreconf. This strategy is
|
|
12
|
+
# used by the _Package_ strategy in case of the tested package does use
|
|
13
|
+
# the _autotools_ or not.
|
|
14
|
+
class Bootstrap < Proxy
|
|
15
|
+
include Concrete
|
|
16
|
+
|
|
17
|
+
BOOTSTRAP = /bootstrap(\.sh)?/
|
|
18
|
+
AUTORECONF = 'autoreconf -fvi'
|
|
19
|
+
|
|
20
|
+
def prologue
|
|
21
|
+
super
|
|
22
|
+
|
|
23
|
+
cmd = self.class.have_bootstrap? @dir
|
|
24
|
+
if cmd.nil? and Configure.have_configure_input? @dir
|
|
25
|
+
cmd = AUTORECONF
|
|
26
|
+
end
|
|
27
|
+
unless cmd.nil? or Configure.have_configure?(@dir)
|
|
28
|
+
create(Cmd) do |test|
|
|
29
|
+
test.name = 'internal command'
|
|
30
|
+
test.exit = 0
|
|
31
|
+
test.dir = @dir
|
|
32
|
+
test.command = cmd
|
|
33
|
+
test.reject :strategy
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def dir= ( dir )
|
|
40
|
+
@dir = Pathname.new(dir)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def self.have_bootstrap? ( dir=Pathname.new('.') )
|
|
45
|
+
res = dir.entries.find { |ent| ent.to_s =~ BOOTSTRAP }
|
|
46
|
+
(res.nil?) ? nil : dir + res
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
attribute :dir, 'bootstrap directory', :mandatory
|
|
50
|
+
|
|
51
|
+
end # class Bootstrap
|
|
52
|
+
|
|
53
|
+
end # module Strategies
|
|
54
|
+
|
|
55
|
+
end # module Uttk
|
|
@@ -0,0 +1,64 @@
|
|
|
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/Checkout.rb 21881 2006-02-19T01:33:18.844638Z pouillar $
|
|
5
|
+
|
|
6
|
+
module Uttk
|
|
7
|
+
|
|
8
|
+
module Strategies
|
|
9
|
+
|
|
10
|
+
class Checkout < Strategy
|
|
11
|
+
include Concrete
|
|
12
|
+
|
|
13
|
+
def prologue
|
|
14
|
+
super
|
|
15
|
+
@url = URI.parse(@url) unless @url.is_a? URI
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def run_impl
|
|
19
|
+
begin
|
|
20
|
+
file, data = @url.checkout
|
|
21
|
+
if data.is_a? Commands::Datas::Data
|
|
22
|
+
out, err = data.output, data.error
|
|
23
|
+
@log.my_stdout = out.read unless out.nil? or out.size.zero?
|
|
24
|
+
@log.my_stderr = err.read unless err.nil? or err.size.zero?
|
|
25
|
+
end
|
|
26
|
+
file = FileType.guess(file)
|
|
27
|
+
if file.is_a? FileType::Directory
|
|
28
|
+
@symtbl[:checkout_dir] = file.path
|
|
29
|
+
@symtbl[:extract_dir] = file.path
|
|
30
|
+
pass
|
|
31
|
+
end
|
|
32
|
+
unless file.extractable? or file.installable?
|
|
33
|
+
fail("Bad file type #{file}:#{file.class}, " +
|
|
34
|
+
'neither extractable nor installable')
|
|
35
|
+
end
|
|
36
|
+
if file.extractable?
|
|
37
|
+
path = file.extract
|
|
38
|
+
fail("cannot extract #{file} returned path is nil") if path.nil?
|
|
39
|
+
elsif file.installable?
|
|
40
|
+
install_dir = TempPath.new
|
|
41
|
+
install_dir.mkpath
|
|
42
|
+
data = file.install(install_dir)
|
|
43
|
+
if data.status != 0
|
|
44
|
+
fail("cannot install #{file} returned path is nil")
|
|
45
|
+
end
|
|
46
|
+
path = install_dir + 'gems' + file.path.basename.extsplit.first
|
|
47
|
+
end
|
|
48
|
+
@symtbl[:checkout_dir] = path
|
|
49
|
+
@symtbl[:extract_dir] = path
|
|
50
|
+
rescue FileType::ExtractError => ex
|
|
51
|
+
fail(ex)
|
|
52
|
+
rescue URI::CheckoutError => ex
|
|
53
|
+
fail(ex)
|
|
54
|
+
end
|
|
55
|
+
pass
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
attribute :url, 'url to checkout', :mandatory
|
|
59
|
+
|
|
60
|
+
end # class Checkout
|
|
61
|
+
|
|
62
|
+
end # module Strategies
|
|
63
|
+
|
|
64
|
+
end # module Uttk
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Author:: Marco Tessari <marco.tessari@epita.fr>.
|
|
2
|
+
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
|
|
3
|
+
# License:: LGPL
|
|
4
|
+
# $Id: /fey/uttk/trunk/lib/uttk/strategies/Clean.rb 8778 2005-09-26T04:34:48.103938Z ertai $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
module Strategies
|
|
10
|
+
|
|
11
|
+
class Clean < Strategy
|
|
12
|
+
include Concrete
|
|
13
|
+
|
|
14
|
+
def run_impl
|
|
15
|
+
if @dir.is_a? Array
|
|
16
|
+
@dir.each { |dir| FileUtils.rm_rf(dir) }
|
|
17
|
+
else
|
|
18
|
+
FileUtils.rm_rf(@dir)
|
|
19
|
+
end
|
|
20
|
+
pass
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
attribute :dir, 'clean directory', :mandatory
|
|
24
|
+
|
|
25
|
+
end # class Clean
|
|
26
|
+
|
|
27
|
+
end # module Strategies
|
|
28
|
+
|
|
29
|
+
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/Cmd.rb 22184 2006-02-23T16:12:25.225774Z pouillar $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
module Strategies
|
|
10
|
+
|
|
11
|
+
# I can check many interaction with a command line based program, such as:
|
|
12
|
+
# its standard output, exit status, standard error. I can specify to a
|
|
13
|
+
# given command its arguments, environment variables and standard input.
|
|
14
|
+
#
|
|
15
|
+
# A tutorial introduces how to use this strategy at
|
|
16
|
+
# http://uttk.org/shelf/documentation
|
|
17
|
+
class Cmd < CmdBase
|
|
18
|
+
include Concrete
|
|
19
|
+
|
|
20
|
+
#
|
|
21
|
+
# Methods
|
|
22
|
+
#
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def assertion
|
|
26
|
+
fail('wrong exit value') if !@exit.nil? and @exit.to_i != @my_exit.to_i
|
|
27
|
+
super
|
|
28
|
+
end
|
|
29
|
+
protected :assertion
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def failed_hook
|
|
33
|
+
super
|
|
34
|
+
@log.my_exit = @my_exit
|
|
35
|
+
end
|
|
36
|
+
protected :failed_hook
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def son_hook
|
|
40
|
+
env_sub = proc do |k,v|
|
|
41
|
+
ENV[k.to_s] = v.do_symtbl_gsub(@symtbl).gsub(/\$(\w+)/) { ENV[$1] }
|
|
42
|
+
end
|
|
43
|
+
@env.each(&env_sub)
|
|
44
|
+
@symtbl[:env].each(&env_sub) if @symtbl[:env]
|
|
45
|
+
end
|
|
46
|
+
protected :son_hook
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# Attributes
|
|
51
|
+
#
|
|
52
|
+
|
|
53
|
+
attribute :exit, 'the exit status reference', Integer
|
|
54
|
+
attribute :env, 'environment variables', Hash do {} end
|
|
55
|
+
|
|
56
|
+
end # class Cmd
|
|
57
|
+
|
|
58
|
+
end # module Strategies
|
|
59
|
+
|
|
60
|
+
end # module Uttk
|
|
@@ -0,0 +1,130 @@
|
|
|
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/CmdBase.rb 21844 2006-02-17T17:26:59.771162Z pouillar $
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Uttk
|
|
8
|
+
|
|
9
|
+
module Strategies
|
|
10
|
+
|
|
11
|
+
class CmdBase < IOBased
|
|
12
|
+
include Abstract
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
# Constructor
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
def initialize ( *a, &b )
|
|
19
|
+
super
|
|
20
|
+
@my_exit, @pid, @my_status = nil, nil, nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
#
|
|
25
|
+
# Methods
|
|
26
|
+
#
|
|
27
|
+
|
|
28
|
+
def run_impl
|
|
29
|
+
begin
|
|
30
|
+
cmd = mk_command
|
|
31
|
+
cmd.gsub!("\n", ' ')
|
|
32
|
+
|
|
33
|
+
@log[:running] = cmd
|
|
34
|
+
|
|
35
|
+
@pid = Kernel.fork do
|
|
36
|
+
unless @input.nil? or @input_in_args
|
|
37
|
+
STDIN.reopen(@input.my.open('r'))
|
|
38
|
+
end
|
|
39
|
+
STDOUT.reopen(@output.my.open('w')) unless @output.nil?
|
|
40
|
+
STDERR.reopen(@error.my.open('w')) unless @error.nil?
|
|
41
|
+
Dir.chdir(@dir.to_s) if @dir
|
|
42
|
+
begin
|
|
43
|
+
son_hook
|
|
44
|
+
exec(cmd)
|
|
45
|
+
rescue Exception => ex
|
|
46
|
+
@log.exception_raised_during_exec = ex
|
|
47
|
+
exit! 127
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
father_hook
|
|
51
|
+
waitpid
|
|
52
|
+
fail('exception raised during exec') if @my_exit == 127
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
protected :run_impl
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def son_hook
|
|
59
|
+
end
|
|
60
|
+
protected :son_hook
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def father_hook
|
|
64
|
+
end
|
|
65
|
+
protected :father_hook
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def abort_hook
|
|
69
|
+
unless @pid.nil?
|
|
70
|
+
begin
|
|
71
|
+
Process.kill('-KILL', -@pid)
|
|
72
|
+
waitpid
|
|
73
|
+
rescue Errno::ESRCH
|
|
74
|
+
@log.already_killed = @pid
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
@my_exit = 134 # Common status returned by sh on a SIGABRT
|
|
78
|
+
super
|
|
79
|
+
end
|
|
80
|
+
protected :abort_hook
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def waitpid
|
|
84
|
+
return if @pid.nil? or not @my_status.nil?
|
|
85
|
+
Process.waitpid(@pid)
|
|
86
|
+
@my_status = $?
|
|
87
|
+
@my_exit = @my_status.exitstatus
|
|
88
|
+
end
|
|
89
|
+
protected :waitpid
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def mk_command
|
|
93
|
+
cmd = @command.to_s.dup
|
|
94
|
+
cmd += ' %a' if cmd !~ /%a/ and @args
|
|
95
|
+
cmd.gsub!(/%a/, @args.to_s) if @args
|
|
96
|
+
if cmd =~ /%i/ and @input and @input.my
|
|
97
|
+
cmd.gsub!(/%i/, @input.my.to_s)
|
|
98
|
+
@input_in_args = true
|
|
99
|
+
else
|
|
100
|
+
@input_in_args = false
|
|
101
|
+
end
|
|
102
|
+
cmd
|
|
103
|
+
end
|
|
104
|
+
protected :mk_command
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def epilogue
|
|
108
|
+
waitpid
|
|
109
|
+
super
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
#
|
|
114
|
+
# Attributes
|
|
115
|
+
#
|
|
116
|
+
|
|
117
|
+
attr_reader :my_exit, :my_status, :pid
|
|
118
|
+
|
|
119
|
+
attribute :command, 'the command to execute', :mandatory,
|
|
120
|
+
[String, Pathname, Array]
|
|
121
|
+
attribute :dir, 'the directory where to launch the command',
|
|
122
|
+
[String, Pathname]
|
|
123
|
+
attribute :args, 'the arguments for the command',
|
|
124
|
+
[Array, String, Numeric]
|
|
125
|
+
|
|
126
|
+
end # class CmdBase
|
|
127
|
+
|
|
128
|
+
end # module Strategies
|
|
129
|
+
|
|
130
|
+
end # module Uttk
|