rubysl-test-unit 1.0.1 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,184 @@
1
+ require 'test/unit'
2
+
3
+ module Test
4
+ module Unit
5
+ class Worker < Runner # :nodoc:
6
+ class << self
7
+ undef autorun
8
+ end
9
+
10
+ alias orig_run_suite mini_run_suite
11
+ undef _run_suite
12
+ undef _run_suites
13
+ undef run
14
+
15
+ def increment_io(orig) # :nodoc:
16
+ *rest, io = 32.times.inject([orig.dup]){|ios, | ios << ios.last.dup }
17
+ rest.each(&:close)
18
+ io
19
+ end
20
+
21
+ def _run_suites(suites, type) # :nodoc:
22
+ suites.map do |suite|
23
+ _run_suite(suite, type)
24
+ end
25
+ end
26
+
27
+ def _run_suite(suite, type) # :nodoc:
28
+ @partial_report = []
29
+ orig_testout = MiniTest::Unit.output
30
+ i,o = IO.pipe
31
+
32
+ MiniTest::Unit.output = o
33
+ orig_stdin, orig_stdout = $stdin, $stdout
34
+
35
+ th = Thread.new do
36
+ begin
37
+ while buf = (self.verbose ? i.gets : i.read(5))
38
+ _report "p", buf
39
+ end
40
+ rescue IOError
41
+ rescue Errno::EPIPE
42
+ end
43
+ end
44
+
45
+ e, f, s = @errors, @failures, @skips
46
+
47
+ begin
48
+ result = orig_run_suite(suite, type)
49
+ rescue Interrupt
50
+ @need_exit = true
51
+ result = [nil,nil]
52
+ end
53
+
54
+ MiniTest::Unit.output = orig_testout
55
+ $stdin = orig_stdin
56
+ $stdout = orig_stdout
57
+
58
+ o.close
59
+ begin
60
+ th.join
61
+ rescue IOError
62
+ raise unless ["stream closed","closed stream"].include? $!.message
63
+ end
64
+ i.close
65
+
66
+ result << @partial_report
67
+ @partial_report = nil
68
+ result << [@errors-e,@failures-f,@skips-s]
69
+ result << ($: - @old_loadpath)
70
+ result << suite.name
71
+
72
+ begin
73
+ _report "done", Marshal.dump(result)
74
+ rescue Errno::EPIPE; end
75
+ return result
76
+ ensure
77
+ MiniTest::Unit.output = orig_stdout
78
+ $stdin = orig_stdin
79
+ $stdout = orig_stdout
80
+ o.close if o && !o.closed?
81
+ i.close if i && !i.closed?
82
+ end
83
+
84
+ def run(args = []) # :nodoc:
85
+ process_args args
86
+ @@stop_auto_run = true
87
+ @opts = @options.dup
88
+ @need_exit = false
89
+
90
+ @old_loadpath = []
91
+ begin
92
+ begin
93
+ @stdout = increment_io(STDOUT)
94
+ @stdin = increment_io(STDIN)
95
+ rescue
96
+ exit 2
97
+ end
98
+ exit 2 unless @stdout && @stdin
99
+
100
+ @stdout.sync = true
101
+ _report "ready!"
102
+ while buf = @stdin.gets
103
+ case buf.chomp
104
+ when /^loadpath (.+?)$/
105
+ @old_loadpath = $:.dup
106
+ $:.push(*Marshal.load($1.unpack("m")[0].force_encoding("ASCII-8BIT"))).uniq!
107
+ when /^run (.+?) (.+?)$/
108
+ _report "okay"
109
+
110
+ @options = @opts.dup
111
+ suites = MiniTest::Unit::TestCase.test_suites
112
+
113
+ begin
114
+ require $1
115
+ rescue LoadError
116
+ _report "after", Marshal.dump([$1, ProxyError.new($!)])
117
+ _report "ready"
118
+ next
119
+ end
120
+ _run_suites MiniTest::Unit::TestCase.test_suites-suites, $2.to_sym
121
+
122
+ if @need_exit
123
+ begin
124
+ _report "bye"
125
+ rescue Errno::EPIPE; end
126
+ exit
127
+ else
128
+ _report "ready"
129
+ end
130
+ when /^quit$/
131
+ begin
132
+ _report "bye"
133
+ rescue Errno::EPIPE; end
134
+ exit
135
+ end
136
+ end
137
+ rescue Errno::EPIPE
138
+ rescue Exception => e
139
+ begin
140
+ trace = e.backtrace
141
+ err = ["#{trace.shift}: #{e.message} (#{e.class})"] + trace.map{|t| t.prepend("\t") }
142
+
143
+ _report "bye", Marshal.dump(err.join("\n"))
144
+ rescue Errno::EPIPE;end
145
+ exit
146
+ ensure
147
+ @stdin.close if @stdin
148
+ @stdout.close if @stdout
149
+ end
150
+ end
151
+
152
+ def _report(res, *args) # :nodoc:
153
+ res = "#{res} #{args.pack("m0")}" unless args.empty?
154
+ @stdout.puts(res)
155
+ end
156
+
157
+ def puke(klass, meth, e) # :nodoc:
158
+ @partial_report << [klass.name, meth, e.is_a?(MiniTest::Assertion) ? e : ProxyError.new(e)]
159
+ super
160
+ end
161
+ end
162
+ end
163
+ end
164
+
165
+ if $0 == __FILE__
166
+ module Test
167
+ module Unit
168
+ class TestCase < MiniTest::Unit::TestCase # :nodoc: all
169
+ undef on_parallel_worker?
170
+ def on_parallel_worker?
171
+ true
172
+ end
173
+ end
174
+ end
175
+ end
176
+ require 'rubygems'
177
+ module Gem # :nodoc:
178
+ end
179
+ class Gem::TestCase < MiniTest::Unit::TestCase # :nodoc:
180
+ @@project_dir = File.expand_path('../../../..', __FILE__)
181
+ end
182
+
183
+ Test::Unit::Worker.new.run(ARGV)
184
+ end
@@ -1,159 +1,33 @@
1
- #--
2
- #
3
- # Author:: Nathaniel Talbott.
4
- # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
5
- # License:: Ruby license.
6
-
7
1
  require 'test/unit/assertions'
