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
data/misc/expandtab.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
+
# Copyright:: Copyright (c) 2005 Uttk team. All rights reserved.
|
4
|
+
# License:: LGPL
|
5
|
+
# $Id: /fey/uttk/trunk/misc/expandtab.rb 8784 2005-09-26T12:11:55.049358Z ertai $
|
6
|
+
|
7
|
+
class String
|
8
|
+
def process!
|
9
|
+
chomp!
|
10
|
+
gsub!(/\t/, ' ')
|
11
|
+
self
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
if ARGV.empty?
|
16
|
+
STDIN.each do |line|
|
17
|
+
puts line.process!
|
18
|
+
end
|
19
|
+
else
|
20
|
+
ARGV.each do |file|
|
21
|
+
puts "Processing: #{file}..."
|
22
|
+
File.open("#{file}.tmp", 'w') do |tmp|
|
23
|
+
IO.foreach(file) do |line|
|
24
|
+
tmp.puts line.process!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
File.rename("#{file}.tmp", file)
|
28
|
+
end
|
29
|
+
end
|
data/misc/header.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
ARGV.map! { |x| Pathname.new(x) }
|
5
|
+
|
6
|
+
ARGV.each do |path|
|
7
|
+
next if path.to_s =~ /header\.rb/
|
8
|
+
header, body, she_bang = '', '', nil
|
9
|
+
header_mode = true
|
10
|
+
path.each_line do |line|
|
11
|
+
header_mode = false unless line =~ /^\s*$/ or line =~ /^#[! ]/
|
12
|
+
if line =~ /^#!/
|
13
|
+
she_bang = line
|
14
|
+
elsif header_mode
|
15
|
+
header += line
|
16
|
+
else
|
17
|
+
body += line
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
header =~ /^# Authors?::?\s+(.*)$/
|
22
|
+
author = $1
|
23
|
+
raise "No author for #{path}" if author.nil?
|
24
|
+
|
25
|
+
header =~ /^# Copyright::?\s+Copyright\s+\([cC]\)\s+([\d-, ]*\d)/
|
26
|
+
years = '2004, 2005' # $1
|
27
|
+
raise "No years for #{path}" if years.nil?
|
28
|
+
raise "Invalid year format in #{path}" if years =~ /-/
|
29
|
+
|
30
|
+
path.open('w') do |f|
|
31
|
+
f.print she_bang unless she_bang.nil?
|
32
|
+
str = <<-end
|
33
|
+
# Author:: #{author}
|
34
|
+
# Copyright:: Copyright (c) #{years} Uttk team. All rights reserved.
|
35
|
+
# License:: LGPL
|
36
|
+
# $Id$
|
37
|
+
end
|
38
|
+
str.gsub!(/^\s*#/, '#')
|
39
|
+
|
40
|
+
f.puts str
|
41
|
+
2.times { f.puts }
|
42
|
+
f.print body
|
43
|
+
end
|
44
|
+
end
|
data/misc/renaming
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
class String
|
6
|
+
def uttk_rename!
|
7
|
+
r = gsub!(/([^Uu])ttk/, '\1uttk') || r
|
8
|
+
r = gsub!(/^ttk/, 'uttk') || r
|
9
|
+
r = gsub!(/([^uU])ttk/, '\1Uttk') || r
|
10
|
+
r = gsub!(/^T[Tt][Kk]/, 'Uttk') || r
|
11
|
+
r = gsub!(/([^Uu])T[tT][kK]/, '\1Uttk') || r
|
12
|
+
r = gsub!(/TestTKewl/, 'Unified Test Tool Kit') || r
|
13
|
+
r = gsub!(/TestToolKit/, 'Unified Test Tool Kit') || r
|
14
|
+
# r = gsub!(/([^Uu ][^Nn ][^Ii ][^Ff ][^Ii ][^Ee ][^Dd ]\s*)(\s*?[tT][Ee][Ss][Tt]\s*[Tt][Oo][Oo][Ll]\s*[Kk][Ii][Tt])/, '\1 Unified\2') || r
|
15
|
+
(r)? self : nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Pathname
|
20
|
+
def uttk_rename!
|
21
|
+
path = self
|
22
|
+
if new = basename.to_s.uttk_rename!
|
23
|
+
p = dirname + new
|
24
|
+
if system("svn move #{self} #{p} --force")
|
25
|
+
path = p
|
26
|
+
end
|
27
|
+
r = self
|
28
|
+
end
|
29
|
+
unless path.directory?
|
30
|
+
r = path.read.uttk_rename!
|
31
|
+
if r
|
32
|
+
path.open('w') { |f| f.syswrite(r) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
(r)? self : nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
ARGV.each do |arg|
|
40
|
+
Pathname.new(arg).find do |path|
|
41
|
+
next if path.to_s == /^\.\.?$/
|
42
|
+
Find.prune if path.to_s =~ /\.svn/
|
43
|
+
next unless path.directory?
|
44
|
+
if path.uttk_rename!
|
45
|
+
STDERR.puts "- #{path}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
Pathname.new(arg).find do |path|
|
49
|
+
next if path.to_s == /renaming/
|
50
|
+
next if path.to_s == /^\.\.?$/
|
51
|
+
Find.prune if path.to_s =~ /\.svn/
|
52
|
+
next if path.directory?
|
53
|
+
if path.uttk_rename!
|
54
|
+
STDERR.puts "- #{path}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# Author:: Nicolas Despr�s <nicolas.despres@lrde.epita.fr>.
|
3
|
+
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
|
4
|
+
# License:: LGPL
|
5
|
+
# $Id: /w/fey/uttk/trunk/misc/textile_compiler 22074 2006-02-21T13:47:00.947568Z pouillar $
|
6
|
+
|
7
|
+
require 'erb'
|
8
|
+
require 'pathname'
|
9
|
+
require 'optparse'
|
10
|
+
|
11
|
+
module TextileCompiler
|
12
|
+
|
13
|
+
DEFAULT_SEVERITY_LEVEL = :warning
|
14
|
+
|
15
|
+
SEVERITY_LEVELS = {
|
16
|
+
:fatal => 0,
|
17
|
+
:error => 1,
|
18
|
+
:warning => 2,
|
19
|
+
:info => 3,
|
20
|
+
:debug => 4
|
21
|
+
}
|
22
|
+
|
23
|
+
def self.severity_level=(level)
|
24
|
+
@@severity_level = level
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.severity_level
|
28
|
+
@@severity_level
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.log(level, message)
|
32
|
+
@@severity_level ||= DEFAULT_SEVERITY_LEVEL
|
33
|
+
if SEVERITY_LEVELS[level] <= SEVERITY_LEVELS[@@severity_level]
|
34
|
+
STDERR.puts "#{File.basename($0)}: #{level}: #{message}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.error(message)
|
39
|
+
log(:error, message)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.fatal(message)
|
43
|
+
log(:fatal, message)
|
44
|
+
raise message
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.warning(message)
|
48
|
+
log(:warning, message)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.info(message)
|
52
|
+
log(:info, message)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.debug(message)
|
56
|
+
log(:debug, message)
|
57
|
+
end
|
58
|
+
|
59
|
+
class Compiler
|
60
|
+
|
61
|
+
DEFAULT_OPTIONS = {
|
62
|
+
:input_extension => '.rtextile',
|
63
|
+
:output_extension => '.textile'
|
64
|
+
}
|
65
|
+
|
66
|
+
def initialize(commands, options={})
|
67
|
+
@command = commands
|
68
|
+
@options = DEFAULT_OPTIONS
|
69
|
+
@options.merge!(options)
|
70
|
+
TextileCompiler.debug("current directory = `#{Pathname.pwd}'")
|
71
|
+
end
|
72
|
+
|
73
|
+
def compile(*pathnames)
|
74
|
+
pathnames.each do |src_pathname|
|
75
|
+
if src_pathname.extname == @options[:input_extension]
|
76
|
+
base_pathname = src_pathname.to_s.sub(/#{src_pathname.extname}$/, '')
|
77
|
+
dest_pathname = Pathname.new(base_pathname +
|
78
|
+
@options[:output_extension])
|
79
|
+
dest_pathname.open('w') do |f|
|
80
|
+
f.write ERB.new(src_pathname.read).result(@command.get_binding)
|
81
|
+
end
|
82
|
+
else
|
83
|
+
TextileCompiler.warning("unknown file extension, ignore `#{src_pathname}'")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end # class Compiler
|
89
|
+
|
90
|
+
class Textile
|
91
|
+
|
92
|
+
def initialize
|
93
|
+
@fixtures_directory = Pathname.new(".")
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_binding
|
97
|
+
binding
|
98
|
+
end
|
99
|
+
|
100
|
+
def comment(&block)
|
101
|
+
end
|
102
|
+
|
103
|
+
def command(command, options={})
|
104
|
+
args = options[:arguments]
|
105
|
+
args ||= []
|
106
|
+
args = args.join(' ')
|
107
|
+
|
108
|
+
cmd = "#{command} #{args}"
|
109
|
+
cmd = "echo #{options[:input]} | #{cmd}" if options[:input]
|
110
|
+
TextileCompiler.info("cmd `#{cmd}'")
|
111
|
+
|
112
|
+
result = "|{background:#ddd}.<code>$ #{cmd}</code>|\n\n"
|
113
|
+
|
114
|
+
TextileCompiler.debug("options[:directory] = `#{options[:directory]}'")
|
115
|
+
directory = options[:directory]
|
116
|
+
directory ||= "."
|
117
|
+
directory = @fixtures_directory + Pathname.new(directory)
|
118
|
+
unless directory.directory? and directory.executable? and directory.readable?
|
119
|
+
TextileCompiler.error("bad directory `#{directory}' " +
|
120
|
+
"(fixtures_directory = `#{@fixtures_directory}'")
|
121
|
+
end
|
122
|
+
TextileCompiler.debug("directory = `#{directory}'")
|
123
|
+
|
124
|
+
full_cmd = "cd #{directory} && #{cmd}"
|
125
|
+
full_cmd += " 2>&1" if options[:with_stderr]
|
126
|
+
TextileCompiler.debug("run `#{full_cmd}'")
|
127
|
+
unless options[:without_output]
|
128
|
+
result += "<pre>\n" + `#{full_cmd}` + "\n</pre>"
|
129
|
+
end
|
130
|
+
status = $?.exitstatus
|
131
|
+
if status != 0
|
132
|
+
TextileCompiler.warning("the command `#{full_cmd}' has exited with " +
|
133
|
+
"status #{status}")
|
134
|
+
end
|
135
|
+
result
|
136
|
+
end
|
137
|
+
|
138
|
+
def fixtures_directory=(new_value)
|
139
|
+
tmp = Pathname.new(new_value)
|
140
|
+
if tmp.directory? and tmp.executable? and tmp.readable?
|
141
|
+
@fixtures_directory = tmp
|
142
|
+
else
|
143
|
+
TextileCompiler.error("bad fixture directory `#{tmp}'")
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
attr_reader :fixtures_directory
|
148
|
+
|
149
|
+
end # class Textile
|
150
|
+
|
151
|
+
end # class TextileCompiler
|
152
|
+
|
153
|
+
|
154
|
+
ME_DIR, ME = Pathname.new($0).split
|
155
|
+
|
156
|
+
options = TextileCompiler::Compiler::DEFAULT_OPTIONS
|
157
|
+
opts = OptionParser.new do |opts|
|
158
|
+
|
159
|
+
opts.banner = "Usage: #{ME} [options] <.rtextile files>..."
|
160
|
+
opts.separator ''
|
161
|
+
|
162
|
+
opts.summary_indent = ' '
|
163
|
+
opts.summary_width = 28
|
164
|
+
|
165
|
+
opts.on('--input-extension EXT',
|
166
|
+
"Input extention (default: #{options[:input_extension]})") do |ext|
|
167
|
+
options[:input_extenstion] = ext
|
168
|
+
end
|
169
|
+
|
170
|
+
opts.on('--output-extension EXT',
|
171
|
+
"Output extention (default: #{options[:output_extension]})") do |ext|
|
172
|
+
options[:output_extenstion] = ext
|
173
|
+
end
|
174
|
+
|
175
|
+
opts.on('-s',
|
176
|
+
'--severity LEVEL',
|
177
|
+
TextileCompiler::SEVERITY_LEVELS.keys,
|
178
|
+
'Log severity level (no argument for the list)') do |lvl|
|
179
|
+
if lvl.nil?
|
180
|
+
puts "Log severity level:"
|
181
|
+
TextileCompiler::SEVERITY_LEVELS.keys.each { |l| puts " - #{l}" }
|
182
|
+
exit
|
183
|
+
else
|
184
|
+
TextileCompiler.severity_level = lvl
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
opts.parse!(ARGV)
|
191
|
+
ARGV.map! { |arg| Pathname.new(arg) }
|
192
|
+
|
193
|
+
TextileCompiler::Compiler.new(TextileCompiler::Textile.new).compile(*ARGV)
|
194
|
+
|
data/misc/uttk-grep.sh
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Author:: Nicolas Despres <nicolas.despres@gmail.com>.
|
3
|
+
# Copyright:: Copyright (c) 2005 Uttk team. All rights reserved.
|
4
|
+
# License:: LGPL
|
5
|
+
# $Id$
|
6
|
+
|
7
|
+
require 'pathname'
|
8
|
+
require 'optparse'
|
9
|
+
|
10
|
+
ME_DIR, ME = Pathname.new($0).split
|
11
|
+
|
12
|
+
skip_comment = false
|
13
|
+
skip_empty_line = false
|
14
|
+
skip_test = false
|
15
|
+
verbose = true
|
16
|
+
append = false
|
17
|
+
opts = OptionParser.new do |opts|
|
18
|
+
|
19
|
+
opts.banner = "Usage: #{ME} [options] <glob_patterns...>"
|
20
|
+
opts.separator ''
|
21
|
+
|
22
|
+
opts.on('-c', '--skip-comment', 'Skip comment') do
|
23
|
+
skip_comment = true
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on('-C', '--no-skip-comment', 'Do not skip comment (default)') do
|
27
|
+
skip_comment = false
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on('-l', '--skip-empty-line', 'Skip empty line') do
|
31
|
+
skip_empty_line = true
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on('-L', '--no-skip-empty-line', 'Do not skip empty line (default)') do
|
35
|
+
skip_empty_line = false
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.on('-t', '--skip-test', 'Skip unit test suite') do
|
39
|
+
skip_test = true
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on('-T', '--no-skip-test', 'Do not skip unit test suite (default)') do
|
43
|
+
skip_test = false
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on('-v', '--verbose', 'Be verbose (default)') do
|
47
|
+
verbose = true
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on('-V', '--no-verbose', 'Do not be verbose') do
|
51
|
+
verbose = false
|
52
|
+
end
|
53
|
+
|
54
|
+
opts.on('-a', '--append', 'Append glob pattern to the search list') do
|
55
|
+
append = true
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.parse!(ARGV)
|
61
|
+
|
62
|
+
|
63
|
+
def merge_arrays! ( dst, src, &block )
|
64
|
+
src.each_with_index do |x, i|
|
65
|
+
dst[i] = block[dst[i], x]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
GLOBDIRS = [
|
71
|
+
'bin/**/*.rb',
|
72
|
+
'bin/uttk*',
|
73
|
+
'lib/**/*.{rb,js,css}',
|
74
|
+
'test/**/*.{rb,yml}',
|
75
|
+
]
|
76
|
+
|
77
|
+
|
78
|
+
files = []
|
79
|
+
globdirs = GLOBDIRS
|
80
|
+
if append
|
81
|
+
globdirs += ARGV
|
82
|
+
else
|
83
|
+
globdirs = ARGV unless ARGV.empty?
|
84
|
+
end
|
85
|
+
globdirs.each do |glob|
|
86
|
+
Pathname.glob(glob).each do |x|
|
87
|
+
next if x.to_s =~ /~$/
|
88
|
+
files << x
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
if verbose
|
94
|
+
puts "%7s %7s %7s %7s %7s %s" %
|
95
|
+
[ 'lines', 'code', 'comment', 'empty', 'test', 'file' ]
|
96
|
+
end
|
97
|
+
total = [0] * 5
|
98
|
+
files.each do |f|
|
99
|
+
count = test_count = comment_count = empty_count = code_count = 0
|
100
|
+
unit_test = false
|
101
|
+
f.each_line do |l|
|
102
|
+
|
103
|
+
if l =~ /^\s*#/
|
104
|
+
comment_count += 1
|
105
|
+
|
106
|
+
elsif l =~ /^\s*$/
|
107
|
+
empty_count += 1
|
108
|
+
|
109
|
+
elsif l =~ /^(\s*)test_section/
|
110
|
+
unit_test = /^#{$1}end/
|
111
|
+
|
112
|
+
elsif unit_test
|
113
|
+
if l =~ unit_test
|
114
|
+
unit_test = false
|
115
|
+
else
|
116
|
+
test_count += 1
|
117
|
+
end
|
118
|
+
|
119
|
+
else
|
120
|
+
code_count += 1
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
count = code_count
|
126
|
+
count += test_count unless skip_test
|
127
|
+
count += comment_count unless skip_comment
|
128
|
+
count += empty_count unless skip_empty_line
|
129
|
+
|
130
|
+
if f.to_s =~ /\.yml$/
|
131
|
+
code_count, test_count = 0, code_count
|
132
|
+
end
|
133
|
+
lst = [ count, code_count, comment_count, empty_count, test_count ]
|
134
|
+
merge_arrays!(total, lst) { |x, y| x + y }
|
135
|
+
|
136
|
+
puts "%7s %7s %7s %7s %7s #{f}" % lst if verbose
|
137
|
+
end
|
138
|
+
|
139
|
+
if verbose
|
140
|
+
puts "%7s %7s %7s %7s %7s total" % total
|
141
|
+
else
|
142
|
+
puts total[0]
|
143
|
+
end
|