reap 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +8 -1
- data/Reapfile +8 -7
- data/doc/classes/Reap.html +1 -1
- data/doc/classes/Reap/AnnounceTask.html +50 -42
- data/doc/classes/Reap/ChmodTask.html +40 -41
- data/doc/classes/Reap/PackageTask.html +35 -33
- data/doc/classes/Reap/PublishTask.html +48 -42
- data/doc/classes/Reap/RDocTask.html +14 -14
- data/doc/classes/Reap/Runner.html +49 -57
- data/doc/classes/Reap/Task.html +119 -71
- data/doc/classes/Reap/TemplateTask.html +42 -49
- data/doc/classes/Reap/TestTask.html +135 -23
- data/doc/classes/Reap/TestTask/TestResults.html +235 -0
- data/doc/created.rid +1 -1
- data/doc/files/README.html +3 -3
- data/doc/files/lib/reap/reap_rb.html +3 -2
- data/doc/files/lib/reap/runner_rb.html +6 -5
- data/doc/files/lib/reap/task_rb.html +1 -1
- data/doc/files/lib/reap/tasks/announce-task_rb.html +6 -6
- data/doc/files/lib/reap/tasks/chmod-task_rb.html +1 -1
- data/doc/files/lib/reap/tasks/package-task_rb.html +1 -1
- data/doc/files/lib/reap/tasks/publish-task_rb.html +1 -1
- data/doc/files/lib/reap/tasks/rdoc-task_rb.html +1 -1
- data/doc/files/lib/reap/tasks/template-task_rb.html +2 -1
- data/doc/files/lib/reap/tasks/test-task_rb.html +9 -1
- data/doc/fr_class_index.html +1 -0
- data/doc/fr_file_index.html +0 -1
- data/doc/fr_method_index.html +40 -36
- data/lib/reap/reap.rb +4 -2
- data/lib/reap/runner.rb +23 -28
- data/lib/reap/task.rb +71 -22
- data/lib/reap/tasks/announce-task.rb +29 -20
- data/lib/reap/tasks/chmod-task.rb +6 -9
- data/lib/reap/tasks/package-task.rb +33 -29
- data/lib/reap/tasks/publish-task.rb +22 -16
- data/lib/reap/tasks/rdoc-task.rb +9 -11
- data/lib/reap/tasks/template-task.rb +12 -11
- data/lib/reap/tasks/test-task.rb +115 -20
- data/pub/www/doc/classes/Reap.html +184 -0
- data/pub/www/doc/classes/Reap/AnnounceTask.html +331 -0
- data/pub/www/doc/classes/Reap/ChmodTask.html +278 -0
- data/pub/www/doc/classes/Reap/PackageTask.html +372 -0
- data/pub/www/doc/classes/Reap/PublishTask.html +231 -0
- data/pub/www/doc/classes/Reap/RDocTask.html +254 -0
- data/pub/www/doc/classes/Reap/Runner.html +307 -0
- data/pub/www/doc/classes/Reap/Task.html +390 -0
- data/pub/www/doc/classes/Reap/TemplateTask.html +233 -0
- data/pub/www/doc/classes/Reap/TestTask.html +242 -0
- data/pub/www/doc/created.rid +1 -0
- data/pub/www/doc/files/LICENSE.html +119 -0
- data/pub/www/doc/files/README.html +194 -0
- data/pub/www/doc/files/lib/reap/reap_rb.html +110 -0
- data/pub/www/doc/files/lib/reap/runner_rb.html +113 -0
- data/pub/www/doc/files/lib/reap/task_rb.html +108 -0
- data/pub/www/doc/files/lib/reap/tasks/announce-task_rb.html +113 -0
- data/pub/www/doc/files/lib/reap/tasks/chmod-task_rb.html +101 -0
- data/pub/www/doc/files/lib/reap/tasks/package-task_rb.html +108 -0
- data/pub/www/doc/files/lib/reap/tasks/publish-task_rb.html +101 -0
- data/pub/www/doc/files/lib/reap/tasks/rdoc-task_rb.html +101 -0
- data/pub/www/doc/files/lib/reap/tasks/template-task_rb.html +108 -0
- data/pub/www/doc/files/lib/reap/tasks/test-task_rb.html +101 -0
- data/{doc → pub/www/doc}/files/lib/reap/template_rb.html +0 -0
- data/pub/www/doc/fr_class_index.html +36 -0
- data/pub/www/doc/fr_file_index.html +39 -0
- data/pub/www/doc/fr_method_index.html +69 -0
- data/pub/www/doc/index.html +24 -0
- data/pub/www/doc/rdoc-style.css +208 -0
- data/pub/www/index.html +6 -0
- data/test/{test_require.rb → tc_require.rb} +0 -0
- metadata +50 -10
- data/lib/reap/template.rb +0 -72
@@ -1,45 +1,53 @@
|
|
1
1
|
|
2
2
|
require 'net/smtp'
|
3
|
-
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
3
|
+
|
4
|
+
require 'nano/string/margin'
|
5
|
+
require 'nano/string/tab'
|
6
|
+
require 'nano/string/align_center'
|
7
|
+
require 'nano/string/fold'
|
8
|
+
require 'nano/string/word_wrap'
|
8
9
|
|
9
10
|
module Reap
|
10
11
|
|
11
12
|
class AnnounceTask < Task
|
12
|
-
|
13
|
+
|
13
14
|
def self.task ; :announce ; end
|
14
|
-
|
15
|
+
|
15
16
|
def self.desc ; "Sends [ANN] email to ruby-talk or other list." ; end
|
16
17
|
|
17
18
|
|
18
|
-
def
|
19
|
-
@address
|
20
|
-
@from
|
21
|
-
@server
|
22
|
-
@port
|
23
|
-
@domain
|
24
|
-
@account
|
19
|
+
def setup
|
20
|
+
@address = section['to']
|
21
|
+
@from = section['from'].to_s
|
22
|
+
@server = section['server'].to_s.strip
|
23
|
+
@port = section['port'] || 25
|
24
|
+
@domain = section['domain'].to_s.strip
|
25
|
+
@account = section['account'].to_s
|
25
26
|
@authtype = section['authtype'].to_sym
|
26
|
-
@
|
27
|
+
@tls = section['tls'] ? true : false
|
27
28
|
|
29
|
+
@title = master['title']
|
30
|
+
@version = master['version']
|
31
|
+
@summary = master['summary']
|
32
|
+
|
33
|
+
@subject = "[ANN] #{@title}, v#{@version}"
|
34
|
+
|
28
35
|
#raise "DOMAIN is a required field" if @domain.empty?
|
29
36
|
|
37
|
+
# header
|
30
38
|
announce = %Q{
|
31
39
|
|
|
32
40
|
|A N N O U N C I N G
|
33
41
|
|
|
34
|
-
|#{@
|
42
|
+
|#{@title}, v#{@version}
|
35
43
|
|
|
36
|
-
|#{@
|
44
|
+
|#{@summary}
|
37
45
|
|
|
38
46
|
}.margin.center_lines(66)
|
39
47
|
|
40
48
|
# abstract
|
41
49
|
abstract = ''
|
42
|
-
desc =
|
50
|
+
desc = description
|
43
51
|
if desc
|
44
52
|
abstract << "\n\n"
|
45
53
|
abstract << "ABSTRACT: #{desc}".word_wrap(72)
|
@@ -71,7 +79,7 @@ module Reap
|
|
71
79
|
memo = ''
|
72
80
|
memo << "\n" << ('-' * 72) << "\n"
|
73
81
|
memo << "(Memo)\n\n"
|
74
|
-
memo << section['memo'].
|
82
|
+
memo << section['memo'].fold.word_wrap(72)
|
75
83
|
#memo << "\n"
|
76
84
|
end
|
77
85
|
|
@@ -83,7 +91,7 @@ module Reap
|
|
83
91
|
msg << "(from #{msg_file})\n\n"
|
84
92
|
mg = ''
|
85
93
|
File.open( msg_file ) { |f| mg << f.gets(nil) }
|
86
|
-
msg << mg.
|
94
|
+
msg << mg.fold.word_wrap(72)
|
87
95
|
end
|
88
96
|
|
89
97
|
# stamp
|
@@ -122,6 +130,7 @@ module Reap
|
|
122
130
|
}.margin
|
123
131
|
begin
|
124
132
|
# --- Send using SMTP object and an adaptor
|
133
|
+
Net::SMTP.enable_tls if Net::SMTP.respond_to?(:enable_tls) and @tls
|
125
134
|
Net::SMTP.start(@server, @port, @domain, @account, passwd, @authtype) do |s|
|
126
135
|
s.send_message mail, @from, @address
|
127
136
|
end
|
@@ -4,19 +4,16 @@ module Reap
|
|
4
4
|
class ChmodTask < Task
|
5
5
|
|
6
6
|
def self.task; :chmod ; end
|
7
|
-
|
8
7
|
def self.desc; "Change the permissions of package files." ; end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# @group = section['group']
|
14
|
-
# #raise "USER and GROUP are required CHMOD fields." unless @user and @group
|
9
|
+
def setup
|
10
|
+
@user = section['user']
|
11
|
+
@group = section['group']
|
15
12
|
end
|
16
13
|
|
17
14
|
def run
|
18
15
|
puts "Reap is shelling out work to chmod..."
|
19
|
-
|
16
|
+
|
20
17
|
# misc
|
21
18
|
misc = FileList.new
|
22
19
|
misc.include('[A-Z]*')
|
@@ -43,7 +40,7 @@ module Reap
|
|
43
40
|
end
|
44
41
|
|
45
42
|
private
|
46
|
-
|
43
|
+
|
47
44
|
def chmod( file_list, file_mode=644, dir_mode=755 )
|
48
45
|
dirs, files = file_list.partition{ |l| File.directory?(l) }
|
49
46
|
unless files.empty?
|
@@ -53,7 +50,7 @@ module Reap
|
|
53
50
|
unless dirs.empty?
|
54
51
|
fstr = '"' + dirs.join('" "') + '"'
|
55
52
|
sh %{chmod #{dir_mode} #{fstr}}
|
56
|
-
end
|
53
|
+
end
|
57
54
|
end
|
58
55
|
|
59
56
|
# def chown( file_list, user, group )
|
@@ -1,5 +1,9 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
begin
|
3
|
+
require 'rubygems'
|
4
|
+
rescue
|
5
|
+
# no rubygems
|
6
|
+
end
|
3
7
|
|
4
8
|
module Reap
|
5
9
|
|
@@ -12,41 +16,41 @@ module Reap
|
|
12
16
|
class PackageTask < Task
|
13
17
|
|
14
18
|
def self.task ; :package ; end
|
15
|
-
|
16
19
|
def self.desc ; "Build standard .tar.gz, .tar.bzip2 and .zip packages." ; end
|
17
20
|
|
21
|
+
def setup
|
22
|
+
@dir = section['dir'] || 'pkg'
|
18
23
|
|
19
|
-
|
20
|
-
@
|
21
|
-
|
22
|
-
@name = section['name'] || @config['name']
|
23
|
-
@version = section['version'] || @config['version'] || '0.0.1'
|
24
|
-
@package_name = @name + '--' + @version
|
24
|
+
@name = section['name'] || master['name']
|
25
|
+
@version = section['version'] || master['version'] || '0.0.1'
|
26
|
+
@package_name = @name + '-' + @version
|
25
27
|
|
26
|
-
@author
|
27
|
-
@email
|
28
|
-
@summary
|
29
|
-
@project
|
30
|
-
@homepage
|
31
|
-
|
32
|
-
@include
|
33
|
-
@exclude
|
28
|
+
@author = section['author'] || master['author']
|
29
|
+
@email = section['email'] || master['email']
|
30
|
+
@summary = section['summary'] || master['summary']
|
31
|
+
@project = section['project'] || master['rubyforge']['project']
|
32
|
+
@homepage = section['homepage'] || master['homepage'] || master['rubyforge']['homepage']
|
33
|
+
|
34
|
+
@include = section['include'] || DEFAULT_INCLUDE
|
35
|
+
@exclude = MUST_EXCLUDE + section['exclude']
|
34
36
|
|
35
37
|
@zip = section['zip'].nil? ? true : section['zip']
|
36
38
|
@gzip = section['gzip'].nil? ? true : section['zip']
|
37
39
|
@bzip2 = section['bzip2'].nil? ? true : section['zip']
|
38
40
|
@gem = section['gem'].nil? ? true : section['gem']
|
39
|
-
|
41
|
+
|
40
42
|
# gem specific
|
41
|
-
if
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
if defined?(Gem)
|
44
|
+
if self['platform']
|
45
|
+
@platform = ::Gem.const_get(section['platform'])
|
46
|
+
else
|
47
|
+
@platform = ::Gem::Platform::RUBY
|
48
|
+
end
|
49
|
+
@autorequire = section['autorequire']
|
50
|
+
@requirements = section['requirements'] || []
|
51
|
+
@dependencies = section['dependencies'] || []
|
52
|
+
@executables = section['executables'] || []
|
45
53
|
end
|
46
|
-
@autorequire = section['autorequire']
|
47
|
-
@requirements = section['requirements'] || []
|
48
|
-
@dependencies = section['dependencies'] || []
|
49
|
-
@executables = section['executables'] || []
|
50
54
|
end
|
51
55
|
|
52
56
|
def run
|
@@ -81,7 +85,7 @@ module Reap
|
|
81
85
|
FileUtils.safe_ln(fn, f)
|
82
86
|
end
|
83
87
|
end
|
84
|
-
|
88
|
+
|
85
89
|
# create standard package files
|
86
90
|
FileUtils.chdir(@dir) do
|
87
91
|
# tar bzip2 for unix
|
@@ -103,14 +107,14 @@ module Reap
|
|
103
107
|
end
|
104
108
|
|
105
109
|
# create gem package
|
106
|
-
if @gem
|
110
|
+
if defined?(Gem) and @gem
|
107
111
|
run_gem
|
108
112
|
end
|
109
113
|
return true
|
110
114
|
end
|
111
115
|
|
112
116
|
private
|
113
|
-
|
117
|
+
|
114
118
|
def run_gem
|
115
119
|
spec = Gem::Specification.new { |s|
|
116
120
|
s.name = @name
|
@@ -147,7 +151,7 @@ module Reap
|
|
147
151
|
Gem::Builder.new(spec).build
|
148
152
|
sh %{mv ./*.gem #{@dir}/}
|
149
153
|
end
|
150
|
-
|
154
|
+
|
151
155
|
end #class PackageTask
|
152
156
|
|
153
157
|
end #module Reap
|
@@ -2,28 +2,34 @@
|
|
2
2
|
module Reap
|
3
3
|
|
4
4
|
class PublishTask < Task
|
5
|
-
|
5
|
+
|
6
6
|
def self.task ; :publish ; end
|
7
|
-
|
8
7
|
def self.desc ; "Publish documents to the web." ; end
|
9
|
-
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@
|
15
|
-
@
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@host = section['host'].to_s.downcase || 'rubyforge'
|
12
|
+
@type = (section['type'] || 'www').to_s.downcase
|
13
|
+
@command = section['command']
|
14
|
+
@dir = section['dir']
|
15
|
+
#@exclude = section['exclude']
|
16
|
+
@project = section['project']
|
17
|
+
@username = section['username']
|
16
18
|
end
|
17
19
|
|
18
20
|
def run
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
case @host
|
22
|
+
when 'rubyforge'
|
23
|
+
case @type
|
24
|
+
when 'www', 'web'
|
25
|
+
cmd = %{scp -r #{@dir}/* #{@username}@rubyforge.org:/var/www/gforge-projects/#{@project}/}
|
26
|
+
else
|
27
|
+
puts %{Unrecognized publishing type '#{@type}' for host '#{@host}'.}
|
28
|
+
end
|
29
|
+
else
|
30
|
+
puts %{Unrecognized publishing host '#{@host}'.}
|
31
|
+
end
|
32
|
+
puts "Reap is shelling out publishing work..."
|
27
33
|
puts cmd
|
28
34
|
sh(cmd) unless $PRETEND
|
29
35
|
end
|
data/lib/reap/tasks/rdoc-task.rb
CHANGED
@@ -4,18 +4,16 @@ module Reap
|
|
4
4
|
class RDocTask < Task
|
5
5
|
|
6
6
|
def self.task; :rdoc ; end
|
7
|
-
|
8
7
|
def self.desc ; "Generate RDocs." ; end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@title = section["title"] || @config["title"]
|
9
|
+
def setup
|
10
|
+
@dir = section["dir"] || 'doc'
|
11
|
+
@main = section["main"]
|
12
|
+
@title = section["title"] || master["title"]
|
15
13
|
@template = section["template"] || 'html'
|
16
|
-
@include
|
17
|
-
@exclude
|
18
|
-
@options
|
14
|
+
@include = section["include"] || ['lib/**/*']
|
15
|
+
@exclude = section["exclude"]
|
16
|
+
@options = section["options"] || []
|
19
17
|
end
|
20
18
|
|
21
19
|
def run
|
@@ -30,7 +28,7 @@ module Reap
|
|
30
28
|
FileUtils.rm_r(trash_dir) if FileTest.exists?(trash_dir)
|
31
29
|
FileUtils.mv(@dir, trash_dir)
|
32
30
|
else
|
33
|
-
puts "
|
31
|
+
puts "Reap rdoc task canceled."
|
34
32
|
return nil
|
35
33
|
end
|
36
34
|
end
|
@@ -47,7 +45,7 @@ module Reap
|
|
47
45
|
build << "-T '#{@template}'" if @template
|
48
46
|
rdoc_opts = build.join(' ')
|
49
47
|
# do it!
|
50
|
-
puts "
|
48
|
+
puts "Reap is shelling work out to RDoc..."
|
51
49
|
puts %{rdoc -o #{@dir} #{rdoc_opts}}
|
52
50
|
sh %{rdoc -o #{rdoc_dir} #{rdoc_opts} #{rdoc_files}}
|
53
51
|
end
|
@@ -1,38 +1,39 @@
|
|
1
1
|
|
2
2
|
require 'fileutils'
|
3
|
+
require 'rbconfig'
|
3
4
|
|
4
5
|
module Reap
|
5
6
|
|
6
7
|
class TemplateTask < Task
|
7
|
-
|
8
|
+
|
9
|
+
DATA_DIR = 'site_ruby/reap'
|
10
|
+
|
8
11
|
def self.task ; :template ; end
|
9
|
-
|
10
12
|
def self.desc ; "Create template configuration file in current directory." ; end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
14
|
+
#def setup
|
15
|
+
#end
|
15
16
|
|
16
17
|
def run
|
17
|
-
dir = File.dirname(File.dirname(__FILE__))
|
18
|
-
tmpf = File.join( dir, 'template.
|
18
|
+
dir = File.join( ::Config::CONFIG['datadir'], DATA_DIR ) #File.dirname(File.dirname(__FILE__))
|
19
|
+
tmpf = File.join( dir, 'template.yaml' )
|
19
20
|
unless File.file?( tmpf )
|
20
21
|
puts tmpf
|
21
22
|
raise "Tempfile is missing."
|
22
23
|
end
|
23
|
-
|
24
|
+
|
24
25
|
if File.directory?("Reapfile")
|
25
26
|
puts "Why is Reapfile a directory? Cannot comply."
|
26
27
|
return
|
27
28
|
elsif File.file?("Reapfile")
|
28
29
|
puts "Reapfile already exists."
|
29
|
-
return
|
30
|
+
return
|
30
31
|
end
|
31
32
|
# copy tmpf to Reapfile
|
32
33
|
FileUtils.cp( tmpf, "Reapfile" )
|
33
|
-
puts "Reapfile
|
34
|
+
puts "Reapfile created. You'll need to fill it out."
|
34
35
|
end
|
35
|
-
|
36
|
+
|
36
37
|
end #class Template
|
37
38
|
|
38
39
|
end #module Reap
|
data/lib/reap/tasks/test-task.rb
CHANGED
@@ -1,18 +1,27 @@
|
|
1
1
|
|
2
|
+
require 'nano/string/tab'
|
3
|
+
|
4
|
+
#require 'test/unit'
|
5
|
+
require 'test/unit/ui/testrunnermediator'
|
6
|
+
|
7
|
+
Test::Unit.run = true # don't run auto tests
|
8
|
+
|
2
9
|
module Reap
|
3
10
|
|
4
11
|
class TestTask < Task
|
5
12
|
|
6
13
|
def self.task ; :test ; end
|
7
|
-
|
8
14
|
def self.desc ; "Run unit tests." ; end
|
9
15
|
|
16
|
+
def setup
|
17
|
+
@libs = ( section["libs"] || ['lib'] ).join(':')
|
18
|
+
#@libs = (section["libs"] || []).join(':')
|
19
|
+
@files = section["files"] || [ 'test/**/tc*.rb', 'test/**/test*.rb', 'test/**/*test.rb' ]
|
20
|
+
@options = section['options']
|
10
21
|
|
11
|
-
|
12
|
-
@
|
13
|
-
|
14
|
-
@files = section["files"] || [ 'test/**/tc*.rb', 'test/**/test*.rb', 'test/**/*test.rb' ]
|
15
|
-
@options = section['options']
|
22
|
+
@results = TestResults.new
|
23
|
+
@errors = []
|
24
|
+
@failures = []
|
16
25
|
end
|
17
26
|
|
18
27
|
def run
|
@@ -24,22 +33,108 @@ module Reap
|
|
24
33
|
puts "No test files found."
|
25
34
|
return
|
26
35
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
36
|
+
print "Reap is shelling out work to Ruby's Test Suite..."
|
37
|
+
|
38
|
+
test_files.each { |f|
|
39
|
+
$stdout << '.'; $stdout.flush
|
40
|
+
run_test( f )
|
41
|
+
#ruby %{-r"test/unit" "#{f}"}
|
42
|
+
}
|
43
|
+
puts "done."
|
44
|
+
|
45
|
+
# Display Failures
|
46
|
+
puts
|
47
|
+
puts %{FAILURES:#{@failures.empty? ? ' []' : ''}}
|
48
|
+
@failures.reverse.each { |fails|
|
49
|
+
fails.reverse.each { |failure|
|
50
|
+
puts
|
51
|
+
puts %{ - test : #{failure.test_name}}
|
52
|
+
puts %{ message : #{failure.message.gsub("\n"," ")}}
|
53
|
+
puts %{ location : #{failure.location}}
|
33
54
|
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
55
|
+
}
|
56
|
+
|
57
|
+
# Display Errors
|
58
|
+
puts
|
59
|
+
puts %{ERRORS:#{@errors.empty? ? ' []' : ''}}
|
60
|
+
@errors.reverse.each { |errs|
|
61
|
+
errs.reverse.each { |err|
|
62
|
+
puts
|
63
|
+
puts %{ - test : #{err.test_name}}
|
64
|
+
puts %{ message : #{err.exception.message}}
|
65
|
+
puts %{ backtrace :}
|
66
|
+
err.exception.backtrace[0...-1].each { |bt| puts %Q{ - #{bt}} }
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
# Display Final Results
|
71
|
+
puts
|
72
|
+
puts @results
|
73
|
+
puts
|
74
|
+
|
75
|
+
# old way (don't work right)
|
76
|
+
#puts %Q{ ruby %{-I#{test_libs} -e0 -r"test/unit" \\\n#{test_reqs}#{test_opts}} } if $DEBUG
|
77
|
+
#ruby %{-I#{test_libs} -e0 -r"test/unit" \\\n#{test_reqs}#{test_opts}}
|
78
|
+
#ruby %{-e0 -r"test/unit" \\\n#{test_reqs}#{test_opts}}
|
79
|
+
end
|
80
|
+
|
81
|
+
def run_test( test_file )
|
82
|
+
if ! File.file?( test_file )
|
83
|
+
r = nil
|
84
|
+
else
|
85
|
+
r = fork_test( test_file )
|
86
|
+
end
|
87
|
+
unless r.passed?
|
88
|
+
@errors << r.instance_variable_get('@errors')
|
89
|
+
@failures << r.instance_variable_get('@failures')
|
90
|
+
end
|
91
|
+
@results << r
|
92
|
+
end
|
93
|
+
|
94
|
+
def fork_test( testfile )
|
95
|
+
src = %Q{
|
96
|
+
#require 'test/unit'
|
97
|
+
require 'test/unit/collector'
|
98
|
+
require 'test/unit/collector/objectspace'
|
99
|
+
require 'test/unit/ui/testrunnermediator'
|
100
|
+
load('#{testfile}')
|
101
|
+
tests = Test::Unit::Collector::ObjectSpace.new.collect
|
102
|
+
runner = Test::Unit::UI::TestRunnerMediator.new( tests )
|
103
|
+
result = runner.run_suite
|
104
|
+
puts Marshal.dump(result)
|
105
|
+
}
|
106
|
+
result = IO.popen("ruby","w+") do |ruby|
|
107
|
+
ruby.puts src
|
108
|
+
ruby.close_write
|
109
|
+
ruby.read
|
40
110
|
end
|
111
|
+
return Marshal.load(result)
|
41
112
|
end
|
42
113
|
|
43
|
-
|
44
|
-
|
114
|
+
class TestResults
|
115
|
+
attr_reader :assertion_count, :run_count, :failure_count, :error_count
|
116
|
+
def initialize
|
117
|
+
@assertion_count = 0
|
118
|
+
@run_count = 0
|
119
|
+
@failure_count = 0
|
120
|
+
@error_count = 0
|
121
|
+
end
|
122
|
+
def <<( result )
|
123
|
+
@assertion_count += result.assertion_count
|
124
|
+
@run_count += result.run_count
|
125
|
+
@failure_count += result.failure_count
|
126
|
+
@error_count += result.error_count
|
127
|
+
end
|
128
|
+
def to_s
|
129
|
+
s = %{SUMMARY:\n\n}
|
130
|
+
s << %{ tests : #{@run_count}\n}
|
131
|
+
s << %{ assertions : #{@assertion_count}\n}
|
132
|
+
s << %{ failures : #{@failure_count}\n}
|
133
|
+
s << %{ errors : #{@error_count}\n}
|
134
|
+
s
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
end #class TestTask
|
139
|
+
|
45
140
|
end #module Reap
|