test-unit 3.0.8 → 3.0.9
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 +21 -1
- data/lib/test/unit/code-snippet-fetcher.rb +1 -0
- data/lib/test/unit/color-scheme.rb +46 -7
- data/lib/test/unit/ui/console/testrunner.rb +83 -20
- data/lib/test/unit/version.rb +1 -1
- data/test/test-color-scheme.rb +23 -30
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1731a62620afe520b8f3817106f6e9c126f5ea73
|
4
|
+
data.tar.gz: e78724adf56e151021ccb346e17db6fdb1e781af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cc3e2a66dd5fa1366f1442a94b90c0ff7ee98da7732faed76ab536b67afc2e1f7753e5fc8a17bf8301f6927880168cf9248672e93c502d3cd3382eef395e2e6
|
7
|
+
data.tar.gz: 16d07b7d4b54a3826399d0eb9b97457a47cdf6ba945c4deaee1982b4f27809685f32beb8c5dbbb61e416efbc8cfb77922008d39ced1864e47110c749a617cf96
|
data/doc/text/news.md
CHANGED
@@ -1,8 +1,28 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.0.9 - 2014-12-31 {#version-3-0-9}
|
4
|
+
|
5
|
+
It's a release that improves colors.
|
6
|
+
|
7
|
+
### Improvements
|
8
|
+
|
9
|
+
* Added a work around for Ruby 1.8. (Note: Ruby 1.8 isn't
|
10
|
+
supported.) [GitHub#89][Patch by Aaron Stone]
|
11
|
+
* Supported colorized output on Windows.
|
12
|
+
[GitHub#90][Patch by usa]
|
13
|
+
* Improved colorized output.
|
14
|
+
http://www.a-k-r.org/d/2014-12.html#a2014_12_27_1
|
15
|
+
[Suggested by Tanaka Akira]
|
16
|
+
|
17
|
+
### Thanks
|
18
|
+
|
19
|
+
* Aaron Stone
|
20
|
+
* usa
|
21
|
+
* Tanaka Akira
|
22
|
+
|
3
23
|
## 3.0.8 - 2014-12-12 {#version-3-0-8}
|
4
24
|
|
5
|
-
It's a release that
|
25
|
+
It's a release that supports Ruby 2.2.0 preview2.
|
6
26
|
|
7
27
|
### Improvements
|
8
28
|
|
@@ -19,16 +19,22 @@ module Test
|
|
19
19
|
@@default_for_8_colors ||=
|
20
20
|
new("pass" => Color.new("green", :background => true) +
|
21
21
|
Color.new("white", :bold => true),
|
22
|
+
"pass-marker" => Color.new("green", :bold => true),
|
22
23
|
"failure" => Color.new("red", :background => true) +
|
23
24
|
Color.new("white", :bold => true),
|
25
|
+
"failure-marker" => Color.new("red"),
|
24
26
|
"pending" => Color.new("magenta", :background => true) +
|
25
27
|
Color.new("white", :bold => true),
|
28
|
+
"pending-marker" => Color.new("magenta"),
|
26
29
|
"omission" => Color.new("blue", :background => true) +
|
27
30
|
Color.new("white", :bold => true),
|
31
|
+
"omission-marker" => Color.new("blue"),
|
28
32
|
"notification" => Color.new("cyan", :background => true) +
|
29
33
|
Color.new("white", :bold => true),
|
34
|
+
"notification-marker" => Color.new("cyan"),
|
30
35
|
"error" => Color.new("black", :background => true) +
|
31
36
|
Color.new("yellow", :bold => true),
|
37
|
+
"error-marker" => Color.new("yellow"),
|
32
38
|
"case" => Color.new("blue", :background => true) +
|
33
39
|
Color.new("white", :bold => true),
|
34
40
|
"suite" => Color.new("green", :background => true) +
|
@@ -50,16 +56,22 @@ module Test
|
|
50
56
|
@@default_for_256_colors ||=
|
51
57
|
new("pass" => Color.new("030", :background => true) +
|
52
58
|
Color.new("555", :bold => true),
|
59
|
+
"pass-marker" => Color.new("050", :bold => true),
|
53
60
|
"failure" => Color.new("300", :background => true) +
|
54
61
|
Color.new("555", :bold => true),
|
62
|
+
"failure-marker" => Color.new("500"),
|
55
63
|
"pending" => Color.new("303", :background => true) +
|
56
64
|
Color.new("555", :bold => true),
|
65
|
+
"pending-marker" => Color.new("303"),
|
57
66
|
"omission" => Color.new("001", :background => true) +
|
58
67
|
Color.new("555", :bold => true),
|
68
|
+
"omission-marker" => Color.new("001"),
|
59
69
|
"notification" => Color.new("011", :background => true) +
|
60
70
|
Color.new("555", :bold => true),
|
71
|
+
"notification-marker" => Color.new("011"),
|
61
72
|
"error" => Color.new("000", :background => true) +
|
62
73
|
Color.new("550", :bold => true),
|
74
|
+
"error-marker" => Color.new("550"),
|
63
75
|
"case" => Color.new("220", :background => true) +
|
64
76
|
Color.new("555", :bold => true),
|
65
77
|
"suite" => Color.new("110", :background => true) +
|
@@ -95,16 +107,43 @@ module Test
|
|
95
107
|
end
|
96
108
|
|
97
109
|
def available_colors
|
110
|
+
guess_available_colors_from_vte_version_env ||
|
111
|
+
guess_available_colors_from_colorterm_env ||
|
112
|
+
guess_available_colors_from_term_env ||
|
113
|
+
8
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
def guess_available_colors_from_vte_version_env
|
118
|
+
vte_version = ENV["VTE_VERSION"]
|
119
|
+
return nil if vte_version.nil?
|
120
|
+
|
121
|
+
major = 0
|
122
|
+
minor = 13
|
123
|
+
micro = 0
|
124
|
+
packed_version = major * 10000 + minor * 100 + micro
|
125
|
+
if vte_version.to_i >= packed_version
|
126
|
+
256
|
127
|
+
else
|
128
|
+
8
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def guess_available_colors_from_colorterm_env
|
98
133
|
case ENV["COLORTERM"]
|
99
|
-
when "gnome-terminal"
|
134
|
+
when "gnome-terminal", "xfce4-terminal"
|
100
135
|
256
|
101
136
|
else
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
137
|
+
nil
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def guess_available_colors_from_term_env
|
142
|
+
case ENV["TERM"]
|
143
|
+
when /-256color\z/
|
144
|
+
256
|
145
|
+
else
|
146
|
+
nil
|
108
147
|
end
|
109
148
|
end
|
110
149
|
end
|
@@ -6,6 +6,11 @@
|
|
6
6
|
# * Copyright (c) 2008-2013 Kouhei Sutou <kou@clear-code.com>
|
7
7
|
# License:: Ruby license.
|
8
8
|
|
9
|
+
begin
|
10
|
+
require 'io/console'
|
11
|
+
rescue LoadError
|
12
|
+
end
|
13
|
+
|
9
14
|
require 'test/unit/color-scheme'
|
10
15
|
require 'test/unit/code-snippet-fetcher'
|
11
16
|
require 'test/unit/fault-location-detector'
|
@@ -89,7 +94,8 @@ module Test
|
|
89
94
|
|
90
95
|
def add_fault(fault)
|
91
96
|
@faults << fault
|
92
|
-
output_progress(fault.single_character_display,
|
97
|
+
output_progress(fault.single_character_display,
|
98
|
+
fault_marker_color(fault))
|
93
99
|
output_progress_in_detail(fault) if @show_detail_immediately
|
94
100
|
@already_outputted = true if fault.critical?
|
95
101
|
end
|
@@ -173,17 +179,17 @@ module Test
|
|
173
179
|
def output_fault_in_detail(fault)
|
174
180
|
if fault.is_a?(Failure) and
|
175
181
|
fault.inspected_expected and fault.inspected_actual
|
176
|
-
output_single(fault.label
|
177
|
-
output(
|
178
|
-
output(fault.test_name)
|
182
|
+
output_single("#{fault.label}: ")
|
183
|
+
output(fault.test_name, fault_color(fault))
|
179
184
|
output_fault_backtrace(fault)
|
180
185
|
output_failure_message(fault)
|
181
186
|
else
|
182
|
-
output_single(fault.label, fault_color(fault))
|
183
187
|
if fault.is_a?(Error)
|
184
|
-
|
188
|
+
output_single("#{fault.label}: ")
|
189
|
+
output(fault.test_name, fault_color(fault))
|
185
190
|
output_fault_message(fault)
|
186
191
|
else
|
192
|
+
output_single(fault.label, fault_color(fault))
|
187
193
|
output_fault_message(fault)
|
188
194
|
output(fault.test_name)
|
189
195
|
end
|
@@ -308,11 +314,11 @@ module Test
|
|
308
314
|
|
309
315
|
def output_statistics(elapsed_time)
|
310
316
|
output("Finished in #{elapsed_time} seconds.")
|
311
|
-
|
312
|
-
output(@result
|
313
|
-
output("%g%% passed" % @result.pass_percentage
|
317
|
+
output_summary_marker
|
318
|
+
output(@result)
|
319
|
+
output("%g%% passed" % @result.pass_percentage)
|
314
320
|
unless elapsed_time.zero?
|
315
|
-
|
321
|
+
output_summary_marker
|
316
322
|
test_throughput = @result.run_count / elapsed_time
|
317
323
|
assertion_throughput = @result.assertion_count / elapsed_time
|
318
324
|
throughput = [
|
@@ -323,6 +329,16 @@ module Test
|
|
323
329
|
end
|
324
330
|
end
|
325
331
|
|
332
|
+
def output_summary_marker
|
333
|
+
term_width = guess_term_width
|
334
|
+
if term_width.zero?
|
335
|
+
marker_width = 6
|
336
|
+
else
|
337
|
+
marker_width = term_width
|
338
|
+
end
|
339
|
+
output("-" * marker_width, summary_marker_color)
|
340
|
+
end
|
341
|
+
|
326
342
|
def test_started(test)
|
327
343
|
return unless output?(VERBOSE)
|
328
344
|
|
@@ -337,7 +353,7 @@ module Test
|
|
337
353
|
|
338
354
|
def test_finished(test)
|
339
355
|
unless @already_outputted
|
340
|
-
output_progress(".", color("pass"))
|
356
|
+
output_progress(".", color("pass-marker"))
|
341
357
|
end
|
342
358
|
@already_outputted = false
|
343
359
|
|
@@ -423,7 +439,7 @@ module Test
|
|
423
439
|
|
424
440
|
def output_progress_in_detail_marker(fault)
|
425
441
|
if @progress_row_max > 0
|
426
|
-
output("=" * @progress_row_max
|
442
|
+
output("=" * @progress_row_max)
|
427
443
|
else
|
428
444
|
nl
|
429
445
|
end
|
@@ -453,20 +469,25 @@ module Test
|
|
453
469
|
_color
|
454
470
|
end
|
455
471
|
|
472
|
+
def fault_class_color_name(fault_class)
|
473
|
+
fault_class.name.split(/::/).last.downcase
|
474
|
+
end
|
475
|
+
|
456
476
|
def fault_color(fault)
|
457
|
-
|
477
|
+
color(fault_class_color_name(fault.class))
|
458
478
|
end
|
459
479
|
|
460
|
-
def
|
461
|
-
color(
|
480
|
+
def fault_marker_color(fault)
|
481
|
+
color("#{fault_class_color_name(fault.class)}-marker")
|
462
482
|
end
|
463
483
|
|
464
|
-
def
|
465
|
-
color(@result.status)
|
484
|
+
def summary_marker_color
|
485
|
+
color("#{@result.status}-marker")
|
466
486
|
end
|
467
487
|
|
468
488
|
def guess_color_availability
|
469
489
|
return false unless @output.tty?
|
490
|
+
return true if windows? and ruby_2_0_or_later?
|
470
491
|
case ENV["TERM"]
|
471
492
|
when /(?:term|screen)(?:-(?:256)?color)?\z/
|
472
493
|
true
|
@@ -476,6 +497,14 @@ module Test
|
|
476
497
|
end
|
477
498
|
end
|
478
499
|
|
500
|
+
def windows?
|
501
|
+
/mswin|mingw/ === RUBY_PLATFORM
|
502
|
+
end
|
503
|
+
|
504
|
+
def ruby_2_0_or_later?
|
505
|
+
RUBY_VERSION >= "2.0.0"
|
506
|
+
end
|
507
|
+
|
479
508
|
def guess_progress_row_max
|
480
509
|
term_width = guess_term_width
|
481
510
|
if term_width.zero?
|
@@ -490,9 +519,30 @@ module Test
|
|
490
519
|
end
|
491
520
|
|
492
521
|
def guess_term_width
|
493
|
-
|
494
|
-
|
495
|
-
|
522
|
+
guess_term_width_from_io || guess_term_width_from_env || 0
|
523
|
+
end
|
524
|
+
|
525
|
+
def guess_term_width_from_io
|
526
|
+
if @output.respond_to?(:winsize)
|
527
|
+
begin
|
528
|
+
@output.winsize[1]
|
529
|
+
rescue SystemCallError
|
530
|
+
nil
|
531
|
+
end
|
532
|
+
else
|
533
|
+
nil
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
537
|
+
def guess_term_width_from_env
|
538
|
+
env = ENV["COLUMNS"] || ENV["TERM_WIDTH"]
|
539
|
+
return nil if env.nil?
|
540
|
+
|
541
|
+
begin
|
542
|
+
Integer(env)
|
543
|
+
rescue ArgumentError
|
544
|
+
nil
|
545
|
+
end
|
496
546
|
end
|
497
547
|
end
|
498
548
|
|
@@ -503,6 +553,7 @@ module Test
|
|
503
553
|
end
|
504
554
|
|
505
555
|
def need_diff?(options={})
|
556
|
+
return false if one_line_all_change?
|
506
557
|
operations.each do |tag,|
|
507
558
|
return true if [:replace, :equal].include?(tag)
|
508
559
|
end
|
@@ -510,6 +561,18 @@ module Test
|
|
510
561
|
end
|
511
562
|
|
512
563
|
private
|
564
|
+
def one_line_all_change?
|
565
|
+
return false if operations.size != 1
|
566
|
+
|
567
|
+
tag, from_start, from_end, to_start, to_end = operations.first
|
568
|
+
return false if tag != :replace
|
569
|
+
return false if [from_start, from_end] != [0, 1]
|
570
|
+
return false if [from_start, from_end] != [to_start, to_end]
|
571
|
+
|
572
|
+
_, _, _line_operations = line_operations(@from.first, @to.first)
|
573
|
+
_line_operations.size == 1
|
574
|
+
end
|
575
|
+
|
513
576
|
def output_single(something, color=nil)
|
514
577
|
@runner.__send__(:output_single, something, color)
|
515
578
|
end
|
data/lib/test/unit/version.rb
CHANGED
data/test/test-color-scheme.rb
CHANGED
@@ -54,36 +54,29 @@ class TestUnitColorScheme < Test::Unit::TestCase
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_default
|
57
|
-
|
58
|
-
"pass"
|
59
|
-
|
60
|
-
"failure"
|
61
|
-
|
62
|
-
"pending"
|
63
|
-
|
64
|
-
"omission"
|
65
|
-
|
66
|
-
"notification"
|
67
|
-
|
68
|
-
"error"
|
69
|
-
|
70
|
-
"case"
|
71
|
-
|
72
|
-
"
|
73
|
-
|
74
|
-
"diff-
|
75
|
-
|
76
|
-
"diff-deleted
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
"diff-inserted" => color("red", :background => true) +
|
81
|
-
color("white", :bold => true),
|
82
|
-
"diff-deleted" => color("green", :background => true) +
|
83
|
-
color("white", :bold => true),
|
84
|
-
}
|
85
|
-
assert_equal(expected_schema,
|
86
|
-
Test::Unit::ColorScheme.default.to_hash)
|
57
|
+
expected_schema_keys = [
|
58
|
+
"pass",
|
59
|
+
"pass-marker",
|
60
|
+
"failure",
|
61
|
+
"failure-marker",
|
62
|
+
"pending",
|
63
|
+
"pending-marker",
|
64
|
+
"omission",
|
65
|
+
"omission-marker",
|
66
|
+
"notification",
|
67
|
+
"notification-marker",
|
68
|
+
"error",
|
69
|
+
"error-marker",
|
70
|
+
"case",
|
71
|
+
"suite",
|
72
|
+
"diff-inserted-tag",
|
73
|
+
"diff-deleted-tag",
|
74
|
+
"diff-difference-tag",
|
75
|
+
"diff-inserted",
|
76
|
+
"diff-deleted",
|
77
|
+
]
|
78
|
+
assert_equal(expected_schema_keys.sort,
|
79
|
+
Test::Unit::ColorScheme.default.to_hash.keys.sort)
|
87
80
|
end
|
88
81
|
end
|
89
82
|
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.0.9
|
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: 2014-12-
|
12
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: power_assert
|