test-unit 2.4.7 → 2.4.8
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/README.textile +1 -1
- data/lib/test-unit.rb +3 -1
- data/lib/test/unit/ui/console/testrunner.rb +10 -3
- data/lib/test/unit/version.rb +1 -1
- data/test/test-code-snippet.rb +37 -0
- data/test/testunit-test-util.rb +8 -0
- metadata +6 -5
data/README.textile
CHANGED
@@ -9,7 +9,7 @@ test-unit - Improved version of Test::Unit bundled in Ruby
|
|
9
9
|
|
10
10
|
Ruby 1.9.x bundles minitest not Test::Unit. Test::Unit
|
11
11
|
bundled in Ruby 1.8.x had not been improved but unbundled
|
12
|
-
Test::Unit (test-unit)
|
12
|
+
Test::Unit (test-unit) is improved actively.
|
13
13
|
|
14
14
|
h2. Features
|
15
15
|
|
data/lib/test-unit.rb
CHANGED
@@ -189,18 +189,25 @@ module Test
|
|
189
189
|
end
|
190
190
|
|
191
191
|
def output_fault_backtrace(fault)
|
192
|
+
snippet_is_shown = false
|
192
193
|
backtrace = fault.location
|
194
|
+
# workaround for test-spec. :<
|
195
|
+
# see also GitHub:#22
|
196
|
+
backtrace ||= []
|
193
197
|
backtrace.each_with_index do |entry, i|
|
194
198
|
output(entry)
|
195
|
-
|
199
|
+
next if snippet_is_shown
|
200
|
+
snippet_is_shown = output_code_snippet(entry, fault_color(fault))
|
196
201
|
end
|
197
202
|
end
|
198
203
|
|
199
204
|
def output_code_snippet(entry, target_line_color=nil)
|
200
|
-
return unless /\A(.*):(\d+)/ =~ entry
|
205
|
+
return false unless /\A(.*):(\d+)/ =~ entry
|
201
206
|
file = $1
|
202
207
|
line_number = $2.to_i
|
203
208
|
lines = @code_snippet_fetcher.fetch(file, line_number)
|
209
|
+
return false if lines.empty?
|
210
|
+
|
204
211
|
max_n = lines.collect {|n, line, attributes| n}.max
|
205
212
|
digits = (Math.log10(max_n) + 1).truncate
|
206
213
|
lines.each do |n, line, attributes|
|
@@ -214,7 +221,7 @@ module Test
|
|
214
221
|
output(" %2s %*d: %s" % [current_line_mark, digits, n, line],
|
215
222
|
line_color)
|
216
223
|
end
|
217
|
-
|
224
|
+
true
|
218
225
|
end
|
219
226
|
|
220
227
|
def output_fault_message(fault)
|
data/lib/test/unit/version.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "test-unit"
|
2
|
+
require "testunit-test-util"
|
3
|
+
|
4
|
+
class TestCodeSnippet < Test::Unit::TestCase
|
5
|
+
include TestUnitTestUtil
|
6
|
+
|
7
|
+
class TestJRuby < self
|
8
|
+
def test_error_inside_jruby
|
9
|
+
jruby_only_test
|
10
|
+
|
11
|
+
backtrace = backtrace_from_jruby
|
12
|
+
no_rb_entries = backtrace.find_all do |(file, _, _)|
|
13
|
+
File.extname(file) != ".rb"
|
14
|
+
end
|
15
|
+
|
16
|
+
fetcher = Test::Unit::CodeSnippetFetcher.new
|
17
|
+
snippets = no_rb_entries.collect do |(file, line, _)|
|
18
|
+
fetcher.fetch(file, line)
|
19
|
+
end
|
20
|
+
assert_equal([[]] * no_rb_entries.size,
|
21
|
+
snippets)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def backtrace_from_jruby
|
26
|
+
begin
|
27
|
+
java.util.Vector.new(-1)
|
28
|
+
rescue Exception
|
29
|
+
$@.collect do |entry|
|
30
|
+
entry.split(/:/, 3)
|
31
|
+
end
|
32
|
+
else
|
33
|
+
flunk("failed to raise an exception from JRuby.")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/test/testunit-test-util.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
module TestUnitTestUtil
|
2
2
|
private
|
3
|
+
def jruby_only_test
|
4
|
+
begin
|
5
|
+
require "java"
|
6
|
+
rescue LoadError
|
7
|
+
omit("test for JRuby")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
3
11
|
def assert_fault_messages(expected, faults)
|
4
12
|
assert_equal(expected, faults.collect {|fault| fault.message})
|
5
13
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 2.4.
|
9
|
+
- 8
|
10
|
+
version: 2.4.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kouhei Sutou
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-
|
19
|
+
date: 2012-03-06 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -63,7 +63,7 @@ dependencies:
|
|
63
63
|
description: |
|
64
64
|
Ruby 1.9.x bundles minitest not Test::Unit. Test::Unit
|
65
65
|
bundled in Ruby 1.8.x had not been improved but unbundled
|
66
|
-
Test::Unit (test-unit)
|
66
|
+
Test::Unit (test-unit) is improved actively.
|
67
67
|
|
68
68
|
email:
|
69
69
|
- kou@cozmixng.org
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- test/run-test.rb
|
141
141
|
- test/test-assertions.rb
|
142
142
|
- test/test-attribute.rb
|
143
|
+
- test/test-code-snippet.rb
|
143
144
|
- test/test-color-scheme.rb
|
144
145
|
- test/test-color.rb
|
145
146
|
- test/test-data.rb
|