test-unit 2.5.0 → 2.5.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/Rakefile CHANGED
@@ -7,45 +7,15 @@ require "yaml"
7
7
  require "rubygems"
8
8
  require "rake/clean"
9
9
  require "yard"
10
- require "jeweler"
11
- require "./lib/test/unit/version.rb"
10
+ require "bundler/gem_helper"
12
11
 
13
12
  task :default => :test
14
13
 
15
- def cleanup_white_space(entry)
16
- entry.gsub(/(\A\n+|\n+\z)/, '') + "\n"
17
- end
18
-
19
- version = Test::Unit::VERSION.dup
20
- ENV["VERSION"] = version
21
- spec = nil
22
- Jeweler::Tasks.new do |_spec|
23
- spec = _spec
24
- spec.name = "test-unit"
25
- spec.version = version
26
- spec.rubyforge_project = "test-unit"
27
- spec.homepage = "http://test-unit.rubyforge.org/"
28
- spec.authors = ["Kouhei Sutou", "Haruka Yoshihara"]
29
- spec.email = ["kou@cozmixng.org", "yoshihara@clear-code.com"]
30
- entries = File.read("README.textile").split(/^h2\.\s(.*)$/)
31
- description = cleanup_white_space(entries[entries.index("Description") + 1])
32
- spec.summary, spec.description, = description.split(/\n\n+/, 3)
33
- spec.license = "Ruby's and PSFL (lib/test/unit/diff.rb)"
34
- spec.files = FileList["lib/**/*.rb",
35
- "bin/*",
36
- "sample/*.rb",
37
- "test/**/*",
38
- "README.textile",
39
- "TODO",
40
- "Rakefile",
41
- "COPYING",
42
- "GPL",
43
- "PSFL"]
44
- end
14
+ base_dir = File.dirname(__FILE__)
45
15
 
46
- Rake::Task["release"].prerequisites.clear
47
- Jeweler::RubygemsDotOrgTasks.new do
48
- end
16
+ helper = Bundler::GemHelper.new(base_dir)
17
+ helper.install
18
+ spec = helper.gemspec
49
19
 
50
20
  reference_base_dir = Pathname.new("doc/reference")
51
21
  doc_en_dir = reference_base_dir + "en"
@@ -50,7 +50,7 @@ module Test
50
50
  run_startup(result)
51
51
  while test = @tests.shift
52
52
  @n_tests += test.size
53
- test.run(result, &progress_block)
53
+ run_test(test, result, &progress_block)
54
54
  @passed = false unless test.passed?
55
55
  end
56
56
  run_shutdown(result)
@@ -110,6 +110,40 @@ module Test
110
110
  end
111
111
  end
112
112
 
113
+ def run_test(test, result)
114
+ finished_is_yielded = false
115
+ finished_object_is_yielded = false
116
+ previous_event_name = nil
117
+ test.run(result) do |event_name, *args|
118
+ case previous_event_name
119
+ when Test::Unit::TestCase::STARTED
120
+ if event_name != Test::Unit::TestCase::STARTED_OBJECT
121
+ yield(Test::Unit::TestCase::STARTED_OBJECT, test)
122
+ end
123
+ when Test::Unit::TestCase::FINISHED
124
+ if event_name != Test::Unit::TestCase::FINISHED_OBJECT
125
+ yield(Test::Unit::TestCase::FINISHED_OBJECT, test)
126
+ end
127
+ finished_object_is_yielded = true
128
+ end
129
+
130
+ case event_name
131
+ when Test::Unit::TestCase::STARTED
132
+ finished_is_yielded = false
133
+ finished_object_is_yielded = false
134
+ when Test::Unit::TestCase::FINISHED
135
+ finished_is_yielded = true
136
+ end
137
+
138
+ previous_event_name = event_name
139
+ yield(event_name, *args)
140
+ end
141
+
142
+ if finished_is_yielded and not finished_object_is_yielded
143
+ yield(Test::Unit::TestCase::FINISHED_OBJECT, test)
144
+ end
145
+ end
146
+
113
147
  def run_shutdown(result)
114
148
  return if @test_case.nil? or !@test_case.respond_to?(:shutdown)
115
149
  begin
@@ -169,25 +169,37 @@ module Test
169
169
  end
170
170
 
171
171
  def output_fault_in_detail(fault)
172
- if fault.is_a?(Failure)
172
+ if fault.is_a?(Failure) and
173
+ fault.inspected_expected and fault.inspected_actual
173
174
  output_single(fault.label, fault_color(fault))
174
175
  output(":")
175
176
  output(fault.test_name)
176
177
  output_fault_backtrace(fault)
177
- output_fault_message(fault)
178
+ output_failure_message(fault)
178
179
  else
