test-unit 3.0.9 → 3.1.0
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.
- checksums.yaml +4 -4
- data/doc/text/news.md +33 -0
- data/lib/test/unit/assertions.rb +1 -1
- data/lib/test/unit/error.rb +6 -2
- data/lib/test/unit/priority.rb +14 -4
- data/lib/test/unit/test-suite-creator.rb +2 -1
- data/lib/test/unit/testcase.rb +3 -3
- data/lib/test/unit/testsuite.rb +7 -4
- data/lib/test/unit/ui/console/testrunner.rb +1 -1
- data/lib/test/unit/version.rb +1 -1
- data/test/test-assertions.rb +24 -16
- data/test/test-priority.rb +57 -18
- data/test/test-test-case.rb +56 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0f3d6b7558b8c2dd32e218231b2b826791440da
|
4
|
+
data.tar.gz: 07aabaaba099bf99ad12491d9b747fa121f9ecf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f810e4cb4ac200999a8afe12c91557855fefb446ac3f2fb6cffe17e973efb02f4840a4ae6cbf01996a21cc0f64e93c3288c895398f9fdb37e76cdadf25ead0a
|
7
|
+
data.tar.gz: 36725fd11eb881311aa7f8bd67e6a00ff3de6784448ecaa2cdaa5b7041df4045fbf52262fc1aa879e70cef58f9f94cff56fa1d9eb66067108ba3657fb884a1a9
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,38 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.1.0 - 2015-05-28 {#version-3-1-0}
|
4
|
+
|
5
|
+
It's a bug fix release.
|
6
|
+
|
7
|
+
### Improvements
|
8
|
+
|
9
|
+
* [ui][console] Removed needless new line.
|
10
|
+
|
11
|
+
### Fixes
|
12
|
+
|
13
|
+
* Fixed a bug that priority mode can't be used on Windows.
|
14
|
+
[GitHub#95][Reported by Daniel Berger]
|
15
|
+
* Fixed a homepage URL RubyGems spec.
|
16
|
+
[GitHub#96][Patch by Masayoshi Takahashi]
|
17
|
+
supported.) [GitHub#89][Patch by Aaron Stone]
|
18
|
+
* Fixed a bug that shutdown hook isn't called when pass throw
|
19
|
+
exception such as `Interrupt` is raised.
|
20
|
+
[GitHub#98][Reported by jeremiahishere.]
|
21
|
+
* Fixed typos in documents.
|
22
|
+
[GitHub#100][Reported by scivola]
|
23
|
+
[GitHub#102][GitHub#103][Patch by Masafumi Yokoyama]
|
24
|
+
* Fixed a bug that the same name test isn't executed in sub test case.
|
25
|
+
[GitHub#104][Reported by wanabe]
|
26
|
+
|
27
|
+
### Thanks
|
28
|
+
|
29
|
+
* Daniel Berger
|
30
|
+
* Masayoshi Takahashi
|
31
|
+
* jeremiahishere
|
32
|
+
* scivola
|
33
|
+
* Masafumi Yokoyama
|
34
|
+
* wanabe
|
35
|
+
|
3
36
|
## 3.0.9 - 2014-12-31 {#version-3-0-9}
|
4
37
|
|
5
38
|
It's a release that improves colors.
|
data/lib/test/unit/assertions.rb
CHANGED
data/lib/test/unit/error.rb
CHANGED
@@ -78,8 +78,12 @@ module Test
|
|
78
78
|
|
79
79
|
NOT_PASS_THROUGH_EXCEPTIONS = []
|
80
80
|
NOT_PASS_THROUGH_EXCEPTION_NAMES = ["Timeout::Error"]
|
81
|
-
PASS_THROUGH_EXCEPTIONS = [
|
82
|
-
|
81
|
+
PASS_THROUGH_EXCEPTIONS = [
|
82
|
+
NoMemoryError,
|
83
|
+
SignalException,
|
84
|
+
Interrupt,
|
85
|
+
SystemExit,
|
86
|
+
]
|
83
87
|
PASS_THROUGH_EXCEPTION_NAMES = []
|
84
88
|
private
|
85
89
|
def handle_all_exception(exception)
|
data/lib/test/unit/priority.rb
CHANGED
@@ -122,9 +122,11 @@ module Test
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def result_dir
|
125
|
-
components = [
|
126
|
-
|
127
|
-
|
125
|
+
components = [
|
126
|
+
".test-result",
|
127
|
+
escape_class_name(@test.class.name || "AnonymousTestCase"),
|
128
|
+
escaped_method_name,
|
129
|
+
]
|
128
130
|
parent_directories = [File.dirname($0), Dir.pwd]
|
129
131
|
if Process.respond_to?(:uid)
|
130
132
|
parent_directories << File.join(Dir.tmpdir, Process.uid.to_s)
|
@@ -145,9 +147,17 @@ module Test
|
|
145
147
|
File.join(result_dir, "passed")
|
146
148
|
end
|
147
149
|
|
150
|
+
def escape_class_name(class_name)
|
151
|
+
class_name.gsub(/(?:[: \\\/])/, "_")
|
152
|
+
end
|
153
|
+
|
148
154
|
def escaped_method_name
|
149
|
-
@test.method_name.to_s.gsub(/[!?=]
|
155
|
+
@test.method_name.to_s.gsub(/(?:[: ]|[!?=]$)/) do |matched|
|
150
156
|
case matched
|
157
|
+
when ":"
|
158
|
+
"_colon_"
|
159
|
+
when " "
|
160
|
+
"_"
|
151
161
|
when "!"
|
152
162
|
".destructive"
|
153
163
|
when "?"
|
@@ -44,9 +44,10 @@ module Test
|
|
44
44
|
methods = @test_case.public_instance_methods(true)
|
45
45
|
super_test_case = @test_case.superclass
|
46
46
|
methods -= super_test_case.public_instance_methods(true)
|
47
|
+
methods |= @test_case.public_instance_methods(false)
|
47
48
|
method_names = methods.collect(&:to_s)
|
48
49
|
test_names = method_names.find_all do |method_name|
|
49
|
-
|
50
|
+
/\Atest./ =~ method_name or
|
50
51
|
@test_case.find_attribute(method_name, :test)
|
51
52
|
end
|
52
53
|
__send__("sort_test_names_in_#{@test_case.test_order}_order", test_names)
|
data/lib/test/unit/testcase.rb
CHANGED
@@ -320,7 +320,7 @@ module Test
|
|
320
320
|
# end
|
321
321
|
# end
|
322
322
|
#
|
323
|
-
# The
|
323
|
+
# The difference of them are the following:
|
324
324
|
#
|
325
325
|
# * Test case created by {sub_test_case} is an anonymous class.
|
326
326
|
# So you can't refer the test case by name.
|
@@ -331,7 +331,7 @@ module Test
|
|
331
331
|
#
|
332
332
|
# @param name [String] The name of newly created sub test case.
|
333
333
|
# @yield
|
334
|
-
# The block is
|
334
|
+
# The block is evaluated under the newly created sub test
|
335
335
|
# case class context.
|
336
336
|
# @return [Test::Unit::TestCase] Created sub test case class.
|
337
337
|
def sub_test_case(name, &block)
|
@@ -346,7 +346,7 @@ module Test
|
|
346
346
|
sub_test_case
|
347
347
|
end
|
348
348
|
|
349
|
-
#
|
349
|
+
# Checks whether a test that is matched the query is
|
350
350
|
# defined.
|
351
351
|
#
|
352
352
|
# @option query [String] :path (nil)
|
data/lib/test/unit/testsuite.rb
CHANGED
@@ -53,11 +53,14 @@ module Test
|
|
53
53
|
run_test(test, result, &progress_block)
|
54
54
|
@passed = false unless test.passed?
|
55
55
|
end
|
56
|
-
run_shutdown(result)
|
57
56
|
ensure
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
begin
|
58
|
+
run_shutdown(result)
|
59
|
+
ensure
|
60
|
+
@elapsed_time = Time.now - @start_time
|
61
|
+
yield(FINISHED, name)
|
62
|
+
yield(FINISHED_OBJECT, self)
|
63
|
+
end
|
61
64
|
end
|
62
65
|
|
63
66
|
# Adds the test to the suite.
|
@@ -186,7 +186,7 @@ module Test
|
|
186
186
|
else
|
187
187
|
if fault.is_a?(Error)
|
188
188
|
output_single("#{fault.label}: ")
|
189
|
-
|
189
|
+
output_single(fault.test_name, fault_color(fault))
|
190
190
|
output_fault_message(fault)
|
191
191
|
else
|
192
192
|
output_single(fault.label, fault_color(fault))
|
data/lib/test/unit/version.rb
CHANGED
data/test/test-assertions.rb
CHANGED
@@ -124,22 +124,30 @@ module Test
|
|
124
124
|
class TestAssertions < TestCase
|
125
125
|
include AssertionCheckable
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
127
|
+
class TestAssertBlock < self
|
128
|
+
def test_pass_without_message
|
129
|
+
check_nothing_fails {
|
130
|
+
assert_block {true}
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_pass_with_message
|
135
|
+
check_nothing_fails {
|
136
|
+
assert_block("successful assert_block") {true}
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_failure_without_message
|
141
|
+
check_fail("assert_block failed.") {
|
142
|
+
assert_block {false}
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_failure_with_message
|
147
|
+
check_fail("failed assert_block") {
|
148
|
+
assert_block("failed assert_block") {false}
|
149
|
+
}
|
150
|
+
end
|
143
151
|
end
|
144
152
|
|
145
153
|
class TestAssertEqual < self
|
data/test/test-priority.rb
CHANGED
@@ -102,33 +102,72 @@ class TestUnitPriority < Test::Unit::TestCase
|
|
102
102
|
assert_in_delta(expected, n_need_to_run.to_f / n, delta)
|
103
103
|
end
|
104
104
|
|
105
|
-
class
|
106
|
-
|
107
|
-
|
108
|
-
Test::Unit::TestSuite.new(name)
|
109
|
-
end
|
105
|
+
class TestClassName < self
|
106
|
+
def test_colon
|
107
|
+
assert_escaped_name("Test__Priority", "Test::Priority")
|
110
108
|
end
|
111
109
|
|
112
|
-
def
|
110
|
+
def test_space
|
111
|
+
assert_escaped_name("test_priority", "test priority")
|
113
112
|
end
|
114
113
|
|
115
|
-
def
|
114
|
+
def test_slash
|
115
|
+
assert_escaped_name("test_priority", "test/priority")
|
116
116
|
end
|
117
117
|
|
118
|
-
def
|
118
|
+
def test_back_slash
|
119
|
+
assert_escaped_name("test_priority", "test\/priority")
|
119
120
|
end
|
120
|
-
end
|
121
121
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
122
|
+
def assert_escaped_name(expected, class_name)
|
123
|
+
checker = Checker.new(nil)
|
124
|
+
escaped_class_name = checker.send(:escape_class_name, class_name)
|
125
|
+
assert_equal(expected, escaped_class_name)
|
126
|
+
end
|
126
127
|
end
|
127
128
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
129
|
+
class TestFileName < self
|
130
|
+
class SpecialNameTestCase < Test::Unit::TestCase
|
131
|
+
class << self
|
132
|
+
def suite
|
133
|
+
Test::Unit::TestSuite.new(name)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_question?
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_exclamation!
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_equal=
|
144
|
+
end
|
145
|
+
|
146
|
+
test "have space" do
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_question
|
151
|
+
assert_escaped_name("test_question.predicate", "test_question?")
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_exclamation
|
155
|
+
assert_escaped_name("test_exclamation.destructive", "test_exclamation!")
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_equal
|
159
|
+
assert_escaped_name("test_equal.equal", "test_equal=")
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_colon_and_space
|
163
|
+
assert_escaped_name("test_colon__have_space", "test: have space")
|
164
|
+
end
|
165
|
+
|
166
|
+
def assert_escaped_name(expected, test_method_name)
|
167
|
+
checker = Checker.new(SpecialNameTestCase.new(test_method_name))
|
168
|
+
passed_file = checker.send(:passed_file)
|
169
|
+
method_name_component = File.basename(File.dirname(passed_file))
|
170
|
+
assert_equal(expected, method_name_component)
|
171
|
+
end
|
133
172
|
end
|
134
173
|
end
|
data/test/test-test-case.rb
CHANGED
@@ -842,6 +842,33 @@ module Test
|
|
842
842
|
end
|
843
843
|
assert_equal(["test_nothing"], test_method_names)
|
844
844
|
end
|
845
|
+
|
846
|
+
def test_duplicated_name
|
847
|
+
test_case = Class.new(TestCase) do
|
848
|
+
def test_nothing
|
849
|
+
end
|
850
|
+
end
|
851
|
+
sub_test_case = test_case.sub_test_case("sub test case") do
|
852
|
+
def test_nothing
|
853
|
+
end
|
854
|
+
end
|
855
|
+
|
856
|
+
test_method_names = test_case.suite.tests.collect do |test|
|
857
|
+
test.method_name
|
858
|
+
end
|
859
|
+
sub_test_method_names = sub_test_case.suite.tests.collect do |test|
|
860
|
+
test.method_name
|
861
|
+
end
|
862
|
+
|
863
|
+
assert_equal([
|
864
|
+
["test_nothing"],
|
865
|
+
["test_nothing"],
|
866
|
+
],
|
867
|
+
[
|
868
|
+
test_method_names,
|
869
|
+
sub_test_method_names,
|
870
|
+
])
|
871
|
+
end
|
845
872
|
end
|
846
873
|
|
847
874
|
class TestStartupShutdown < self
|
@@ -1064,6 +1091,35 @@ module Test
|
|
1064
1091
|
run_test_case(test_case)
|
1065
1092
|
end
|
1066
1093
|
end
|
1094
|
+
|
1095
|
+
def test_pass_through_in_test
|
1096
|
+
test_case = Class.new(TestCase) do
|
1097
|
+
@called = []
|
1098
|
+
class << self
|
1099
|
+
def called
|
1100
|
+
@called
|
1101
|
+
end
|
1102
|
+
|
1103
|
+
def startup
|
1104
|
+
@called << :startup
|
1105
|
+
end
|
1106
|
+
|
1107
|
+
def shutdown
|
1108
|
+
@called << :shutdown
|
1109
|
+
end
|
1110
|
+
end
|
1111
|
+
|
1112
|
+
def test_error
|
1113
|
+
raise Interrupt, "from test"
|
1114
|
+
end
|
1115
|
+
end
|
1116
|
+
|
1117
|
+
assert_raise(Interrupt) do
|
1118
|
+
run_test_case(test_case)
|
1119
|
+
end
|
1120
|
+
assert_equal([:startup, :shutdown],
|
1121
|
+
test_case.called)
|
1122
|
+
end
|
1067
1123
|
end
|
1068
1124
|
end
|
1069
1125
|
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: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: power_assert
|
@@ -208,7 +208,7 @@ files:
|
|
208
208
|
- test/util/test_backtracefilter.rb
|
209
209
|
- test/util/test_observable.rb
|
210
210
|
- test/util/test_procwrapper.rb
|
211
|
-
homepage: http://
|
211
|
+
homepage: http://test-unit.github.io/
|
212
212
|
licenses:
|
213
213
|
- Ruby
|
214
214
|
- PSFL
|