test-unit 3.3.7 → 3.4.2
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 +44 -0
- data/lib/test-unit.rb +2 -0
- data/lib/test/unit.rb +2 -0
- data/lib/test/unit/assertions.rb +5 -12
- data/lib/test/unit/fixture.rb +6 -0
- data/lib/test/unit/ui/console/testrunner.rb +42 -48
- data/lib/test/unit/version.rb +1 -1
- data/lib/test/unit/warning.rb +3 -0
- data/test/test-assertions.rb +7 -10
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b0ea1c609f04e687f6b9c2bbc5d02efc79b1cf02516ddd36ff73a2cb974a2b0
|
4
|
+
data.tar.gz: 5110042334219485a6e99963685c6a51497509da5ec833516c0fa7a7a6eb0294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7201589c5975139093ac4618f696ba4f40448f9d4da7e2d437545d3f105563aed379d382ce57fe09ac5b27aa41af235019befaf2a8d96d5dcc6d6609cc13798e
|
7
|
+
data.tar.gz: e65b33f3f9560ad8581987617520b03ccdd63d59d5354546663fc0898209b3bbcebdc471c2afca5c2112897d34ad6d933f7ef416f2d6ccaad805f45b0a17a24b
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,49 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.4.2 - 2021-05-30 {#version-3-4-2}
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* [UI][console]: Improved diff readability for no color
|
8
|
+
case. Character based diff marks are always showed.
|
9
|
+
|
10
|
+
## 3.4.1 - 2021-04-19 {#version-3-4-1}
|
11
|
+
|
12
|
+
### Fixes
|
13
|
+
|
14
|
+
* Fixed a bug that `setup`/`cleanup`/`teardown` with block may be
|
15
|
+
overwritten by another `setup`/`cleanup`/`teardown` with
|
16
|
+
block. It's caused only with Ruby 2.6 or earlier.
|
17
|
+
[GitHub#179][Reported by akira yamada]
|
18
|
+
|
19
|
+
### Thanks
|
20
|
+
|
21
|
+
* akira yamada
|
22
|
+
|
23
|
+
## 3.4.0 - 2021-01-30 {#version-3-4-0}
|
24
|
+
|
25
|
+
### Improvements
|
26
|
+
|
27
|
+
* Enable deprecated warnings by default.
|
28
|
+
|
29
|
+
## 3.3.9 - 2020-12-29 {#version-3-3-9}
|
30
|
+
|
31
|
+
### Improvements
|
32
|
+
|
33
|
+
* `assert_not_match`: Add support for `String` as pattern.
|
34
|
+
[GitHub#178][Patch by David Rodríguez]
|
35
|
+
|
36
|
+
### Thanks
|
37
|
+
|
38
|
+
* David Rodríguez
|
39
|
+
|
40
|
+
## 3.3.8 - 2020-12-25 {#version-3-3-8}
|
41
|
+
|
42
|
+
### Improvements
|
43
|
+
|
44
|
+
* [UI][console]: Removed reverse mode because Ruby 3.0 reverts
|
45
|
+
reverse backtrace.
|
46
|
+
|
3
47
|
## 3.3.7 - 2020-11-18 {#version-3-3-7}
|
4
48
|
|
5
49
|
### Improvements
|
data/lib/test-unit.rb
CHANGED
data/lib/test/unit.rb
CHANGED
data/lib/test/unit/assertions.rb
CHANGED
@@ -534,12 +534,7 @@ EOT
|
|
534
534
|
# assert_match(/\d+/, 'five, 6, seven')
|
535
535
|
def assert_match(pattern, string, message=nil)
|
536
536
|
_wrap_assertion do
|
537
|
-
pattern =
|
538
|
-
when String
|
539
|
-
Regexp.new(Regexp.escape(pattern))
|
540
|
-
else
|
541
|
-
pattern
|
542
|
-
end
|
537
|
+
pattern = Regexp.new(Regexp.escape(pattern)) if pattern.is_a?(String)
|
543
538
|
full_message = build_message(message,
|
544
539
|
"<?> was expected to be =~\n<?>.",
|
545
540
|
pattern, string)
|
@@ -711,15 +706,13 @@ EOT
|
|
711
706
|
# @example
|
712
707
|
# assert_not_match(/two/, 'one 2 three') # -> pass
|
713
708
|
# assert_not_match(/three/, 'one 2 three') # -> fail
|
714
|
-
def assert_not_match(
|
709
|
+
def assert_not_match(pattern, string, message=nil)
|
715
710
|
_wrap_assertion do
|
716
|
-
|
717
|
-
"<REGEXP> in assert_not_match(<REGEXP>, ...) " +
|
718
|
-
"should be a Regexp.")
|
711
|
+
pattern = Regexp.new(Regexp.escape(pattern)) if pattern.is_a?(String)
|
719
712
|
full_message = build_message(message,
|
720
713
|
"<?> was expected to not match\n<?>.",
|
721
|
-
|
722
|
-
assert_block(full_message) {
|
714
|
+
pattern, string)
|
715
|
+
assert_block(full_message) { pattern !~ string }
|
723
716
|
end
|
724
717
|
end
|
725
718
|
|
data/lib/test/unit/fixture.rb
CHANGED
@@ -103,6 +103,7 @@ module Test
|
|
103
103
|
@test_case = test_case
|
104
104
|
@type = type
|
105
105
|
@default_options = default_options
|
106
|
+
@callbacks = {}
|
106
107
|
@before_prepend_callbacks = []
|
107
108
|
@before_append_callbacks = []
|
108
109
|
@after_prepend_callbacks = []
|
@@ -130,6 +131,11 @@ module Test
|
|
130
131
|
@test_case.attribute(:source_location,
|
131
132
|
callback.source_location,
|
132
133
|
method_name)
|
134
|
+
# For Ruby 2.6 or earlier. callback may be GC-ed. If
|
135
|
+
# callback is GC-ed, callback_method_name may be
|
136
|
+
# duplicated because callback_method_name uses callback.object_id.
|
137
|
+
# See also: https://github.com/test-unit/test-unit/issues/179
|
138
|
+
@callbacks[callback] = true
|
133
139
|
@test_case.__send__(:define_method, method_name, &callback)
|
134
140
|
else
|
135
141
|
method_name = method_name_or_callback
|
@@ -47,8 +47,6 @@ module Test
|
|
47
47
|
@progress_row_max ||= guess_progress_row_max
|
48
48
|
@show_detail_immediately = @options[:show_detail_immediately]
|
49
49
|
@show_detail_immediately = true if @show_detail_immediately.nil?
|
50
|
-
@reverse_output = @options[:reverse_output]
|
51
|
-
@reverse_output = @output.tty? if @reverse_output.nil?
|
52
50
|
@already_outputted = false
|
53
51
|
@indent = 0
|
54
52
|
@top_level = true
|
@@ -184,29 +182,15 @@ module Test
|
|
184
182
|
if fault.is_a?(Failure) and
|
185
183
|
fault.inspected_expected and
|
186
184
|
fault.inspected_actual
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
output(fault.test_name, fault_color(fault))
|
192
|
-
else
|
193
|
-
output_single("#{fault.label}: ")
|
194
|
-
output(fault.test_name, fault_color(fault))
|
195
|
-
output_fault_backtrace(fault)
|
196
|
-
output_failure_message(fault)
|
197
|
-
end
|
185
|
+
output_single("#{fault.label}: ")
|
186
|
+
output(fault.test_name, fault_color(fault))
|
187
|
+
output_fault_backtrace(fault)
|
188
|
+
output_failure_message(fault)
|
198
189
|
else
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
output_fault_message(fault)
|
204
|
-
else
|
205
|
-
output_single("#{fault.label}: ")
|
206
|
-
output_single(fault.test_name, fault_color(fault))
|
207
|
-
output_fault_message(fault)
|
208
|
-
output_fault_backtrace(fault)
|
209
|
-
end
|
190
|
+
output_single("#{fault.label}: ")
|
191
|
+
output_single(fault.test_name, fault_color(fault))
|
192
|
+
output_fault_message(fault)
|
193
|
+
output_fault_backtrace(fault)
|
210
194
|
end
|
211
195
|
end
|
212
196
|
|
@@ -244,19 +228,10 @@ module Test
|
|
244
228
|
end
|
245
229
|
end
|
246
230
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
end
|
252
|
-
output(entry)
|
253
|
-
end
|
254
|
-
else
|
255
|
-
backtrace.each_with_index do |entry, i|
|
256
|
-
output(entry)
|
257
|
-
if i == code_snippet_backtrace_index
|
258
|
-
output_code_snippet(code_snippet_lines, fault_color(fault))
|
259
|
-
end
|
231
|
+
backtrace.each_with_index do |entry, i|
|
232
|
+
output(entry)
|
233
|
+
if i == code_snippet_backtrace_index
|
234
|
+
output_code_snippet(code_snippet_lines, fault_color(fault))
|
260
235
|
end
|
261
236
|
end
|
262
237
|
end
|
@@ -336,17 +311,10 @@ module Test
|
|
336
311
|
end
|
337
312
|
|
338
313
|
def output_fault_in_short(fault)
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
output(" [#{fault.test_name}]")
|
344
|
-
else
|
345
|
-
output_single("#{fault.label}: ")
|
346
|
-
output_single(fault.message, fault_color(fault))
|
347
|
-
output(" [#{fault.test_name}]")
|
348
|
-
output(fault.location.first)
|
349
|
-
end
|
314
|
+
output_single("#{fault.label}: ")
|
315
|
+
output_single(fault.message, fault_color(fault))
|
316
|
+
output(" [#{fault.test_name}]")
|
317
|
+
output(fault.location.first)
|
350
318
|
end
|
351
319
|
|
352
320
|
def format_fault(fault)
|
@@ -692,6 +660,7 @@ module Test
|
|
692
660
|
|
693
661
|
def diff_line(from_line, to_line)
|
694
662
|
to_operations = []
|
663
|
+
mark_operations = []
|
695
664
|
from_line, to_line, _operations = line_operations(from_line, to_line)
|
696
665
|
|
697
666
|
no_replace = true
|
@@ -721,11 +690,22 @@ module Test
|
|
721
690
|
output_single(" " * (from_width - to_width))
|
722
691
|
end
|
723
692
|
end
|
693
|
+
mark_operations << Proc.new do
|
694
|
+
output_single("?" * from_width,
|
695
|
+
color("diff-difference-tag"))
|
696
|
+
if (to_width < from_width)
|
697
|
+
output_single(" " * (from_width - to_width))
|
698
|
+
end
|
699
|
+
end
|
724
700
|
when :delete
|
725
701
|
output_single(from_line[from_start...from_end],
|
726
702
|
color("diff-deleted"))
|
727
703
|
unless no_replace
|
728
704
|
to_operations << Proc.new {output_single(" " * from_width)}
|
705
|
+
mark_operations << Proc.new do
|
706
|
+
output_single("-" * from_width,
|
707
|
+
color("diff-deleted"))
|
708
|
+
end
|
729
709
|
end
|
730
710
|
when :insert
|
731
711
|
if no_replace
|
@@ -737,11 +717,16 @@ module Test
|
|
737
717
|
output_single(to_line[to_start...to_end],
|
738
718
|
color("diff-inserted"))
|
739
719
|
end
|
720
|
+
mark_operations << Proc.new do
|
721
|
+
output_single("+" * to_width,
|
722
|
+
color("diff-inserted"))
|
723
|
+
end
|
740
724
|
end
|
741
725
|
when :equal
|
742
726
|
output_single(from_line[from_start...from_end])
|
743
727
|
unless no_replace
|
744
728
|
to_operations << Proc.new {output_single(" " * to_width)}
|
729
|
+
mark_operations << Proc.new {output_single(" " * to_width)}
|
745
730
|
end
|
746
731
|
else
|
747
732
|
raise "unknown tag: #{tag}"
|
@@ -757,6 +742,15 @@ module Test
|
|
757
742
|
end
|
758
743
|
output("")
|
759
744
|
end
|
745
|
+
|
746
|
+
unless mark_operations.empty?
|
747
|
+
output_single("?", color("diff-difference-tag"))
|
748
|
+
output_single(" ")
|
749
|
+
mark_operations.each do |operation|
|
750
|
+
operation.call
|
751
|
+
end
|
752
|
+
output("")
|
753
|
+
end
|
760
754
|
end
|
761
755
|
end
|
762
756
|
end
|
data/lib/test/unit/version.rb
CHANGED
data/test/test-assertions.rb
CHANGED
@@ -956,16 +956,6 @@ EOM
|
|
956
956
|
end
|
957
957
|
end
|
958
958
|
|
959
|
-
def test_assert_not_match_fail_not_regexp
|
960
|
-
check_fail("<REGEXP> in assert_not_match(<REGEXP>, ...) " +
|
961
|
-
"should be a Regexp.\n" +
|
962
|
-
"<\"asdf\"> was expected to be instance_of?\n" +
|
963
|
-
"<Regexp> but was\n" +
|
964
|
-
"<String>.") do
|
965
|
-
assert_not_match("asdf", "asdf")
|
966
|
-
end
|
967
|
-
end
|
968
|
-
|
969
959
|
def test_assert_not_match_fail_match
|
970
960
|
check_fail("</string/> was expected to not match\n" +
|
971
961
|
"<\"string\">.") do
|
@@ -973,6 +963,13 @@ EOM
|
|
973
963
|
end
|
974
964
|
end
|
975
965
|
|
966
|
+
def test_assert_not_match_fail_match_string
|
967
|
+
check_fail("</asdf/> was expected to not match\n" +
|
968
|
+
"<\"asdf\">.") do
|
969
|
+
assert_not_match("asdf", "asdf")
|
970
|
+
end
|
971
|
+
end
|
972
|
+
|
976
973
|
def test_assert_not_match_fail_match_with_message
|
977
974
|
check_fail("message.\n" +
|
978
975
|
"</string/> was expected to not match\n" +
|
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.
|
4
|
+
version: 3.4.2
|
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: 2021-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: power_assert
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- lib/test/unit/util/output.rb
|
165
165
|
- lib/test/unit/util/procwrapper.rb
|
166
166
|
- lib/test/unit/version.rb
|
167
|
+
- lib/test/unit/warning.rb
|
167
168
|
- sample/adder.rb
|
168
169
|
- sample/subtracter.rb
|
169
170
|
- sample/test_adder.rb
|
@@ -231,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
232
|
- !ruby/object:Gem::Version
|
232
233
|
version: '0'
|
233
234
|
requirements: []
|
234
|
-
rubygems_version: 3.
|
235
|
+
rubygems_version: 3.3.0.dev
|
235
236
|
signing_key:
|
236
237
|
specification_version: 4
|
237
238
|
summary: An xUnit family unit testing framework for Ruby.
|