179
180
  output_single(fault.label, fault_color(fault))
180
181
  if fault.is_a?(Error)
181
182
  output(": #{fault.test_name}")
182
- output(fault.message)
183
+ output_fault_message(fault)
183
184
  else
184
- output(": #{fault.message}")
185
+ if fault.message.include?("\n")
186
+ output(":")
187
+ output_fault_message(fault)
188
+ else
189
+ output(": #{fault.message}")
190
+ end
185
191
  output(fault.test_name)
186
192
  end
187
193
  output_fault_backtrace(fault)
188
194
  end
189
195
  end
190
196
 
197
+ def output_fault_message(fault)
198
+ fault.message.each_line do |line|
199
+ output(" #{line.chomp}")
200
+ end
201
+ end
202
+
191
203
  def output_fault_backtrace(fault)
192
204
  snippet_is_shown = false
193
205
  backtrace = fault.location
@@ -224,42 +236,42 @@ module Test
224
236
  true
225
237
  end
226
238
 
227
- def output_fault_message(fault)
228
- if fault.expected.respond_to?(:encoding) and
229
- fault.actual.respond_to?(:encoding) and
230
- fault.expected.encoding != fault.actual.encoding
239
+ def output_failure_message(failure)
240
+ if failure.expected.respond_to?(:encoding) and
241
+ failure.actual.respond_to?(:encoding) and
242
+ failure.expected.encoding != failure.actual.encoding
231
243
  need_encoding = true
232
244
  else
233
245
  need_encoding = false
234
246
  end
235
- output(fault.user_message) if fault.user_message
247
+ output(failure.user_message) if failure.user_message
236
248
  output_single("<")
237
- output_single(fault.inspected_expected, color("pass"))
249
+ output_single(failure.inspected_expected, color("pass"))
238
250
  output_single(">")
239
251
  if need_encoding
240
252
  output_single("(")
241
- output_single(fault.expected.encoding.name, color("pass"))
253
+ output_single(failure.expected.encoding.name, color("pass"))
242
254
  output_single(")")
243
255
  end
244
256
  output(" expected but was")
245
257
  output_single("<")
246
- output_single(fault.inspected_actual, color("failure"))
258
+ output_single(failure.inspected_actual, color("failure"))
247
259
  output_single(">")
248
260
  if need_encoding
249
261
  output_single("(")
250
- output_single(fault.actual.encoding.name, color("failure"))
262
+ output_single(failure.actual.encoding.name, color("failure"))
251
263
  output_single(")")
252
264
  end
253
265
  output("")
254
- from, to = prepare_for_diff(fault.expected, fault.actual)
266
+ from, to = prepare_for_diff(failure.expected, failure.actual)
255
267
  if from and to
256
268
  from_lines = from.split(/\r?\n/)
257
269
  to_lines = to.split(/\r?\n/)
258
270
  if need_encoding
259
271
  from_lines << ""
260
272
  to_lines << ""
261
- from_lines << "Encoding: #{fault.expected.encoding.name}"
262
- to_lines << "Encoding: #{fault.actual.encoding.name}"
273
+ from_lines << "Encoding: #{failure.expected.encoding.name}"
274
+ to_lines << "Encoding: #{failure.actual.encoding.name}"
263
275
  end
264
276
  differ = ColorizedReadableDiffer.new(from_lines, to_lines, self)
265
277
  if differ.need_diff?
@@ -40,10 +40,7 @@ module Test
40
40
  notify_listeners(RESET, @suite.size)
41
41
  notify_listeners(STARTED, result)
42
42
 
43
-
44
- @suite.run(result) do |channel, value|
45
- notify_listeners(channel, value)
46
- end
43
+ run_suite(result)
47
44
  end
48
45
  ensure
49
46
  elapsed_time = Time.now - start_time
@@ -53,10 +50,6 @@ module Test
53
50
  result
54
51
  end
55
52
 
56
- # Just for backward compatibility.
57
- # @see GitHub#28
58
- alias_method :run_suite, :run
59
-
60
53
  private
61
54
  # A factory method to create the result the mediator
62
55
  # should run with. Can be overridden by subclasses if
@@ -95,6 +88,12 @@ module Test
95
88
  pass_assertion_listener)
96
89
  end
97
90
  end
91
+
92
+ def run_suite(result)
93
+ @suite.run(result) do |channel, value|
94
+ notify_listeners(channel, value)
95
+ end
96
+ end
98
97
  end
99
98
  end
100
99
  end
@@ -1,5 +1,5 @@
1
1
  module Test
2
2
  module Unit
3
- VERSION = '2.5.0'
3
+ VERSION = '2.5.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,10 +10,10 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-06 00:00:00.000000000 Z
13
+ date: 2012-07-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: rake
16
+ name: bundler
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
@@ -29,7 +29,7 @@ dependencies:
29
29
  - !ruby/object:Gem::Version