8
- require 'test/unit/failure'
9
- require 'test/unit/error'
10
- require 'test/unit/testsuite'
11
- require 'test/unit/assertionfailederror'
12
- require 'test/unit/util/backtracefilter'
13
2
 
14
3
  module Test
15
4
  module Unit
5
+ # remove silly TestCase class
6
+ remove_const(:TestCase) if defined?(self::TestCase)
16
7
 
17
- # Ties everything together. If you subclass and add your own
18
- # test methods, it takes care of making them into tests and
19
- # wrapping those tests into a suite. It also does the
20
- # nitty-gritty of actually running an individual test and
21
- # collecting its results into a Test::Unit::TestResult object.
22
- class TestCase
8
+ class TestCase < MiniTest::Unit::TestCase # :nodoc: all
23
9
  include Assertions
24
- include Util::BacktraceFilter
25
-
26
- attr_reader :method_name
27
-
28
- STARTED = name + "::STARTED"
29
- FINISHED = name + "::FINISHED"
30
-
31
- ##
32
- # These exceptions are not caught by #run.
33
-
34
- PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, Interrupt,
35
- SystemExit]
36
-
37
- # Creates a new instance of the fixture for running the
38
- # test represented by test_method_name.
39
- def initialize(test_method_name)
40
- unless(respond_to?(test_method_name) and
41
- (method(test_method_name).arity == 0 ||
42
- method(test_method_name).arity == -1))
43
- throw :invalid_test
44
- end
45
- @method_name = test_method_name
46
- @test_passed = true
47
- end
48
-
49
- # Rolls up all of the test* methods in the fixture into
50
- # one suite, creating a new instance of the fixture for
51
- # each method.
52
- def self.suite
53
- method_names = public_instance_methods(true)
54
- tests = method_names.delete_if {|method_name| method_name !~ /^test./}
55
- suite = TestSuite.new(name)
56
- tests.sort.each do
57
- |test|
58
- catch(:invalid_test) do
59
- suite << new(test)
60
- end
61
- end
62
- if (suite.empty?)
63
- catch(:invalid_test) do
64
- suite << new("default_test")
65
- end
66
- end
67
- return suite
68
- end
69
-
70
- # Runs the individual test method represented by this
71
- # instance of the fixture, collecting statistics, failures
72
- # and errors in result.
73
- def run(result)
74
- yield(STARTED, name)
75
- @_result = result
76
- begin
77
- setup
78
- __send__(@method_name)
79
- rescue AssertionFailedError => e
80
- add_failure(e.message, e.backtrace)
81
- rescue Exception
82
- raise if PASSTHROUGH_EXCEPTIONS.include? $!.class
83
- add_error($!)
84
- ensure
85
- begin
86
- teardown
87
- rescue AssertionFailedError => e
88
- add_failure(e.message, e.backtrace)
89
- rescue Exception
90
- raise if PASSTHROUGH_EXCEPTIONS.include? $!.class
91
- add_error($!)
92
- end
93
- end
94
- result.add_run
95
- yield(FINISHED, name)
96
- end
97
10
 
98
- # Called before every test method runs. Can be used
99
- # to set up fixture information.
100
- def setup
11
+ def on_parallel_worker?
12
+ false
101
13
  end
102
14
 
103
- # Called after every test method runs. Can be used to tear
104
- # down fixture information.
105
- def teardown
15
+ def run runner
16
+ @options = runner.options
17
+ super runner
106
18
  end
107
-
108
- def default_test
109
- flunk("No tests were specified")
110
- end
111
-
112
- # Returns whether this individual test passed or
113
- # not. Primarily for use in teardown so that artifacts
114
- # can be left behind if the test fails.
115
- def passed?
116
- return @test_passed
117
- end
118
- private :passed?
119
-
120
- def size
121
- 1
122
- end
123
-
124
- def add_assertion
125
- @_result.add_assertion
126
- end
127
- private :add_assertion
128
19
 
