DTR 0.0.1
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/CHANGES +2 -0
- data/LICENSE.TXT +203 -0
- data/README +152 -0
- data/Rakefile +368 -0
- data/TODO +11 -0
- data/bin/dtr +64 -0
- data/doc/jamis.rb +591 -0
- data/install.rb +89 -0
- data/lib/dtr/base.rb +281 -0
- data/lib/dtr/command_line.rb +173 -0
- data/lib/dtr/drb_dtr.rb +275 -0
- data/lib/dtr/ruby_ext.rb +27 -0
- data/lib/dtr.rb +88 -0
- data/show_process_exit_code.bat +5 -0
- data/test/average_packer_test.rb +32 -0
- data/test/base_test.rb +236 -0
- data/test/original_test_reports_test.rb +91 -0
- data/test/ruby_ext_test.rb +13 -0
- data/test/ruby_runner_test.rb +56 -0
- data/test/scenario_setup_and_run_tests_simply.rb +51 -0
- data/test/server_test.rb +39 -0
- data/test/test_helper.rb +108 -0
- metadata +82 -0
data/Rakefile
ADDED
@@ -0,0 +1,368 @@
|
|
1
|
+
# Rakefile for DTR -*- ruby -*-
|
2
|
+
|
3
|
+
# Copyright 2007 by Li Xiao (swing1979@gmail.com)
|
4
|
+
# All rights reserved.
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib')
|
7
|
+
require 'dtr'
|
8
|
+
|
9
|
+
require 'rake/clean'
|
10
|
+
require 'rake/testtask'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'rubygems'
|
15
|
+
require 'rake/gempackagetask'
|
16
|
+
rescue Exception
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
CLEAN.include('**/*.o', '*.dot')
|
20
|
+
CLOBBER.include('TAGS')
|
21
|
+
CLOBBER.include('coverage', 'rcov_aggregate')
|
22
|
+
|
23
|
+
def announce(msg='')
|
24
|
+
STDERR.puts msg
|
25
|
+
end
|
26
|
+
|
27
|
+
if `ruby -Ilib ./bin/dtr --version` =~ /dtr, version ([0-9.]+)$/
|
28
|
+
CURRENT_VERSION = $1
|
29
|
+
else
|
30
|
+
CURRENT_VERSION = "0.0.0"
|
31
|
+
end
|
32
|
+
|
33
|
+
$package_version = CURRENT_VERSION
|
34
|
+
|
35
|
+
SRC_RB = FileList['lib/**/*.rb']
|
36
|
+
|
37
|
+
# The default task is run if rake is given no explicit arguments.
|
38
|
+
|
39
|
+
desc "Default Task"
|
40
|
+
task :default => :test_all
|
41
|
+
|
42
|
+
# Test Tasks ---------------------------------------------------------
|
43
|
+
task :dbg do |t|
|
44
|
+
puts "Arguments are: #{t.args.join(', ')}"
|
45
|
+
end
|
46
|
+
|
47
|
+
# Common Abbreviations ...
|
48
|
+
|
49
|
+
task :test_all => [:test_units, :test_functionals]
|
50
|
+
task :tu => :test_units
|
51
|
+
task :tf => :test_functionals
|
52
|
+
task :test => :test_units
|
53
|
+
|
54
|
+
Rake::TestTask.new(:test_units) do |t|
|
55
|
+
t.test_files = FileList['test/*test.rb']
|
56
|
+
t.warning = true
|
57
|
+
t.verbose = false
|
58
|
+
end
|
59
|
+
|
60
|
+
Rake::TestTask.new(:test_functionals) do |t|
|
61
|
+
t.test_files = FileList['test/scenario*.rb']
|
62
|
+
t.warning = true
|
63
|
+
t.verbose = false
|
64
|
+
end
|
65
|
+
|
66
|
+
begin
|
67
|
+
require 'rcov/rcovtask'
|
68
|
+
|
69
|
+
Rcov::RcovTask.new do |t|
|
70
|
+
t.libs << "test"
|
71
|
+
t.rcov_opts = [
|
72
|
+
'-xRakefile', '-xrakefile', '-xpublish.rf', '--text-report',
|
73
|
+
]
|
74
|
+
t.test_files = FileList[
|
75
|
+
'test/*test.rb'
|
76
|
+
]
|
77
|
+
t.output_dir = 'coverage'
|
78
|
+
t.verbose = true
|
79
|
+
end
|
80
|
+
rescue LoadError
|
81
|
+
# No rcov available
|
82
|
+
end
|
83
|
+
|
84
|
+
directory 'testdata'
|
85
|
+
[:test_units].each do |t|
|
86
|
+
task t => ['testdata']
|
87
|
+
end
|
88
|
+
|
89
|
+
# CVS Tasks ----------------------------------------------------------
|
90
|
+
|
91
|
+
# Install DTR using the standard install.rb script.
|
92
|
+
|
93
|
+
desc "Install the application"
|
94
|
+
task :install do
|
95
|
+
ruby "install.rb"
|
96
|
+
end
|
97
|
+
|
98
|
+
# Create a task to build the RDOC documentation tree.
|
99
|
+
|
100
|
+
rd = Rake::RDocTask.new("rdoc") { |rdoc|
|
101
|
+
rdoc.rdoc_dir = 'html'
|
102
|
+
# rdoc.template = 'kilmer'
|
103
|
+
# rdoc.template = 'css2'
|
104
|
+
rdoc.template = 'doc/jamis.rb'
|
105
|
+
rdoc.title = "DTR -- Distributed Test Runner"
|
106
|
+
rdoc.options << '--line-numbers' << '--inline-source' <<
|
107
|
+
'--main' << 'README' <<
|
108
|
+
'--title' << '"DTR -- Distributed Test Runner'
|
109
|
+
rdoc.rdoc_files.include('README', 'LICENSE.txt', 'TODO', 'CHANGES')
|
110
|
+
rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
|
111
|
+
}
|
112
|
+
|
113
|
+
# ====================================================================
|
114
|
+
# Create a task that will package the DTR software into distributable
|
115
|
+
# tar, zip and gem files.
|
116
|
+
|
117
|
+
PKG_FILES = FileList[
|
118
|
+
'install.rb',
|
119
|
+
'[A-Z]*',
|
120
|
+
'bin/**/*',
|
121
|
+
'lib/**/*.rb',
|
122
|
+
'test/**/*.rb',
|
123
|
+
'doc/**/*'
|
124
|
+
]
|
125
|
+
PKG_FILES.exclude('doc/example/*.o')
|
126
|
+
PKG_FILES.exclude(%r{doc/example/main$})
|
127
|
+
|
128
|
+
if ! defined?(Gem)
|
129
|
+
puts "Package Target requires RubyGEMs"
|
130
|
+
else
|
131
|
+
spec = Gem::Specification.new do |s|
|
132
|
+
|
133
|
+
#### Basic information.
|
134
|
+
|
135
|
+
s.name = 'DTR'
|
136
|
+
s.version = $package_version
|
137
|
+
s.summary = "DTR is a distributed test runner to run tests on distributed computers for decreasing build time."
|
138
|
+
|
139
|
+
#### Dependencies and requirements.
|
140
|
+
|
141
|
+
s.add_dependency('progressbar', '> 0.0.2')
|
142
|
+
#s.requirements << ""
|
143
|
+
|
144
|
+
#### Which files are to be included in this gem? Everything! (Except SVN directories.)
|
145
|
+
|
146
|
+
s.files = PKG_FILES.to_a.delete_if {|item| item.include?(".svn")}
|
147
|
+
|
148
|
+
#### Load-time details: library and application (you will need one or both).
|
149
|
+
|
150
|
+
s.require_path = 'lib' # Use these for libraries.
|
151
|
+
|
152
|
+
s.bindir = "bin" # Use these for applications.
|
153
|
+
s.executables = ["dtr"]
|
154
|
+
s.default_executable = "dtr"
|
155
|
+
|
156
|
+
#### Documentation and testing.
|
157
|
+
|
158
|
+
s.has_rdoc = false
|
159
|
+
#s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
|
160
|
+
#s.rdoc_options = rd.options
|
161
|
+
|
162
|
+
#### Author and project details.
|
163
|
+
|
164
|
+
s.author = "Li Xiao"
|
165
|
+
s.email = "swing1979@gmail.com"
|
166
|
+
s.homepage = "http://dtr.rubyforge.org"
|
167
|
+
s.rubyforge_project = "dtr"
|
168
|
+
# if ENV['CERT_DIR']
|
169
|
+
# s.signing_key = File.join(ENV['CERT_DIR'], 'gem-private_key.pem')
|
170
|
+
# s.cert_chain = [File.join(ENV['CERT_DIR'], 'gem-public_cert.pem')]
|
171
|
+
# end
|
172
|
+
end
|
173
|
+
|
174
|
+
package_task = Rake::GemPackageTask.new(spec) do |pkg|
|
175
|
+
#pkg.need_zip = true
|
176
|
+
#pkg.need_tar = true
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
# Misc tasks =========================================================
|
181
|
+
|
182
|
+
def count_lines(filename)
|
183
|
+
lines = 0
|
184
|
+
codelines = 0
|
185
|
+
open(filename) { |f|
|
186
|
+
f.each do |line|
|
187
|
+
lines += 1
|
188
|
+
next if line =~ /^\s*$/
|
189
|
+
next if line =~ /^\s*#/
|
190
|
+
codelines += 1
|
191
|
+
end
|
192
|
+
}
|
193
|
+
[lines, codelines]
|
194
|
+
end
|
195
|
+
|
196
|
+
def show_line(msg, lines, loc)
|
197
|
+
printf "%6s %6s %s\n", lines.to_s, loc.to_s, msg
|
198
|
+
end
|
199
|
+
|
200
|
+
desc "Count lines in the main DTR file"
|
201
|
+
task :lines do
|
202
|
+
total_lines = 0
|
203
|
+
total_code = 0
|
204
|
+
show_line("File Name", "LINES", "LOC")
|
205
|
+
SRC_RB.each do |fn|
|
206
|
+
lines, codelines = count_lines(fn)
|
207
|
+
show_line(fn, lines, codelines)
|
208
|
+
total_lines += lines
|
209
|
+
total_code += codelines
|
210
|
+
end
|
211
|
+
show_line("TOTAL", total_lines, total_code)
|
212
|
+
end
|
213
|
+
|
214
|
+
# Define an optional publish target in an external file. If the
|
215
|
+
# publish.rf file is not found, the publish targets won't be defined.
|
216
|
+
|
217
|
+
load "publish.rf" if File.exist? "publish.rf"
|
218
|
+
|
219
|
+
# Support Tasks ------------------------------------------------------
|
220
|
+
|
221
|
+
RUBY_FILES = FileList['**/*.rb'].exclude('pkg')
|
222
|
+
|
223
|
+
desc "Look for TODO and FIXME tags in the code"
|
224
|
+
task :todo do
|
225
|
+
RUBY_FILES.egrep(/#.*(FIXME|TODO|TBD)/)
|
226
|
+
end
|
227
|
+
|
228
|
+
desc "Look for Debugging print lines"
|
229
|
+
task :dbg do
|
230
|
+
RUBY_FILES.egrep(/\bDBG|\bbreakpoint\b/)
|
231
|
+
end
|
232
|
+
|
233
|
+
desc "List all ruby files"
|
234
|
+
task :rubyfiles do
|
235
|
+
puts RUBY_FILES
|
236
|
+
puts FileList['bin/*'].exclude('bin/*.rb')
|
237
|
+
end
|
238
|
+
task :rf => :rubyfiles
|
239
|
+
|
240
|
+
desc "Create a TAGS file"
|
241
|
+
task :tags => "TAGS"
|
242
|
+
|
243
|
+
TAGS = 'xctags -e'
|
244
|
+
|
245
|
+
file "TAGS" => RUBY_FILES do
|
246
|
+
puts "Makings TAGS"
|
247
|
+
sh "#{TAGS} #{RUBY_FILES}", :verbose => false
|
248
|
+
end
|
249
|
+
|
250
|
+
# --------------------------------------------------------------------
|
251
|
+
# Creating a release
|
252
|
+
|
253
|
+
task :noop
|
254
|
+
|
255
|
+
desc "[rel, reuse, reltest] Make a new release"
|
256
|
+
task :release => [
|
257
|
+
:prerelease,
|
258
|
+
:clobber,
|
259
|
+
:test_all,
|
260
|
+
:update_version,
|
261
|
+
:package,
|
262
|
+
:tag] do
|
263
|
+
|
264
|
+
announce
|
265
|
+
announce "**************************************************************"
|
266
|
+
announce "* Release #{$package_version} Complete."
|
267
|
+
announce "* Packages ready to upload."
|
268
|
+
announce "**************************************************************"
|
269
|
+
announce
|
270
|
+
end
|
271
|
+
|
272
|
+
# Validate that everything is ready to go for a release.
|
273
|
+
desc "[rel, reuse, reltest]"
|
274
|
+
task :prerelease do |t, rel, reuse, reltest|
|
275
|
+
$package_version = rel
|
276
|
+
announce
|
277
|
+
announce "**************************************************************"
|
278
|
+
announce "* Making RubyGem Release #{$package_version}"
|
279
|
+
announce "* (current version #{CURRENT_VERSION})"
|
280
|
+
announce "**************************************************************"
|
281
|
+
announce
|
282
|
+
|
283
|
+
# Is a release number supplied?
|
284
|
+
unless rel
|
285
|
+
fail "Usage: rake release[X.Y.Z] [REUSE=tag_suffix]"
|
286
|
+
end
|
287
|
+
|
288
|
+
# Is the release different than the current release.
|
289
|
+
# (or is REUSE set?)
|
290
|
+
if $package_version == CURRENT_VERSION && ! reuse
|
291
|
+
fail "Current version is #{$package_version}, must specify REUSE=tag_suffix to reuse version"
|
292
|
+
end
|
293
|
+
|
294
|
+
# Are all source files checked in?
|
295
|
+
if reltest
|
296
|
+
announce "Release Task Testing, skipping checked-in file test"
|
297
|
+
else
|
298
|
+
announce "Checking for unchecked-in files..."
|
299
|
+
data = `svn st`
|
300
|
+
unless data =~ /^$/
|
301
|
+
abort "svn status is not clean ... do you have unchecked-in files?"
|
302
|
+
end
|
303
|
+
announce "No outstanding checkins found ... OK"
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
desc "[rel, reuse, reltest]"
|
308
|
+
task :update_version => [:prerelease] do |t, rel, reuse, reltest|
|
309
|
+
if rel == CURRENT_VERSION
|
310
|
+
announce "No version change ... skipping version update"
|
311
|
+
else
|
312
|
+
announce "Updating DTR version to #{rel}"
|
313
|
+
open("lib/dtr.rb") do |dtrin|
|
314
|
+
open("lib/dtr.rb.new", "w") do |dtrout|
|
315
|
+
dtrin.each do |line|
|
316
|
+
if line =~ /^DTRVERSION\s*=\s*/
|
317
|
+
dtrout.puts "DTRVERSION = '#{rel}'"
|
318
|
+
else
|
319
|
+
dtrout.puts line
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
mv "lib/dtr.rb.new", "lib/dtr.rb"
|
325
|
+
if reltest
|
326
|
+
announce "Release Task Testing, skipping commiting of new version"
|
327
|
+
else
|
328
|
+
sh %{svn commit -m "Updated to version #{rel}" lib/dtr.rb} # "
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
desc "[rel, reuse, reltest] Tag all the CVS files with the latest release number (REL=x.y.z)"
|
334
|
+
task :tag => [:prerelease] do |t, rel, reuse, reltest|
|
335
|
+
reltag = "REL_#{rel.gsub(/\./, '_')}"
|
336
|
+
reltag << reuse.gsub(/\./, '_') if reuse
|
337
|
+
announce "Tagging Repository with [#{reltag}]"
|
338
|
+
if reltest
|
339
|
+
announce "Release Task Testing, skipping CVS tagging"
|
340
|
+
else
|
341
|
+
sh %{svn copy svn+ssh://rubyforge.org/var/svn/dtr/trunk svn+ssh://rubyforge.org/var/svn/dtr/tags/#{reltag} -m 'Commiting release #{reltag}'}
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
desc "Install the jamis RDoc template"
|
346
|
+
task :install_jamis_template do
|
347
|
+
require 'rbconfig'
|
348
|
+
dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html")
|
349
|
+
fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir)
|
350
|
+
install "doc/jamis.rb", dest_dir, :verbose => true
|
351
|
+
end
|
352
|
+
|
353
|
+
|
354
|
+
task :run_dtr_lots do
|
355
|
+
Dir.chdir('testdata') do
|
356
|
+
begin
|
357
|
+
FileUtils.makedirs 'run_dtr_lots'
|
358
|
+
test_files = Array.new(10) do |index|
|
359
|
+
test_file = "run_dtr_lots/test#{index}.rb"
|
360
|
+
FileUtils.copy_file 'a_test_case.rb', test_file
|
361
|
+
test_file
|
362
|
+
end
|
363
|
+
DTR.run test_files, ['druby://localhost:3344']
|
364
|
+
ensure
|
365
|
+
FileUtils.rm_rf 'run_dtr_lots'
|
366
|
+
end
|
367
|
+
end
|
368
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
= DTR Project -- To Do List
|
2
|
+
|
3
|
+
Send suggestions for this list to swing1979@gmail.com
|
4
|
+
|
5
|
+
=== To Do
|
6
|
+
17. check thread safe
|
7
|
+
18. integrate with cc.rb
|
8
|
+
19. error log trace has file path on client
|
9
|
+
20. rake task
|
10
|
+
21. good example in README
|
11
|
+
(moved DONE list to CHANGES file)
|
data/bin/dtr
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
begin
|
3
|
+
require 'dtr'
|
4
|
+
rescue LoadError
|
5
|
+
require 'rubygems'
|
6
|
+
require 'dtr'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'optparse'
|
10
|
+
require 'logger'
|
11
|
+
|
12
|
+
opts = OptionParser.new do |opts|
|
13
|
+
opts.banner = "DTR client server usage: #{$0} [options]"
|
14
|
+
opts.separator ""
|
15
|
+
opts.separator "Synopsis:"
|
16
|
+
opts.separator "dtr -s 'DTR server uri'"
|
17
|
+
opts.separator ""
|
18
|
+
opts.separator "Options:"
|
19
|
+
|
20
|
+
opts.on("-s", "--server_uri SERVER_URI", "DTR server uri") do |server_uri|
|
21
|
+
DTROPTIONS[:server_uri] = server_uri.untaint
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on("-n", "--name NAME", "DTR client server name, the default is string 'client' with a time stamp.") do |name|
|
25
|
+
DTROPTIONS[:client_name] = name.untaint
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-o", "--output_dir OUTPUT_DIR", "the dir for DTR client server to output logs, the default is 'dtr_tmp'.") do |output_dir|
|
29
|
+
DTROPTIONS[:tmp_dir] = output_dir.untaint
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.on("-i", "--setup COMMAND", "Define the command for initializing test environment, the default is 'rake db:test:prepare'") do |command|
|
33
|
+
DTROPTIONS[:setup] = command.untaint
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.on("-p", "--port PORT", "Define DTR client server port, the default is 3344") do |port|
|
37
|
+
DTROPTIONS[:port] = port.untaint
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on_tail("-t", "--trace", "Turn on invoke/execute tracing.") do
|
41
|
+
DTROPTIONS[:log_level] = Logger::DEBUG
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on_tail("-u", "--stdout", "Print all log into stdout.") do
|
45
|
+
DTROPTIONS[:output_model] = :stdout
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on_tail("-v", "--version", "Show version") do
|
49
|
+
puts "dtr, version " + DTRVERSION
|
50
|
+
DTROPTIONS[:exit] = true
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on_tail("-h", "--help", "Show this help doc") do
|
54
|
+
puts opts
|
55
|
+
DTROPTIONS[:exit] = true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
begin
|
60
|
+
opts.parse!
|
61
|
+
DTR.start_client_server unless DTROPTIONS[:exit]
|
62
|
+
rescue Exception => e
|
63
|
+
logger.error { e }
|
64
|
+
end
|