30
30
  version: '0'
31
31
  - !ruby/object:Gem::Dependency
32
- name: yard
32
+ name: rake
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  none: false
35
35
  requirements:
@@ -45,7 +45,7 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
- name: jeweler
48
+ name: yard
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
@@ -72,97 +72,95 @@ email:
72
72
  - yoshihara@clear-code.com
73
73
  executables: []
74
74
  extensions: []
75
- extra_rdoc_files:
75
+ extra_rdoc_files: []
76
+ files:
76
77
  - README.textile
77
78
  - TODO
78
- files:
79
+ - Rakefile
79
80
  - COPYING
80
81
  - GPL
81
82
  - PSFL
82
- - README.textile
83
- - Rakefile
84
- - TODO
85
83
  - lib/test-unit.rb
86
84
  - lib/test/unit.rb
87
- - lib/test/unit/assertionfailederror.rb
88
- - lib/test/unit/assertions.rb
89
85
  - lib/test/unit/attribute.rb
90
- - lib/test/unit/autorunner.rb
91
- - lib/test/unit/code-snippet-fetcher.rb
92
- - lib/test/unit/collector.rb
93
- - lib/test/unit/collector/descendant.rb
94
- - lib/test/unit/collector/dir.rb
95
- - lib/test/unit/collector/load.rb
96
- - lib/test/unit/collector/objectspace.rb
97
- - lib/test/unit/collector/xml.rb
98
- - lib/test/unit/color-scheme.rb
99
- - lib/test/unit/color.rb
100
86
  - lib/test/unit/data.rb
101
- - lib/test/unit/diff.rb
102
- - lib/test/unit/error.rb
103
- - lib/test/unit/exceptionhandler.rb
104
- - lib/test/unit/failure.rb
105
- - lib/test/unit/fixture.rb
106
- - lib/test/unit/notification.rb
107
- - lib/test/unit/omission.rb
108
- - lib/test/unit/pending.rb
109
- - lib/test/unit/priority.rb
110
- - lib/test/unit/runner/console.rb
87
+ - lib/test/unit/color.rb
88
+ - lib/test/unit/version.rb
111
89
  - lib/test/unit/runner/emacs.rb
90
+ - lib/test/unit/runner/console.rb
112
91
  - lib/test/unit/runner/xml.rb
113
- - lib/test/unit/testcase.rb
114
- - lib/test/unit/testresult.rb
115
- - lib/test/unit/testsuite.rb
116
- - lib/test/unit/testsuitecreator.rb
117
- - lib/test/unit/ui/console/outputlevel.rb
118
- - lib/test/unit/ui/console/testrunner.rb
92
+ - lib/test/unit/ui/testrunnerutilities.rb
119
93
  - lib/test/unit/ui/emacs/testrunner.rb
120
94
  - lib/test/unit/ui/testrunner.rb
121
- - lib/test/unit/ui/testrunnermediator.rb
122
- - lib/test/unit/ui/testrunnerutilities.rb
123
95
  - lib/test/unit/ui/xml/testrunner.rb
124
- - lib/test/unit/util/backtracefilter.rb
96
+ - lib/test/unit/ui/console/outputlevel.rb
97
+ - lib/test/unit/ui/console/testrunner.rb
98
+ - lib/test/unit/ui/testrunnermediator.rb
99
+ - lib/test/unit/assertionfailederror.rb
100
+ - lib/test/unit/failure.rb
101
+ - lib/test/unit/autorunner.rb
102
+ - lib/test/unit/exceptionhandler.rb
103
+ - lib/test/unit/assertions.rb
104
+ - lib/test/unit/error.rb
105
+ - lib/test/unit/omission.rb
106
+ - lib/test/unit/fixture.rb
107
+ - lib/test/unit/collector/descendant.rb
108
+ - lib/test/unit/collector/load.rb
109
+ - lib/test/unit/collector/xml.rb
110
+ - lib/test/unit/collector/dir.rb
111
+ - lib/test/unit/collector/objectspace.rb
112
+ - lib/test/unit/code-snippet-fetcher.rb
113
+ - lib/test/unit/testsuitecreator.rb
114
+ - lib/test/unit/color-scheme.rb
115
+ - lib/test/unit/testcase.rb
125
116
  - lib/test/unit/util/method-owner-finder.rb
126
- - lib/test/unit/util/observable.rb
127
117
  - lib/test/unit/util/output.rb
128
118
  - lib/test/unit/util/procwrapper.rb