129
- def add_failure(message, all_locations=caller())
130
- @test_passed = false
131
- @_result.add_failure(Failure.new(name, filter_backtrace(all_locations), message))
20
+ def self.test_order
21
+ :sorted
132
22
  end
133
- private :add_failure
134
23
 
135
- def add_error(exception)
136
- @test_passed = false
137
- @_result.add_error(Error.new(name, exception))
138
- end
139
- private :add_error
140
-
141
- # Returns a human-readable name for the specific test that
142
- # this instance of TestCase represents.
143
- def name
144
- "#{@method_name}(#{self.class.name})"
145
- end
146
-
147
- # Overridden to return #name.
148
- def to_s
149
- name
150
- end
151
-
152
- # It's handy to be able to compare TestCase instances.
153
- def ==(other)
154
- return false unless(other.kind_of?(self.class))
155
- return false unless(@method_name == other.method_name)
156
- self.class == other.class
24
+ def self.method_added(name)
25
+ return unless name.to_s.start_with?("test_")
26
+ @test_methods ||= {}
27
+ if @test_methods[name]
28
+ warn "test/unit warning: method #{ self }##{ name } is redefined"
29
+ end
30
+ @test_methods[name] = true
157
31
  end
158
32
  end
159
33
  end
@@ -16,10 +16,12 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
18
 
19
+ spec.required_ruby_version = "~> 2.0"
20
+
19
21
  spec.add_runtime_dependency "minitest", "~> 4.7"
20
22
 
21
23
  spec.add_development_dependency "bundler", "~> 1.3"
22
24
  spec.add_development_dependency "rake", "~> 10.0"
23
25
  spec.add_development_dependency "mspec", "~> 1.5"
24
- spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
26
+ spec.add_development_dependency "rubysl-prettyprint", "~> 2.0"
25
27
  end
metadata CHANGED
@@ -1,85 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysl-test-unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Shirai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-16 00:00:00.000000000 Z
11
+ date: 2013-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '10.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.5'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.5'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubysl-prettyprint
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: '1.0'
75
+ version: '2.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: '1.0'
82
+ version: '2.0'
83
83
  description: Ruby standard library unit.
84
84
  email:
85
85
  - brixen@gmail.com
@@ -87,8 +87,8 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - ".gitignore"
91
- - ".travis.yml"
90
+ - .gitignore
91
+ - .travis.yml
92
92
  - Gemfile
93
93
  - LICENSE
94
94
  - README.md
@@ -97,27 +97,9 @@ files:
97
97
  - lib/rubysl/test/unit/unit.rb
98
98
  - lib/rubysl/test/unit/version.rb
99
99
  - lib/test/unit.rb
100
- - lib/test/unit/assertionfailederror.rb
101
100
  - lib/test/unit/assertions.rb
102
- - lib/test/unit/autorunner.rb
103
- - lib/test/unit/collector.rb
104
- - lib/test/unit/collector/dir.rb
105
- - lib/test/unit/collector/objectspace.rb
106
- - lib/test/unit/error.rb
107
- - lib/test/unit/failure.rb
101
+ - lib/test/unit/parallel.rb
108
102
  - lib/test/unit/testcase.rb
109
- - lib/test/unit/testresult.rb
110
- - lib/test/unit/testsuite.rb
111
- - lib/test/unit/ui/console/testrunner.rb
112
- - lib/test/unit/ui/fox/testrunner.rb
113
- - lib/test/unit/ui/gtk/testrunner.rb
114
- - lib/test/unit/ui/gtk2/testrunner.rb
115
- - lib/test/unit/ui/testrunnermediator.rb
116
- - lib/test/unit/ui/testrunnerutilities.rb
117
- - lib/test/unit/ui/tk/testrunner.rb
118
- - lib/test/unit/util/backtracefilter.rb
119
- - lib/test/unit/util/observable.rb
120
- - lib/test/unit/util/procwrapper.rb
121
103
  - rubysl-test-unit.gemspec
122
104
  homepage: https://github.com/rubysl/rubysl-test-unit
123
105
  licenses:
@@ -129,18 +111,19 @@ require_paths:
129
111
  - lib
130
112
  required_ruby_version: !ruby/object:Gem::Requirement
131
113
  requirements:
132
- - - ">="
114
+ - - ~>
133
115
  - !ruby/object:Gem::Version
134
- version: '0'
116
+ version: '2.0'
135
117
  required_rubygems_version: !ruby/object:Gem::Requirement
136
118
  requirements:
137
- - - ">="
119
+ - - '>='
138
120
  - !ruby/object:Gem::Version
139
121
  version: '0'
140
122
  requirements: []
141
123
  rubyforge_project:
142
- rubygems_version: 2.2.2
124
+ rubygems_version: 2.0.7
143
125
  signing_key:
144
126
  specification_version: 4
145
127
  summary: Ruby standard library unit.
146
128
  test_files: []
129
+ has_rdoc: