ratch 0.4.1 → 1.0.0
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/COPYING +17 -669
- data/HISTORY +6 -0
- data/MANIFEST +36 -0
- data/METADATA +14 -0
- data/NEWS +7 -0
- data/README +67 -17
- data/bin/ratch +5 -78
- data/demo/tryme-task.ratch +12 -0
- data/demo/tryme1.ratch +6 -0
- data/lib/ratch/core_ext.rb +6 -0
- data/lib/ratch/core_ext/facets.rb +1 -0
- data/lib/ratch/core_ext/filetest.rb +52 -0
- data/lib/ratch/core_ext/object.rb +8 -0
- data/lib/ratch/core_ext/pathname.rb +38 -0
- data/lib/ratch/core_ext/string.rb +44 -0
- data/lib/ratch/{dsl/console.rb → core_ext/to_console.rb} +2 -76
- data/lib/ratch/core_ext/to_list.rb +29 -0
- data/lib/ratch/dsl.rb +494 -49
- data/lib/ratch/index.rb +4 -0
- data/lib/ratch/io.rb +116 -0
- data/lib/ratch/pathglob.rb +73 -0
- data/lib/ratch/plugin.rb +55 -0
- data/lib/ratch/runmode.rb +69 -0
- data/lib/ratch/script.rb +52 -0
- data/lib/ratch/service.rb +33 -0
- data/lib/ratch/task.rb +249 -0
- data/lib/ratch/task2.rb +298 -0
- data/test/README +1 -0
- data/test/test_helper.rb +4 -0
- data/test/test_task.rb +46 -0
- metadata +90 -150
- data/CHANGES +0 -22
- data/TODO +0 -2
- data/bin/lt +0 -56
- data/bin/ludo +0 -14
- data/bin/manifest +0 -451
- data/bin/ratch-find +0 -21
- data/demo/WILMA +0 -1
- data/demo/XR +0 -9
- data/demo/lib/foo/foo.rb +0 -7
- data/demo/p.rb +0 -9
- data/demo/r.rb +0 -6
- data/demo/t.rb +0 -3
- data/demo/task/config.yaml +0 -4
- data/demo/task/one +0 -6
- data/demo/task/simplebuild +0 -15
- data/demo/task/stats +0 -4
- data/demo/task/task +0 -6
- data/demo/task/tryme +0 -10
- data/lib/ratch/dsl/argv.rb +0 -112
- data/lib/ratch/dsl/batch.rb +0 -232
- data/lib/ratch/dsl/build.rb +0 -174
- data/lib/ratch/dsl/email.rb +0 -108
- data/lib/ratch/dsl/file.rb +0 -205
- data/lib/ratch/dsl/meta.rb +0 -125
- data/lib/ratch/dsl/options.rb +0 -98
- data/lib/ratch/dsl/setup.rb +0 -124
- data/lib/ratch/dsl/sign.rb +0 -243
- data/lib/ratch/dsl/stage.rb +0 -147
- data/lib/ratch/dsl/task.rb +0 -139
- data/lib/ratch/dsl/upload.rb +0 -436
- data/lib/ratch/dsl/zip.rb +0 -59
- data/lib/ratch/extra/email.rb +0 -5
- data/lib/ratch/extra/stage.rb +0 -5
- data/lib/ratch/extra/zip.rb +0 -5
- data/lib/ratch/manager.rb +0 -53
- data/lib/ratch/manifest.rb +0 -540
- data/lib/ratch/metadata/information.rb +0 -258
- data/lib/ratch/metadata/package.rb +0 -108
- data/lib/ratch/metadata/project.rb +0 -523
- data/lib/ratch/metadata/release.rb +0 -108
- data/lib/ratch/support/errors.rb +0 -4
- data/lib/ratch/support/filename.rb +0 -18
- data/lib/ratch/support/filetest.rb +0 -29
- data/lib/ratch/toolset/ruby/announce +0 -224
- data/lib/ratch/toolset/ruby/compile +0 -49
- data/lib/ratch/toolset/ruby/install +0 -77
- data/lib/ratch/toolset/ruby/notes +0 -185
- data/lib/ratch/toolset/ruby/pack/gem +0 -93
- data/lib/ratch/toolset/ruby/pack/tgz +0 -46
- data/lib/ratch/toolset/ruby/pack/zip +0 -46
- data/lib/ratch/toolset/ruby/publish +0 -57
- data/lib/ratch/toolset/ruby/release +0 -8
- data/lib/ratch/toolset/ruby/setup +0 -1616
- data/lib/ratch/toolset/ruby/stamp +0 -33
- data/lib/ratch/toolset/ruby/stats +0 -138
- data/lib/ratch/toolset/ruby/test/crosstest +0 -305
- data/lib/ratch/toolset/ruby/test/extest +0 -129
- data/lib/ratch/toolset/ruby/test/isotest +0 -293
- data/lib/ratch/toolset/ruby/test/load +0 -39
- data/lib/ratch/toolset/ruby/test/loadtest +0 -28
- data/lib/ratch/toolset/ruby/test/syntax +0 -29
- data/lib/ratch/toolset/ruby/test/test +0 -26
- data/lib/ratch/toolset/sandbox/query +0 -11
- data/man/ratch.man +0 -73
- data/meta/MANIFEST +0 -130
- data/meta/config.yaml +0 -9
- data/meta/icli.yaml +0 -16
- data/meta/project.yaml +0 -20
- data/meta/ratch.roll +0 -2
- data/meta/xProjectInfo +0 -41
- data/task/clobber/package +0 -10
- data/task/man +0 -14
- data/task/publish +0 -57
- data/task/release +0 -9
- data/task/setup +0 -1616
- data/task/stats +0 -138
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ratch
|
|
2
|
-
|
|
3
|
-
# update version stamps
|
|
4
|
-
|
|
5
|
-
# You can change these via the command line.
|
|
6
|
-
version = commandline['version'] || rollrc.version
|
|
7
|
-
status = commandline['status'] || rollrc.status
|
|
8
|
-
|
|
9
|
-
# Update ROLLRC file.
|
|
10
|
-
|
|
11
|
-
main :stamp do
|
|
12
|
-
if version != rollrc.version or status != rollrc.status
|
|
13
|
-
build rollrc.file
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
file rollrc.file do
|
|
20
|
-
w = ''
|
|
21
|
-
w << "#{rollrc.name} #{version} #{status} #{Time.now.strftime('%Y-%m-%d')}"
|
|
22
|
-
w << " #{rollrc.default}" if rollrc.default
|
|
23
|
-
w << "\n"
|
|
24
|
-
w << rollrc.libpath.join("\n")
|
|
25
|
-
|
|
26
|
-
if dryrun?
|
|
27
|
-
puts rollrc.file + ":"
|
|
28
|
-
puts w
|
|
29
|
-
else
|
|
30
|
-
File.open(rollrc.file, 'w'){|f| f << w}
|
|
31
|
-
puts "#{rollrc.file} updated."
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ratch
|
|
2
|
-
|
|
3
|
-
# Simple code count analysis.
|
|
4
|
-
#
|
|
5
|
-
# This ratchet scan source code counting files,
|
|
6
|
-
# lines of code and comments and presents a
|
|
7
|
-
# report of it's findings.
|
|
8
|
-
|
|
9
|
-
main :stats do
|
|
10
|
-
statistics
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
DEFAULT_STATS_FILES = [ 'lib/**/*', 'ext/**/*', 'bin/**/*' ]
|
|
14
|
-
|
|
15
|
-
# Basic statics on line count.
|
|
16
|
-
#
|
|
17
|
-
# This task counts the file and lines of code in your
|
|
18
|
-
# project and provided some statistical figures.
|
|
19
|
-
#
|
|
20
|
-
# files Files to include and/or exclude in
|
|
21
|
-
# analysis. '+' and '-' files patterns
|
|
22
|
-
# are accepted. The default includes all
|
|
23
|
-
# files in the lib/ and ext/ directories.
|
|
24
|
-
#
|
|
25
|
-
# TODO Support - and + augmentations for configuration.
|
|
26
|
-
|
|
27
|
-
def statistics
|
|
28
|
-
config = configuration['stats'] || {}
|
|
29
|
-
scripts = config['files'] || DEFAULT_STATS_FILES
|
|
30
|
-
files = scripts.inject([]){ |memo, find| memo.concat(glob(find)); memo }
|
|
31
|
-
#Dir.multiglob_with_default(DEFAULT_STATS_FILES)
|
|
32
|
-
|
|
33
|
-
fc, l, c, r, t, s = *line_count(*files)
|
|
34
|
-
|
|
35
|
-
fct, lt, ct, rt, tt, st = *([0]*6)
|
|
36
|
-
if File.directory?('test')
|
|
37
|
-
fct, lt, ct, rt, tt, st = *line_count('test/**/*')
|
|
38
|
-
t = lt if lt > 0
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
rat = lambda do |d,n|
|
|
42
|
-
if d > n and n != 0
|
|
43
|
-
"%.1f" % [ d.to_f / n ]
|
|
44
|
-
elsif n > d and d != 0
|
|
45
|
-
"-" #"%.1f:1" % [ n.to_f / d ]
|
|
46
|
-
elsif d == 0 or n == 0
|
|
47
|
-
"-"
|
|
48
|
-
else
|
|
49
|
-
"1.0"
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
per = lambda do |n,d|
|
|
54
|
-
if d != 0
|
|
55
|
-
(((n.to_f / d)*100).to_i).to_s + "%"
|
|
56
|
-
else
|
|
57
|
-
"-"
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
max = l.to_s.size + 4
|
|
62
|
-
|
|
63
|
-
puts
|
|
64
|
-
#puts "FILES:"
|
|
65
|
-
#puts " source: #{fc}"
|
|
66
|
-
#puts " test : #{fct}"
|
|
67
|
-
#puts " total : #{fc+fct}"
|
|
68
|
-
#puts
|
|
69
|
-
#puts "LINES:"
|
|
70
|
-
#puts " code : %#{max}s %4s" % [ c.to_s, per[c,l] ]
|
|
71
|
-
#puts " docs : %#{max}s %4s" % [ r.to_s, per[r,l] ]
|
|
72
|
-
#puts " space : %#{max}s %4s" % [ s.to_s, per[s,l] ]
|
|
73
|
-
#puts " test : %#{max}s %4s" % [ t.to_s, per[t,l] ]
|
|
74
|
-
#puts " total : %#{max}s %4s" % [ l.to_s, per[l,l] ]
|
|
75
|
-
#puts
|
|
76
|
-
#puts "Ratio to 1 :"
|
|
77
|
-
#puts " code to test : #{rat[c,t]} #{per[c,t]}"
|
|
78
|
-
|
|
79
|
-
head = ["Total", "Code", "-%-", "Docs", "-%-", "Blank", "-%-", "Files"]
|
|
80
|
-
prod = [l.to_s, c.to_s, per[c,l], r.to_s, per[r,l], s.to_s, per[s,l], fc]
|
|
81
|
-
test = [lt.to_s, ct.to_s, per[ct,l], rt.to_s, per[rt,l], st.to_s, per[st,l], fct]
|
|
82
|
-
totl = [(l+lt), (c+ct), per[c+ct,l+lt], (r+rt), per[r+rt,l+lt], (s+st), per[s+st,l+lt], (fc+fct)]
|
|
83
|
-
|
|
84
|
-
puts "TYPE %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % head
|
|
85
|
-
puts "Source %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % prod
|
|
86
|
-
puts "Test %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % test
|
|
87
|
-
puts "Total %#{max}s %#{max}s %4s %#{max}s %4s %#{max}s %4s %#{max}s" % totl
|
|
88
|
-
puts
|
|
89
|
-
puts "RATIO Code Docs Blank Test Total"
|
|
90
|
-
puts "Code %7s %7s %7s %7s %7s" % [ rat[c,c], rat[c,r], rat[c,s], rat[c,t], rat[c,l] ]
|
|
91
|
-
puts "Docs %7s %7s %7s %7s %7s" % [ rat[r,c], rat[r,r], rat[r,s], rat[r,t], rat[r,l] ]
|
|
92
|
-
puts "Blank %7s %7s %7s %7s %7s" % [ rat[s,c], rat[s,r], rat[s,s], rat[s,t], rat[s,l] ]
|
|
93
|
-
puts "Test %7s %7s %7s %7s %7s" % [ rat[t,c], rat[t,r], rat[t,s], rat[t,t], rat[t,l] ]
|
|
94
|
-
puts "Total %7s %7s %7s %7s %7s" % [ rat[l,c], rat[l,r], rat[l,s], rat[l,t], rat[l,l] ]
|
|
95
|
-
puts
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
private
|
|
99
|
-
|
|
100
|
-
# Return line counts for files.
|
|
101
|
-
|
|
102
|
-
def line_count( *files )
|
|
103
|
-
files = files.inject([]) do |memo, find|
|
|
104
|
-
memo.concat(Dir.glob(find)); memo
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
fc, l, c, t, r = 0, 0, 0, 0, 0
|
|
108
|
-
bt, rb = false, false
|
|
109
|
-
|
|
110
|
-
files.each do |fname|
|
|
111
|
-
next unless fname =~ /.*rb/ # TODO should this be done?
|
|
112
|
-
fc += 1
|
|
113
|
-
File.open( fname ) do |f|
|
|
114
|
-
while line = f.gets
|
|
115
|
-
l += 1
|
|
116
|
-
next if line =~ /^\s*$/
|
|
117
|
-
case line
|
|
118
|
-
when /^=begin\s+test/
|
|
119
|
-
tb = true; t+=1
|
|
120
|
-
when /^=begin/
|
|
121
|
-
rb = true; r+=1
|
|
122
|
-
when /^=end/
|
|
123
|
-
t+=1 if tb
|
|
124
|
-
r+=1 if rb
|
|
125
|
-
rb, tb = false, false
|
|
126
|
-
when /^\s*#/
|
|
127
|
-
r += 1
|
|
128
|
-
else
|
|
129
|
-
c+=1 if !(rb or tb)
|
|
130
|
-
r+=1 if rb
|
|
131
|
-
t+=1 if tb
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
s = l - c - r - t
|
|
137
|
-
return fc, l, c, r, t, s
|
|
138
|
-
end
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ratch
|
|
2
|
-
|
|
3
|
-
# run cross comparison tests
|
|
4
|
-
#
|
|
5
|
-
# This tool runs unit tests in pairs to make
|
|
6
|
-
# sure there is cross library compatibility.
|
|
7
|
-
|
|
8
|
-
require 'facets/hash/rekey'
|
|
9
|
-
require 'facets/string/tabs'
|
|
10
|
-
require 'facets/progressbar'
|
|
11
|
-
|
|
12
|
-
require 'test/unit/ui/testrunnermediator' #require 'test/unit'
|
|
13
|
-
::Test::Unit.run = true # Don't autorun tests!
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
main :crosstest do
|
|
17
|
-
run_crosstests
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Run unit-tests. Each test is run in a separate interpretor
|
|
21
|
-
# to prevent script clash. This makes for a more robust test
|
|
22
|
-
# facility and prevents potential conflicts between test scripts.
|
|
23
|
-
#
|
|
24
|
-
# tests Test files (eg. test/tc_**/*.rb) [test/**/*]
|
|
25
|
-
# libs Directories to include in load path.
|
|
26
|
-
# ('./lib' is always included)
|
|
27
|
-
# live Deactive use of local libs and test against install.
|
|
28
|
-
# reqs List of files to require prior to running tests.
|
|
29
|
-
# extract Extract embedded tests first? [false]
|
|
30
|
-
#
|
|
31
|
-
# To isolate tests this tool marshals test results across a
|
|
32
|
-
# stdout->stdin shell pipe. This prevents interfence of one
|
|
33
|
-
# script's tests on another. But consequently it is not always
|
|
34
|
-
# possible to send debug info to stdout in the tests themselves
|
|
35
|
-
# (eg. #p and #puts).
|
|
36
|
-
|
|
37
|
-
def run_crosstests
|
|
38
|
-
info = configuration['test']
|
|
39
|
-
|
|
40
|
-
tests = info['files'] || 'test/unit/**/test_*.rb'
|
|
41
|
-
libs = info['libpath']
|
|
42
|
-
reqs = info['require']
|
|
43
|
-
live = info['live']
|
|
44
|
-
#extract = info['extract']
|
|
45
|
-
|
|
46
|
-
tests = [ tests ].flatten
|
|
47
|
-
libs = [ libs ].flatten
|
|
48
|
-
|
|
49
|
-
results = TestResults.new #(style)
|
|
50
|
-
|
|
51
|
-
# get test files
|
|
52
|
-
test_libs = libs.join(':')
|
|
53
|
-
test_files = Dir.multiglob( *tests )
|
|
54
|
-
if test_files.empty?
|
|
55
|
-
puts "Tests [NONE]"
|
|
56
|
-
return
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# run tests
|
|
60
|
-
|
|
61
|
-
if trace?
|
|
62
|
-
pbar = nil
|
|
63
|
-
size = test_files.collect{|f| f.size}.max * 2 + 5
|
|
64
|
-
dots = '.' * size
|
|
65
|
-
else
|
|
66
|
-
pbar = Console::ProgressBar.new('Testing', test_files.size ** 2)
|
|
67
|
-
pbar.inc
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
test_files.each do |test_file|
|
|
71
|
-
next unless File.file?(test_file)
|
|
72
|
-
|
|
73
|
-
test_files.each do |test_file_x|
|
|
74
|
-
next unless File.file?(test_file_x)
|
|
75
|
-
next if test_file == test_file_x
|
|
76
|
-
|
|
77
|
-
pbar.inc if pbar
|
|
78
|
-
unless pbar
|
|
79
|
-
out = test_file +' : ' + test_file_x
|
|
80
|
-
print out + dots[out.size..-1]
|
|
81
|
-
$stdout.flush
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
r = fork_test( test_file, test_file_x, :libs=>libs, :reqs=>reqs, :live=>live )
|
|
85
|
-
|
|
86
|
-
unless pbar
|
|
87
|
-
puts r.passed? ? "[PASS]" : "[FAIL]"
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
results << r
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
pbar.finish if pbar
|
|
95
|
-
|
|
96
|
-
# display results
|
|
97
|
-
puts results
|
|
98
|
-
|
|
99
|
-
fails, errrs = results.failure_count, results.error_count
|
|
100
|
-
#CHECKLIST << :test if fails > 0
|
|
101
|
-
#CHECKLIST << :test if errrs > 0
|
|
102
|
-
return (fails + errrs > 0)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# Run a test in a separate process.
|
|
106
|
-
#
|
|
107
|
-
# Currently send program output to null device.
|
|
108
|
-
# Could send to a logger in future version.
|
|
109
|
-
#
|
|
110
|
-
# Key parameters are libs, reqs, live.
|
|
111
|
-
|
|
112
|
-
def fork_test( file, xfile, keys )
|
|
113
|
-
keys = keys.rekey(:to_s)
|
|
114
|
-
|
|
115
|
-
libs = keys['lib'] || []
|
|
116
|
-
reqs = keys['req'] || []
|
|
117
|
-
live = keys['live']
|
|
118
|
-
|
|
119
|
-
src = ''
|
|
120
|
-
|
|
121
|
-
unless live
|
|
122
|
-
l = File.join( Dir.pwd, 'lib' )
|
|
123
|
-
if File.directory?( l )
|
|
124
|
-
src << %{$:.unshift('#{l}')\n}
|
|
125
|
-
end
|
|
126
|
-
libs.each { |r| src << %{$:.unshift('#{r}')\n} }
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
src << %{
|
|
130
|
-
#require 'test/unit'
|
|
131
|
-
require 'test/unit/collector'
|
|
132
|
-
require 'test/unit/collector/objectspace'
|
|
133
|
-
require 'test/unit/ui/testrunnermediator'
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
reqs.each do |fix|
|
|
137
|
-
src << %Q{
|
|
138
|
-
require '#{fix}'
|
|
139
|
-
}
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
src << %{
|
|
143
|
-
def warn(*null); end # silence warnings
|
|
144
|
-
|
|
145
|
-
output = STDOUT.dup
|
|
146
|
-
STDOUT.reopen( PLATFORM =~ /mswin/ ? "NUL" : "/dev/null" )
|
|
147
|
-
|
|
148
|
-
load('#{file}')
|
|
149
|
-
load('#{xfile}')
|
|
150
|
-
|
|
151
|
-
tests = Test::Unit::Collector::ObjectSpace.new.collect
|
|
152
|
-
runner = Test::Unit::UI::TestRunnerMediator.new( tests )
|
|
153
|
-
result = runner.run_suite
|
|
154
|
-
|
|
155
|
-
begin
|
|
156
|
-
marshalled = Marshal.dump(result)
|
|
157
|
-
rescue TypeError => e
|
|
158
|
-
$stderr << "MARSHAL ERROR\n"
|
|
159
|
-
$stderr << "TEST: #{file}\n"
|
|
160
|
-
$stderr << "XTEST: #{xfile}\n"
|
|
161
|
-
$stderr << "DATA:" << result.inspect
|
|
162
|
-
exit -1
|
|
163
|
-
end
|
|
164
|
-
output << marshalled
|
|
165
|
-
|
|
166
|
-
STDOUT.reopen(output)
|
|
167
|
-
output.close
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
result = IO.popen("ruby","w+") do |ruby|
|
|
171
|
-
ruby.puts src
|
|
172
|
-
ruby.close_write
|
|
173
|
-
ruby.read
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
begin
|
|
177
|
-
marsh = Marshal.load(result)
|
|
178
|
-
rescue ArgumentError
|
|
179
|
-
$stderr << "\nCannot load marshalled test data.\n"
|
|
180
|
-
$stderr << result << "\n"
|
|
181
|
-
exit -1
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
return marsh
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
#
|
|
188
|
-
# Support class for collecting test results.
|
|
189
|
-
#
|
|
190
|
-
|
|
191
|
-
class TestResults
|
|
192
|
-
attr_reader :assertion_count,
|
|
193
|
-
:run_count,
|
|
194
|
-
:failure_count,
|
|
195
|
-
:error_count
|
|
196
|
-
|
|
197
|
-
attr_accessor :style
|
|
198
|
-
|
|
199
|
-
def initialize( style=nil )
|
|
200
|
-
@style = style
|
|
201
|
-
|
|
202
|
-
@results = []
|
|
203
|
-
|
|
204
|
-
@assertion_count = 0
|
|
205
|
-
@run_count = 0
|
|
206
|
-
@failure_count = 0
|
|
207
|
-
@error_count = 0
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
# Add a result to the results collection.
|
|
211
|
-
|
|
212
|
-
def <<( result )
|
|
213
|
-
@results << result
|
|
214
|
-
|
|
215
|
-
@assertion_count += result.assertion_count
|
|
216
|
-
@run_count += result.run_count
|
|
217
|
-
@failure_count += result.failure_count
|
|
218
|
-
@error_count += result.error_count
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
#
|
|
222
|
-
|
|
223
|
-
def errors
|
|
224
|
-
errors = []
|
|
225
|
-
@results.each do |r|
|
|
226
|
-
unless r.passed?
|
|
227
|
-
errors << r.instance_variable_get('@errors')
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
errors.reject! { |e| e == [] }
|
|
231
|
-
errors
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
#
|
|
235
|
-
|
|
236
|
-
def failures
|
|
237
|
-
failures = []
|
|
238
|
-
@results.each do |r|
|
|
239
|
-
unless r.passed?
|
|
240
|
-
failures << r.instance_variable_get('@failures')
|
|
241
|
-
end
|
|
242
|
-
end
|
|
243
|
-
failures.reject! { |e| e == [] }
|
|
244
|
-
failures
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
# Output format for test results.
|
|
248
|
-
|
|
249
|
-
def to_s
|
|
250
|
-
return @results.to_s if style == 'pease'
|
|
251
|
-
|
|
252
|
-
s = []
|
|
253
|
-
# Display failures
|
|
254
|
-
unless failures.empty?
|
|
255
|
-
s << ''
|
|
256
|
-
s << "FAILURES:"
|
|
257
|
-
failures.reverse.each do |fails|
|
|
258
|
-
fails.reverse.each do |failure|
|
|
259
|
-
#puts
|
|
260
|
-
s << %{ - test : #{failure.test_name}}
|
|
261
|
-
s << %{ location : #{failure.location}}
|
|
262
|
-
if failure.message.index("\n")
|
|
263
|
-
s << %{ message : >}
|
|
264
|
-
s << failure.message.tabto(6)
|
|
265
|
-
else
|
|
266
|
-
s << %{ message : #{failure.message}}
|
|
267
|
-
end
|
|
268
|
-
end
|
|
269
|
-
end
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
# Display errors
|
|
273
|
-
unless errors.empty?
|
|
274
|
-
s << ''
|
|
275
|
-
s << "ERRORS:"
|
|
276
|
-
errors.reverse.each do |errs|
|
|
277
|
-
errs.reverse.each do |err|
|
|
278
|
-
s << ''
|
|
279
|
-
s << %{ - test : #{err.test_name}}
|
|
280
|
-
s << %{ message : #{err.exception.message}}
|
|
281
|
-
s << %{ backtrace :}
|
|
282
|
-
err.exception.backtrace[0...-1].each { |bt| s << %Q{ - #{bt}} }
|
|
283
|
-
end
|
|
284
|
-
end
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
# Display final results
|
|
288
|
-
s << ''
|
|
289
|
-
s << "Summary:"
|
|
290
|
-
s << " Tests : #{@run_count}"
|
|
291
|
-
s << " Assertions : #{@assertion_count}"
|
|
292
|
-
s << " Failures : #{@failure_count}"
|
|
293
|
-
s << " Errors : #{@error_count}"
|
|
294
|
-
s << ''
|
|
295
|
-
s << ''
|
|
296
|
-
|
|
297
|
-
return s.join("\n")
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
# Delegate missing call to the results array.
|
|
301
|
-
|
|
302
|
-
def method_missing(*a,&b)
|
|
303
|
-
@results.send(*a,&b)
|
|
304
|
-
end
|
|
305
|
-
end
|