129
- - lib/test/unit/version.rb
130
- - sample/adder.rb
131
- - sample/subtracter.rb
132
- - sample/test_adder.rb
119
+ - lib/test/unit/util/observable.rb
120
+ - lib/test/unit/util/backtracefilter.rb
121
+ - lib/test/unit/pending.rb
122
+ - lib/test/unit/testresult.rb
123
+ - lib/test/unit/collector.rb
124
+ - lib/test/unit/diff.rb
125
+ - lib/test/unit/priority.rb
126
+ - lib/test/unit/notification.rb
127
+ - lib/test/unit/testsuite.rb
133
128
  - sample/test_subtracter.rb
129
+ - sample/subtracter.rb
134
130
  - sample/test_user.rb
131
+ - sample/test_adder.rb
132
+ - sample/adder.rb
133
+ - test/testunit-test-util.rb
134
+ - test/test-testcase.rb
135
+ - test/ui/test_testrunmediator.rb
136
+ - test/test_testresult.rb
137
+ - test/test-pending.rb
138
+ - test/test-emacs-runner.rb
139
+ - test/test-fixture.rb
140
+ - test/test-attribute.rb
141
+ - test/test_failure.rb
142
+ - test/test-data.rb
143
+ - test/test_testsuite.rb
144
+ - test/collector/test_objectspace.rb
135
145
  - test/collector/test-descendant.rb
136
- - test/collector/test-load.rb
137
146
  - test/collector/test_dir.rb
138
- - test/collector/test_objectspace.rb
139
- - test/fixtures/plus.csv
147
+ - test/collector/test-load.rb
140
148
  - test/run-test.rb
141
149
  - test/test-assertions.rb
142
- - test/test-attribute.rb
143
- - test/test-code-snippet.rb
144
- - test/test-color-scheme.rb
145
- - test/test-color.rb
146
- - test/test-data.rb
147
- - test/test-diff.rb
148
- - test/test-emacs-runner.rb
149
- - test/test-fixture.rb
150
- - test/test-notification.rb
151
- - test/test-omission.rb
152
- - test/test-pending.rb
153
150
  - test/test-priority.rb
154
- - test/test-testcase.rb
155
- - test/test_error.rb
156
- - test/test_failure.rb
157
- - test/test_testresult.rb
158
- - test/test_testsuite.rb
159
- - test/testunit-test-util.rb
160
- - test/ui/test_testrunmediator.rb
161
- - test/util/test-method-owner-finder.rb
162
- - test/util/test-output.rb
163
151
  - test/util/test_backtracefilter.rb
164
152
  - test/util/test_observable.rb
165
153
  - test/util/test_procwrapper.rb
154
+ - test/util/test-method-owner-finder.rb
155
+ - test/util/test-output.rb
156
+ - test/fixtures/plus.csv
157
+ - test/test-code-snippet.rb
158
+ - test/test_error.rb
159
+ - test/test-diff.rb
160
+ - test/test-notification.rb
161
+ - test/test-color-scheme.rb
162
+ - test/test-omission.rb
163
+ - test/test-color.rb
166
164
  homepage: http://test-unit.rubyforge.org/
167
165
  licenses:
168
166
  - Ruby's and PSFL (lib/test/unit/diff.rb)
@@ -188,4 +186,36 @@ rubygems_version: 1.8.23
188
186
  signing_key:
189
187
  specification_version: 3
190
188
  summary: test-unit - Improved version of Test::Unit bundled in Ruby 1.8.x.
191
- test_files: []
189
+ test_files:
190
+ - test/testunit-test-util.rb
191
+ - test/test-testcase.rb
192
+ - test/ui/test_testrunmediator.rb
193
+ - test/test_testresult.rb
194
+ - test/test-pending.rb
195
+ - test/test-emacs-runner.rb
196
+ - test/test-fixture.rb
197
+ - test/test-attribute.rb
198
+ - test/test_failure.rb
199
+ - test/test-data.rb
200
+ - test/test_testsuite.rb
201
+ - test/collector/test_objectspace.rb
202
+ - test/collector/test-descendant.rb
203
+ - test/collector/test_dir.rb
204
+ - test/collector/test-load.rb
205
+ - test/run-test.rb
206
+ - test/test-assertions.rb
207
+ - test/test-priority.rb
208
+ - test/util/test_backtracefilter.rb
209
+ - test/util/test_observable.rb
210
+ - test/util/test_procwrapper.rb
211
+ - test/util/test-method-owner-finder.rb
212
+ - test/util/test-output.rb
213
+ - test/fixtures/plus.csv
214
+ - test/test-code-snippet.rb
215
+ - test/test_error.rb
216
+ - test/test-diff.rb
217
+ - test/test-notification.rb
218
+ - test/test-color-scheme.rb
219
+ - test/test-omission.rb
220
+ - test/test-color.rb
221
+ has_rdoc: