turn-again-reporter 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -3
- data/Rakefile +14 -17
- data/lib/minitest/reporters/turn_again_reporter.rb +98 -7
- data/lib/minitest/reporters/turn_again_reporter/version.rb +1 -1
- data/test/integration/color_options_test.rb +28 -0
- data/test/integration/hours_option_test.rb +13 -0
- data/test/integration/indent_option_test.rb +23 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5f99fd10fa85112b1e696162e5d67fbe02a9f1f
|
4
|
+
data.tar.gz: 9b94784ff8b792c65134ee6b37c7feea7f03ef95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e550aa1c55ff3836f445ebe0639ad7259472dff85fa1a52f21ee6eb303ca685f5514cb523ff6c6e0463261800be05e34df1435ae7a1ade3dbc5e941d11365cd3
|
7
|
+
data.tar.gz: e1ab6a03166e564d9b56ef2147c5d3aa56cdf89a216daab4ca1c57f0cce8398f6c515dda3031621e566cbea7000c6564d948aaff2504313d702d0929c48f4e1e
|
data/README.md
CHANGED
@@ -21,10 +21,11 @@ require 'minitest/reporters'
|
|
21
21
|
Minitest::Reporters.use! Minitest::Reporters::TurnAgainReporter.new
|
22
22
|
```
|
23
23
|
|
24
|
-
TurnAgainReporter's initializer will pass on all existing Minitest::Reporters::
|
24
|
+
TurnAgainReporter's initializer will pass on all existing Minitest::Reporters::BaseReporter keyword arguments, such as `color: true` but uses some of its own for some customization:
|
25
25
|
|
26
26
|
1. The `indent` keyword can specify the indentation from the left of the console when running. The default is 4 to faithfully mimic turn itself.
|
27
27
|
2. *Unlike turn*, the duration measurements in next to the test status do not include hours, because the vast majority of tests do not require a whole hour for a single test case. However, hours can be re-enabled by passing the `:hours` keyword as `true`.
|
28
|
+
3. The colors that correspond to the test status flags (`PASS`, `FAIL`, `ERROR`, `SKIP`) can be customized by passing in the symbol of an ansi primary color names for the options `pass_color`, `fail_color`, `error_color` and `skip_color`, respectively. Valid names for ANSI primary colors are `:black`, `:red`, `:green`, `:yellow`, `:blue`, `:magenta`, `:cyan`, and `:white`. Additionally `:no_color` can be specified if you want to turn off color only for a specific status.
|
28
29
|
|
29
30
|
An example of these options:
|
30
31
|
|
@@ -32,14 +33,24 @@ An example of these options:
|
|
32
33
|
|
33
34
|
Minitest::Reporters.use!(
|
34
35
|
Minitest::Reporters::TurnAgainReporter.new(
|
35
|
-
|
36
|
+
hours: true, indent: 2, skip_color: :yellow
|
36
37
|
))
|
37
38
|
```
|
38
39
|
|
39
40
|
|
40
41
|
## Demonstration tests
|
41
42
|
|
42
|
-
Rake test tasks exist for demonstrating the output of this gem.
|
43
|
+
Rake test tasks exist for demonstrating the output of this gem. Current tasks are:
|
44
|
+
|
45
|
+
- `rake pass-format`
|
46
|
+
- `rake fail-format`
|
47
|
+
- `rake error-format`
|
48
|
+
- `rake skip-format`
|
49
|
+
- `rake crazy-colors`
|
50
|
+
- `rake indent-option`
|
51
|
+
- `rake hours-option`
|
52
|
+
|
53
|
+
The usual `rake test` task will simply run all of the demonstration files together. This is not particularly useful. Because this necessarily includes purposeful errors and failures, will fail. Please do not file any issues related to these intended failures. Furthermore, because individual demonstration tests set different configuration settings for the whole suite, subsequent runs may have different formatting depending on which demonstration gets run first (as its settings take precendent).
|
43
54
|
|
44
55
|
|
45
56
|
## Installation
|
data/Rakefile
CHANGED
@@ -6,22 +6,19 @@ Rake::TestTask.new do |t|
|
|
6
6
|
t.test_files = Dir[File.join(File.dirname(__FILE__), 'test/**/*test.rb')]
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
demonstrations = [
|
10
|
+
["pass-format", "pass_format_test.rb" ],
|
11
|
+
["fail-format", "fail_format_test.rb" ],
|
12
|
+
["error-format", "error_format_test.rb" ],
|
13
|
+
["skip-format", "skip_format_test.rb" ],
|
14
|
+
["crazy-colors", "color_options_test.rb" ],
|
15
|
+
["indent-option", "indent_option_test.rb" ],
|
16
|
+
["hours-option", "hours_option_test.rb" ],
|
17
|
+
]
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
Rake::TestTask.new("skip-format") do |t|
|
25
|
-
t.libs << "test"
|
26
|
-
t.test_files = [File.join(File.dirname(__FILE__), 'test/integration/skip_format_test.rb')]
|
19
|
+
demonstrations.each do |task_name, test_file|
|
20
|
+
Rake::TestTask.new(task_name) do |t|
|
21
|
+
t.libs << "test"
|
22
|
+
t.test_files = [File.join(File.dirname(__FILE__), "test/integration/#{test_file}")]
|
23
|
+
end
|
27
24
|
end
|
@@ -27,30 +27,81 @@ module Minitest
|
|
27
27
|
include ANSI::Code
|
28
28
|
include RelativePosition
|
29
29
|
|
30
|
-
attr_reader :hours, :indent
|
30
|
+
attr_reader :hours, :indent,
|
31
|
+
:pass_color, :fail_color, :error_color, :skip_color
|
31
32
|
|
32
33
|
def initialize(options = {})
|
33
|
-
|
34
|
-
@
|
34
|
+
options = option_defaults.merge(options)
|
35
|
+
@hours = !!options.fetch(:hours)
|
36
|
+
@indent = options.fetch(:indent)
|
37
|
+
@pass_color = options.fetch(:pass_color)
|
38
|
+
@fail_color = options.fetch(:fail_color)
|
39
|
+
@error_color = options.fetch(:error_color)
|
40
|
+
@skip_color = options.fetch(:skip_color)
|
35
41
|
super(options)
|
36
42
|
end
|
37
43
|
|
44
|
+
|
45
|
+
def option_defaults
|
46
|
+
{ hours: false,
|
47
|
+
indent: 4,
|
48
|
+
pass_color: :green,
|
49
|
+
fail_color: :red,
|
50
|
+
error_color: :yellow,
|
51
|
+
skip_color: :cyan,
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
|
38
56
|
def start
|
39
57
|
super
|
40
58
|
puts('Started with run options %s' % options[:args])
|
41
59
|
puts
|
42
60
|
end
|
43
61
|
|
62
|
+
|
44
63
|
def report
|
45
64
|
super
|
65
|
+
|
66
|
+
passed = count - (failures + errors + skips)
|
67
|
+
|
46
68
|
puts('Finished in %.5fs' % total_time)
|
47
|
-
print('%d tests, %d assertions, ' % [count, assertions])
|
48
|
-
color = failures.zero? && errors.zero? ? :green : :red
|
49
|
-
print(send(color) { '%d failures, %d errors, ' } % [failures, errors])
|
50
|
-
print(yellow { '%d skips' } % skips)
|
51
69
|
puts
|
70
|
+
print(bold { '%d tests' } % count)
|
71
|
+
print(', ')
|
72
|
+
print(send(report_passed_color) { '%d passed' } % passed)
|
73
|
+
print(', ')
|
74
|
+
print(send(report_failures_color) { '%d failures' } % failures)
|
75
|
+
print(', ')
|
76
|
+
print(send(report_errors_color) { '%d errors' } % errors)
|
77
|
+
print(', ')
|
78
|
+
print(send(report_skips_color) { '%d skips' } % skips)
|
79
|
+
print(', ')
|
80
|
+
print('%d assertions' % assertions)
|
81
|
+
puts
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def print_colored_status(test)
|
86
|
+
print_status = -> { pad_mark( result(test).to_s.upcase ) }
|
87
|
+
if test.passed?
|
88
|
+
print(send(pass_color, &print_status))
|
89
|
+
elsif test.skipped?
|
90
|
+
print(send(skip_color, &print_status))
|
91
|
+
elsif test.error?
|
92
|
+
print(send(error_color, &print_status))
|
93
|
+
else
|
94
|
+
print(send(fail_color, &print_status))
|
95
|
+
end
|
52
96
|
end
|
53
97
|
|
98
|
+
##
|
99
|
+
# To match the interface of printing of colors via methods with blocks.
|
100
|
+
def no_color(&block)
|
101
|
+
block.call
|
102
|
+
end
|
103
|
+
|
104
|
+
|
54
105
|
def record(test)
|
55
106
|
super
|
56
107
|
print (' ' * indent)
|
@@ -64,16 +115,56 @@ module Minitest
|
|
64
115
|
end
|
65
116
|
end
|
66
117
|
|
118
|
+
##
|
119
|
+
# Divergence from Minitest::Reporters::SpecReporter is that here we are
|
120
|
+
# printing the exception name with padding, so that it doesn't break the
|
121
|
+
# visual flow/alignment of all the vertical, colored test result statuses.
|
122
|
+
def print_info(e, name=true)
|
123
|
+
print_with_info_padding("#{e.exception.class.to_s}: ") if name
|
124
|
+
e.message.each_line { |line| print_with_info_padding(line) }
|
125
|
+
|
126
|
+
# When e is a Minitest::UnexpectedError, the filtered backtrace is already part of the message printed out
|
127
|
+
# by the previous line. In that case, and that case only, skip the backtrace output.
|
128
|
+
unless e.is_a?(MiniTest::UnexpectedError)
|
129
|
+
trace = filter_backtrace(e.backtrace)
|
130
|
+
trace.each { |line| print_with_info_padding(line) }
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
67
135
|
protected ######################################################################
|
68
136
|
|
137
|
+
|
138
|
+
def report_passed_color
|
139
|
+
failures.zero? && errors.zero? ? pass_color : :no_color
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def report_failures_color
|
144
|
+
failures.zero? ? :no_color : fail_color
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
def report_errors_color
|
149
|
+
errors.zero? ? :no_color : error_color
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
def report_skips_color
|
154
|
+
skips.zero? ? :no_color : skip_color
|
155
|
+
end
|
156
|
+
|
157
|
+
|
69
158
|
def before_suite(suite)
|
70
159
|
puts suite
|
71
160
|
end
|
72
161
|
|
162
|
+
|
73
163
|
def after_suite(suite)
|
74
164
|
puts
|
75
165
|
end
|
76
166
|
|
167
|
+
|
77
168
|
def format_time(t)
|
78
169
|
if hours
|
79
170
|
' (%02d:%02d:%06.3f) ' % [
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
Minitest::Reporters.use!(Minitest::Reporters::TurnAgainReporter.new(
|
4
|
+
pass_color: :blue,
|
5
|
+
fail_color: :magenta,
|
6
|
+
error_color: :cyan,
|
7
|
+
skip_color: :black
|
8
|
+
))
|
9
|
+
|
10
|
+
class ColorOptionsTest < Minitest::Test
|
11
|
+
|
12
|
+
def test_the_truth
|
13
|
+
assert(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_failing_the_truth
|
17
|
+
refute(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_triggering_an_error
|
21
|
+
Object.new.triggernomethoderror
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_skip_color
|
25
|
+
skip
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
Minitest::Reporters.use!(Minitest::Reporters::TurnAgainReporter.new(
|
4
|
+
indent: 12
|
5
|
+
))
|
6
|
+
|
7
|
+
class IndentOptionTest < Minitest::Test
|
8
|
+
|
9
|
+
def test_waaay_over_there
|
10
|
+
assert(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def test_this_is_actually_pretty_gross
|
15
|
+
assert(true)
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def test_an_obscene_waste_of_space
|
20
|
+
assert(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turn-again-reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Kwiatkowski
|
@@ -76,8 +76,11 @@ files:
|
|
76
76
|
- Rakefile
|
77
77
|
- lib/minitest/reporters/turn_again_reporter.rb
|
78
78
|
- lib/minitest/reporters/turn_again_reporter/version.rb
|
79
|
+
- test/integration/color_options_test.rb
|
79
80
|
- test/integration/error_format_test.rb
|
80
81
|
- test/integration/fail_format_test.rb
|
82
|
+
- test/integration/hours_option_test.rb
|
83
|
+
- test/integration/indent_option_test.rb
|
81
84
|
- test/integration/pass_format_test.rb
|
82
85
|
- test/integration/skip_format_test.rb
|
83
86
|
- test/test_helper.rb
|
@@ -108,8 +111,11 @@ specification_version: 4
|
|
108
111
|
summary: A reporter for the minitest-reporters gem that more accurately mimics the
|
109
112
|
behavior of the turn gem.
|
110
113
|
test_files:
|
114
|
+
- test/integration/color_options_test.rb
|
111
115
|
- test/integration/error_format_test.rb
|
112
116
|
- test/integration/fail_format_test.rb
|
117
|
+
- test/integration/hours_option_test.rb
|
118
|
+
- test/integration/indent_option_test.rb
|
113
119
|
- test/integration/pass_format_test.rb
|
114
120
|
- test/integration/skip_format_test.rb
|
115
121
|
- test/test_helper.rb
|