pkoch-spork-testunit 0.0.7a
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +7 -0
- data/bin/testdrb +17 -0
- data/lib/spork/test_framework/test_unit.rb +97 -0
- metadata +63 -0
data/README.textile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
h1. Test::Unit support for Spork
|
2
|
+
|
3
|
+
This includes a plugin for spork to enable Test::Unit support for spork. It also comes with a very bare-bones drb client to run tests.
|
4
|
+
|
5
|
+
To use it, install the gem, then fire up spork in your project directory (the file test/test_helper.rb must exist to detect that Test::Unit is being used).
|
6
|
+
|
7
|
+
Then, once spork is running, invoke @testdrb@ (e.g. @testdrb -Itest test/your_test.rb@) to run your tests under Spork.
|
data/bin/testdrb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# These fix 1.8.7 test/unit results where a DRbUnknown is returned because the testdrb client doesn't have the classes
|
4
|
+
# in its local namespace. (See issue #2)
|
5
|
+
begin
|
6
|
+
require 'minitest/unit'
|
7
|
+
rescue LoadError
|
8
|
+
# MiniTest is Ruby 1.9, and the classes below only exist in the pre 1.9 test/unit
|
9
|
+
require 'test/unit/testresult'
|
10
|
+
require 'test/unit/failure'
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'drb'
|
14
|
+
DRb.start_service("druby://127.0.0.1:0") # this allows Ruby to do some magical stuff so you can pass an output stream over DRb.
|
15
|
+
test_server = DRbObject.new_with_uri("druby://127.0.0.1:8988")
|
16
|
+
result = test_server.run(ARGV, $stderr, $stdout)
|
17
|
+
|
@@ -0,0 +1,97 @@
|
|
1
|
+
class Spork::TestFramework::TestUnit < Spork::TestFramework
|
2
|
+
DEFAULT_PORT = 8988
|
3
|
+
HELPER_FILE = File.join(Dir.pwd, "test/test_helper.rb")
|
4
|
+
|
5
|
+
def run_tests(argv, stderr, stdout)
|
6
|
+
if defined? MiniTest
|
7
|
+
# Ruby 1.9
|
8
|
+
stdout = Purdytest::IO.new(stdout) if defined? Purdytest # rewrap
|
9
|
+
MiniTest::Unit.output = stdout
|
10
|
+
|
11
|
+
# MiniTest's test/unit does not support -I, -r, or -e
|
12
|
+
# Extract them and remove from arguments that are passed to testrb.
|
13
|
+
argv.each_with_index do |arg, idx|
|
14
|
+
if arg =~ /-I(.*)/
|
15
|
+
if $1 == ''
|
16
|
+
# Path is next argument.
|
17
|
+
include_path = argv[idx + 1]
|
18
|
+
argv[idx + 1] = nil # Will be squashed when compact called.
|
19
|
+
else
|
20
|
+
include_path = $1
|
21
|
+
end
|
22
|
+
$LOAD_PATH << include_path
|
23
|
+
argv[idx] = nil
|
24
|
+
elsif arg =~ /-r(.*)/
|
25
|
+
if $1 == ''
|
26
|
+
# File is next argument.
|
27
|
+
require_file = argv[idx + 1]
|
28
|
+
argv[idx + 1] = nil # Will be squashed when compact called.
|
29
|
+
else
|
30
|
+
require_file = $1
|
31
|
+
end
|
32
|
+
require require_file
|
33
|
+
argv[idx] = nil
|
34
|
+
elsif arg =~ /^-e$/
|
35
|
+
eval argv[idx + 1]
|
36
|
+
argv[idx] = argv[idx + 1] = nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
argv.compact!
|
40
|
+
|
41
|
+
require 'test/unit'
|
42
|
+
if defined? Turn
|
43
|
+
# Use turn's wrapper around minitest
|
44
|
+
if argv.empty?
|
45
|
+
puts "Usage: testrb [options] tests..."
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
runner = Turn::MiniRunner.new
|
49
|
+
config = Turn.config do |c|
|
50
|
+
c.tests = argv
|
51
|
+
c.framework = :minitest
|
52
|
+
end
|
53
|
+
controller = Turn::Controller.new(config)
|
54
|
+
controller.start
|
55
|
+
elsif Test::Unit.respond_to?(:setup_argv)
|
56
|
+
# copied from ruby-1.9.2-p136/bin/testrb:
|
57
|
+
Test::Unit.setup_argv(argv) {|files|
|
58
|
+
if files.empty?
|
59
|
+
puts "Usage: testrb [options] tests..."
|
60
|
+
exit 1
|
61
|
+
end
|
62
|
+
if files.size == 1
|
63
|
+
$0 = File.basename(files[0])
|
64
|
+
else
|
65
|
+
$0 = files.to_s
|
66
|
+
end
|
67
|
+
files
|
68
|
+
}
|
69
|
+
|
70
|
+
MiniTest::Unit.new.run(argv)
|
71
|
+
else
|
72
|
+
# copied from ruby-head/bin/testrb:
|
73
|
+
tests = Test::Unit::AutoRunner.new(true)
|
74
|
+
tests.options.banner.sub!(/\[options\]/, '\& tests...')
|
75
|
+
unless tests.process_args(argv)
|
76
|
+
abort tests.options.banner
|
77
|
+
end
|
78
|
+
files = tests.to_run
|
79
|
+
$0 = files.size == 1 ? File.basename(files[0]) : files.to_s
|
80
|
+
tests.run
|
81
|
+
end
|
82
|
+
else
|
83
|
+
# Ruby 1.8
|
84
|
+
Object.send(:remove_const, :STDOUT); Object.send(:const_set, :STDOUT, stdout)
|
85
|
+
require 'test/unit/autorunner'
|
86
|
+
r = Test::Unit::AutoRunner.new(true)
|
87
|
+
exit(false) unless r.process_args(argv)
|
88
|
+
r.run
|
89
|
+
end
|
90
|
+
rescue => e
|
91
|
+
puts "-"*30
|
92
|
+
puts "Error executing #{argv.join(' ')}"
|
93
|
+
puts e.message
|
94
|
+
puts e.backtrace
|
95
|
+
puts "-"*30
|
96
|
+
end
|
97
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pkoch-spork-testunit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7a
|
5
|
+
prerelease: 5
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tim Harper
|
9
|
+
- Paulo Köch
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-02-11 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: spork
|
17
|
+
requirement: &70326818243580 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.6.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70326818243580
|
26
|
+
description: Test Unit runner for spork
|
27
|
+
email:
|
28
|
+
- timcharper+spork@gmail.com
|
29
|
+
executables:
|
30
|
+
- testdrb
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files:
|
33
|
+
- README.textile
|
34
|
+
files:
|
35
|
+
- bin/testdrb
|
36
|
+
- lib/spork/test_framework/test_unit.rb
|
37
|
+
- README.textile
|
38
|
+
homepage: http://github.com/pkoch/spork-testunit
|
39
|
+
licenses: []
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- --charset=UTF-8
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.8.15
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: spork-testunit
|
63
|
+
test_files: []
|