test-unit 3.2.9 → 3.5.5
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/BSDL +24 -0
- data/COPYING +41 -44
- data/README.md +18 -11
- data/Rakefile +0 -23
- data/doc/text/getting-started.md +2 -2
- data/doc/text/news.md +329 -1
- data/lib/test/unit/assertion-failed-error.rb +35 -0
- data/lib/test/unit/assertions.rb +453 -161
- data/lib/test/unit/attribute.rb +3 -1
- data/lib/test/unit/autorunner.rb +78 -30
- data/lib/test/unit/code-snippet-fetcher.rb +7 -7
- data/lib/test/unit/collector/descendant.rb +1 -0
- data/lib/test/unit/collector/dir.rb +4 -2
- data/lib/test/unit/collector/load.rb +3 -3
- data/lib/test/unit/collector/objectspace.rb +1 -0
- data/lib/test/unit/collector.rb +31 -0
- data/lib/test/unit/color-scheme.rb +20 -2
- data/lib/test/unit/data-sets.rb +26 -15
- data/lib/test/unit/data.rb +5 -5
- data/lib/test/unit/diff.rb +2 -3
- data/lib/test/unit/fixture.rb +6 -0
- data/lib/test/unit/notification.rb +9 -7
- data/lib/test/unit/omission.rb +34 -31
- data/lib/test/unit/pending.rb +12 -11
- data/lib/test/unit/priority.rb +7 -5
- data/lib/test/unit/runner/console.rb +0 -17
- data/lib/test/unit/testcase.rb +222 -146
- data/lib/test/unit/testsuite.rb +1 -1
- data/lib/test/unit/ui/console/testrunner.rb +58 -49
- data/lib/test/unit/util/memory-usage.rb +47 -0
- data/lib/test/unit/util/observable.rb +2 -2
- data/lib/test/unit/util/output.rb +5 -4
- data/lib/test/unit/version.rb +1 -1
- data/lib/test/unit/warning.rb +3 -0
- data/lib/test/unit.rb +177 -161
- data/lib/test-unit.rb +2 -17
- metadata +14 -91
- data/GPL +0 -339
- data/LGPL +0 -502
- data/test/collector/test-descendant.rb +0 -182
- data/test/collector/test-load.rb +0 -442
- data/test/collector/test_dir.rb +0 -407
- data/test/collector/test_objectspace.rb +0 -102
- data/test/fixtures/header-label.csv +0 -3
- data/test/fixtures/header-label.tsv +0 -3
- data/test/fixtures/header.csv +0 -3
- data/test/fixtures/header.tsv +0 -3
- data/test/fixtures/no-header.csv +0 -2
- data/test/fixtures/no-header.tsv +0 -2
- data/test/fixtures/plus.csv +0 -3
- data/test/run-test.rb +0 -22
- data/test/test-assertions.rb +0 -2180
- data/test/test-attribute-matcher.rb +0 -38
- data/test/test-attribute.rb +0 -123
- data/test/test-code-snippet.rb +0 -37
- data/test/test-color-scheme.rb +0 -82
- data/test/test-color.rb +0 -47
- data/test/test-data.rb +0 -419
- data/test/test-diff.rb +0 -518
- data/test/test-emacs-runner.rb +0 -60
- data/test/test-error.rb +0 -26
- data/test/test-failure.rb +0 -33
- data/test/test-fault-location-detector.rb +0 -163
- data/test/test-fixture.rb +0 -713
- data/test/test-notification.rb +0 -33
- data/test/test-omission.rb +0 -81
- data/test/test-pending.rb +0 -70
- data/test/test-priority.rb +0 -173
- data/test/test-test-case.rb +0 -1279
- data/test/test-test-result.rb +0 -113
- data/test/test-test-suite-creator.rb +0 -97
- data/test/test-test-suite.rb +0 -151
- data/test/testunit-test-util.rb +0 -31
- data/test/ui/test_testrunmediator.rb +0 -20
- data/test/util/test-method-owner-finder.rb +0 -38
- data/test/util/test-output.rb +0 -11
- data/test/util/test_backtracefilter.rb +0 -52
- data/test/util/test_observable.rb +0 -102
- data/test/util/test_procwrapper.rb +0 -36
@@ -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)
|
@@ -540,13 +508,28 @@ module Test
|
|
540
508
|
color("#{@result.status}-marker")
|
541
509
|
end
|
542
510
|
|
511
|
+
TERM_COLOR_SUPPORT = /
|
512
|
+
color| # explicitly claims color support in the name
|
513
|
+
direct| # explicitly claims "direct color" (24 bit) support
|
514
|
+
#{ColorScheme::TERM_256}|
|
515
|
+
\Acygwin|
|
516
|
+
\Alinux|
|
517
|
+
\Ansterm-bce|
|
518
|
+
\Ansterm-c-|
|
519
|
+
\Aputty|
|
520
|
+
\Arxvt|
|
521
|
+
\Ascreen|
|
522
|
+
\Atmux|
|
523
|
+
\Axterm
|
524
|
+
/x
|
525
|
+
|
543
526
|
def guess_color_availability
|
544
527
|
return false unless @output.tty?
|
545
528
|
return true if windows? and ruby_2_0_or_later?
|
546
529
|
case ENV["TERM"]
|
547
530
|
when /(?:term|screen)(?:-(?:256)?color)?\z/
|
548
531
|
true
|
549
|
-
when
|
532
|
+
when TERM_COLOR_SUPPORT
|
550
533
|
true
|
551
534
|
else
|
552
535
|
return true if ENV["EMACS"] == "t"
|
@@ -677,6 +660,7 @@ module Test
|
|
677
660
|
|
678
661
|
def diff_line(from_line, to_line)
|
679
662
|
to_operations = []
|
663
|
+
mark_operations = []
|
680
664
|
from_line, to_line, _operations = line_operations(from_line, to_line)
|
681
665
|
|
682
666
|
no_replace = true
|
@@ -706,11 +690,22 @@ module Test
|
|
706
690
|
output_single(" " * (from_width - to_width))
|
707
691
|
end
|
708
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
|
709
700
|
when :delete
|
710
701
|
output_single(from_line[from_start...from_end],
|
711
702
|
color("diff-deleted"))
|
712
703
|
unless no_replace
|
713
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
|
714
709
|
end
|
715
710
|
when :insert
|
716
711
|
if no_replace
|
@@ -722,11 +717,16 @@ module Test
|
|
722
717
|
output_single(to_line[to_start...to_end],
|
723
718
|
color("diff-inserted"))
|
724
719
|
end
|
720
|
+
mark_operations << Proc.new do
|
721
|
+
output_single("+" * to_width,
|
722
|
+
color("diff-inserted"))
|
723
|
+
end
|
725
724
|
end
|
726
725
|
when :equal
|
727
726
|
output_single(from_line[from_start...from_end])
|
728
727
|
unless no_replace
|
729
728
|
to_operations << Proc.new {output_single(" " * to_width)}
|
729
|
+
mark_operations << Proc.new {output_single(" " * to_width)}
|
730
730
|
end
|
731
731
|
else
|
732
732
|
raise "unknown tag: #{tag}"
|
@@ -742,6 +742,15 @@ module Test
|
|
742
742
|
end
|
743
743
|
output("")
|
744
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
|
745
754
|
end
|
746
755
|
end
|
747
756
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Test
|
2
|
+
module Unit
|
3
|
+
module Util
|
4
|
+
class MemoryUsage
|
5
|
+
attr_reader :virtual
|
6
|
+
attr_reader :physical
|
7
|
+
def initialize
|
8
|
+
@virtual = nil
|
9
|
+
@physical = nil
|
10
|
+
collect_data
|
11
|
+
end
|
12
|
+
|
13
|
+
def collected?
|
14
|
+
return false if @virtual.nil?
|
15
|
+
return false if @physical.nil?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def collect_data
|
21
|
+
collect_data_proc
|
22
|
+
end
|
23
|
+
|
24
|
+
def collect_data_proc
|
25
|
+
status_file = "/proc/self/status"
|
26
|
+
return false unless File.exist?(status_file)
|
27
|
+
|
28
|
+
data = File.binread(status_file)
|
29
|
+
data.each_line do |line|
|
30
|
+
case line
|
31
|
+
when /\AVm(Size|RSS):\s*(\d+)\s*kB/
|
32
|
+
name = $1
|
33
|
+
value = Integer($2, 10) * 1024
|
34
|
+
case name
|
35
|
+
when "Size"
|
36
|
+
@virtual = value
|
37
|
+
when "RSS"
|
38
|
+
@physical = value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
collected?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -26,8 +26,8 @@ module Test
|
|
26
26
|
# returned, making it very easy to use the proc
|
27
27
|
# itself as the listener_key:
|
28
28
|
#
|
29
|
-
#
|
30
|
-
#
|
29
|
+
# listener = add_listener("Channel") { ... }
|
30
|
+
# remove_listener("Channel", listener)
|
31
31
|
def add_listener(channel_name, listener_key=NOTHING, &listener) # :yields: value
|
32
32
|
unless(block_given?)
|
33
33
|
raise ArgumentError.new("No callback was passed as a listener")
|
@@ -7,10 +7,11 @@ module Test
|
|
7
7
|
# error as string.
|
8
8
|
#
|
9
9
|
# Example:
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
10
|
+
#
|
11
|
+
# capture_output do
|
12
|
+
# puts("stdout")
|
13
|
+
# warn("stderr")
|
14
|
+
# end # -> ["stdout\n", "stderr\n"]
|
14
15
|
def capture_output
|
15
16
|
require 'stringio'
|
16
17
|
|
data/lib/test/unit/version.rb
CHANGED