minitest-reporters 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +24 -2
- data/CHANGELOG.md +6 -1
- data/lib/minitest/reporters/base_reporter.rb +11 -14
- data/lib/minitest/reporters/html_reporter.rb +1 -1
- data/lib/minitest/reporters/mean_time_reporter.rb +2 -2
- data/lib/minitest/reporters/progress_reporter.rb +3 -3
- data/lib/minitest/reporters/version.rb +1 -1
- data/test/integration/reporters/progress_reporter_test.rb +10 -4
- data/test/unit/minitest/mean_time_reporter_unit_test.rb +47 -45
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd189c42b4c7adcec48a0ce3db5a5abe59dd6d766ef6b9d69b7bca10a305a8ba
|
4
|
+
data.tar.gz: 63c9745d9d6a1de4492434dea58ecf37b78ce3f5df2bdc0dc159915914dc2235
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 676d1065ac7070eb24a1824f8fc914e243281538ad0c8c7c6db24cb5529e395e1992f685562f061628e50ee394d0ce47f09e1f54d9350034be2f3130765288a1
|
7
|
+
data.tar.gz: e6c1ecb07353173d26b3546af1591ec63d1684d3bb66c4740b3b52172ee8ec701e42a831cae19cd2d7263401d61b5e7d96bbbcbe5087b21dbbfb7fccb4410c0a
|
data/.rubocop.yml
CHANGED
@@ -13,7 +13,7 @@ Lint:
|
|
13
13
|
|
14
14
|
Metrics:
|
15
15
|
Severity: refactor
|
16
|
-
Enabled:
|
16
|
+
Enabled: false
|
17
17
|
|
18
18
|
Metrics/LineLength:
|
19
19
|
Severity: convention
|
@@ -36,15 +36,37 @@ Security:
|
|
36
36
|
|
37
37
|
#todo: enable
|
38
38
|
Style:
|
39
|
-
Enabled:
|
39
|
+
Enabled: true
|
40
40
|
|
41
41
|
Style/FormatStringToken:
|
42
42
|
Enabled: false
|
43
43
|
|
44
|
+
Style/IfUnlessModifier:
|
45
|
+
Enabled: false
|
46
|
+
|
44
47
|
#todo: enable
|
45
48
|
Style/StringLiterals:
|
46
49
|
Enabled: false
|
47
50
|
|
51
|
+
Style/TrailingCommaInHashLiteral:
|
52
|
+
EnforcedStyleForMultiline: comma
|
53
|
+
|
54
|
+
#todo: enable
|
55
|
+
Style/HashSyntax:
|
56
|
+
Enabled: false
|
57
|
+
|
58
|
+
#todo: enable
|
59
|
+
Style/FormatString:
|
60
|
+
Enabled: false
|
61
|
+
|
62
|
+
#todo: enable
|
63
|
+
Style/ClassVars:
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
#todo: enable
|
67
|
+
Style/Alias:
|
68
|
+
Enabled: false
|
69
|
+
|
48
70
|
Style/Documentation:
|
49
71
|
Enabled: false
|
50
72
|
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
### [dev](https://github.com/kern/minitest-reporters/compare/v1.3.
|
1
|
+
### [dev](https://github.com/kern/minitest-reporters/compare/v1.3.3...master)
|
2
|
+
|
3
|
+
### [1.3.3](https://github.com/kern/minitest-reporters/compare/v1.3.2...v1.3.3)
|
4
|
+
|
5
|
+
* fixed problem with default report paths for MeanTimeReporter [#269](https://github.com/kern/minitest-reporters/pull/269)
|
6
|
+
contributed by [duonoid](https://github.com/duonoid)
|
2
7
|
|
3
8
|
### [1.3.2](https://github.com/kern/minitest-reporters/compare/v1.3.2.beta2...v1.3.2)
|
4
9
|
|
@@ -28,10 +28,10 @@ module Minitest
|
|
28
28
|
|
29
29
|
suite_changed = last_test.nil? || last_test.name != test.class.name
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
return unless suite_changed
|
32
|
+
|
33
|
+
after_suite(last_test) if last_test
|
34
|
+
before_suite(test.class)
|
35
35
|
end
|
36
36
|
|
37
37
|
def record(test)
|
@@ -40,8 +40,7 @@ module Minitest
|
|
40
40
|
end
|
41
41
|
|
42
42
|
# called by our own after hooks
|
43
|
-
def after_test(_test)
|
44
|
-
end
|
43
|
+
def after_test(_test); end
|
45
44
|
|
46
45
|
def report
|
47
46
|
super
|
@@ -50,11 +49,9 @@ module Minitest
|
|
50
49
|
|
51
50
|
protected
|
52
51
|
|
53
|
-
def after_suite(test)
|
54
|
-
end
|
52
|
+
def after_suite(test); end
|
55
53
|
|
56
|
-
def before_suite(test)
|
57
|
-
end
|
54
|
+
def before_suite(test); end
|
58
55
|
|
59
56
|
def result(test)
|
60
57
|
if test.error?
|
@@ -115,10 +112,10 @@ module Minitest
|
|
115
112
|
|
116
113
|
# When e is a Minitest::UnexpectedError, the filtered backtrace is already part of the message printed out
|
117
114
|
# by the previous line. In that case, and that case only, skip the backtrace output.
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
115
|
+
return if e.is_a?(MiniTest::UnexpectedError)
|
116
|
+
|
117
|
+
trace = filter_backtrace(e.backtrace)
|
118
|
+
trace.each { |line| print_with_info_padding(line) }
|
122
119
|
end
|
123
120
|
end
|
124
121
|
end
|
@@ -62,7 +62,7 @@ module Minitest
|
|
62
62
|
:erb_template => "#{File.dirname(__FILE__)}/../templates/index.html.erb",
|
63
63
|
:reports_dir => 'test/html_reports',
|
64
64
|
:mode => :safe,
|
65
|
-
:output_filename => 'index.html'
|
65
|
+
:output_filename => 'index.html',
|
66
66
|
}
|
67
67
|
|
68
68
|
settings = defaults.merge(args)
|
@@ -124,8 +124,8 @@ module Minitest
|
|
124
124
|
show_progress: true,
|
125
125
|
show_all_runs: true,
|
126
126
|
sort_column: :avg,
|
127
|
-
previous_runs_filename: Dir.tmpdir
|
128
|
-
report_filename: Dir.tmpdir
|
127
|
+
previous_runs_filename: File.join(Dir.tmpdir, 'minitest_reporters_previous_run'),
|
128
|
+
report_filename: File.join(Dir.tmpdir, 'minitest_reporters_report'),
|
129
129
|
}
|
130
130
|
end
|
131
131
|
|
@@ -13,20 +13,20 @@ module Minitest
|
|
13
13
|
include RelativePosition
|
14
14
|
include ANSI::Code
|
15
15
|
|
16
|
-
PROGRESS_MARK = '='
|
16
|
+
PROGRESS_MARK = '='.freeze
|
17
17
|
|
18
18
|
def initialize(options = {})
|
19
19
|
super
|
20
20
|
@detailed_skip = options.fetch(:detailed_skip, true)
|
21
21
|
|
22
|
-
@progress = ProgressBar.create(
|
22
|
+
@progress = ProgressBar.create(
|
23
23
|
total: total_count,
|
24
24
|
starting_at: count,
|
25
25
|
progress_mark: green(PROGRESS_MARK),
|
26
26
|
remainder_mark: ' ',
|
27
27
|
format: options.fetch(:format, ' %C/%c: [%B] %p%% %a, %e'),
|
28
28
|
autostart: false
|
29
|
-
|
29
|
+
)
|
30
30
|
end
|
31
31
|
|
32
32
|
def start
|
@@ -5,7 +5,7 @@ module MinitestReportersTest
|
|
5
5
|
def test_all_failures_are_displayed
|
6
6
|
fixtures_directory = File.expand_path('../../../fixtures', __FILE__)
|
7
7
|
test_filename = File.join(fixtures_directory, 'progress_test.rb')
|
8
|
-
output =
|
8
|
+
output = `#{ruby_executable} #{test_filename} 2>&1`
|
9
9
|
assert_match 'ERROR["test_error"', output, 'Errors should be displayed'
|
10
10
|
assert_match 'FAIL["test_failure"', output, 'Failures should be displayed'
|
11
11
|
assert_match 'SKIP["test_skip', output, 'Skipped tests should be displayed'
|
@@ -13,7 +13,7 @@ module MinitestReportersTest
|
|
13
13
|
def test_skipped_tests_are_not_displayed
|
14
14
|
fixtures_directory = File.expand_path('../../../fixtures', __FILE__)
|
15
15
|
test_filename = File.join(fixtures_directory, 'progress_detailed_skip_test.rb')
|
16
|
-
output =
|
16
|
+
output = `#{ruby_executable} #{test_filename} 2>&1`
|
17
17
|
assert_match 'ERROR["test_error"', output, 'Errors should be displayed'
|
18
18
|
assert_match 'FAIL["test_failure"', output, 'Failures should be displayed'
|
19
19
|
refute_match 'SKIP["test_skip', output, 'Skipped tests should not be displayed'
|
@@ -21,14 +21,20 @@ module MinitestReportersTest
|
|
21
21
|
def test_progress_works_with_filter_and_specs
|
22
22
|
fixtures_directory = File.expand_path('../../../fixtures', __FILE__)
|
23
23
|
test_filename = File.join(fixtures_directory, 'spec_test.rb')
|
24
|
-
output =
|
24
|
+
output = `#{ruby_executable} #{test_filename} -n /length/ 2>&1`
|
25
25
|
refute_match '0 out of 0', output, 'Progress should not puts a warning'
|
26
26
|
end
|
27
27
|
def test_progress_works_with_strict_filter
|
28
28
|
fixtures_directory = File.expand_path('../../../fixtures', __FILE__)
|
29
29
|
test_filename = File.join(fixtures_directory, 'spec_test.rb')
|
30
|
-
output =
|
30
|
+
output = `#{ruby_executable} #{test_filename} -n /^test_0001_works$/ 2>&1`
|
31
31
|
refute_match '0 out of 0', output, 'Progress should not puts a warning'
|
32
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def ruby_executable
|
37
|
+
defined?(JRUBY_VERSION) ? 'jruby' : 'ruby'
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
@@ -1,10 +1,18 @@
|
|
1
1
|
require_relative '../../test_helper'
|
2
|
+
require "ostruct"
|
2
3
|
|
3
4
|
module MinitestReportersTest
|
4
5
|
class MeanTimeReporterUnitTest < Minitest::Test
|
5
6
|
def setup
|
7
|
+
@test_data = []
|
8
|
+
@test_data << { name: 'MIDDLE', prev_time: 5.0, cur_time: 5.0 }
|
9
|
+
@test_data << { name: 'MIN_FAST', prev_time: 0.5, cur_time: 3.5 }
|
10
|
+
@test_data << { name: 'MIN_SLOW', prev_time: 10.5, cur_time: 10.5 }
|
11
|
+
@test_data << { name: 'MAX_FAST', prev_time: 1.2, cur_time: 0.9 }
|
12
|
+
@test_data << { name: 'MAX_SLOW', prev_time: 16.3, cur_time: 6.3 }
|
13
|
+
@test_data << { name: 'AVG_FAST', prev_time: 1.3, cur_time: 0.65 }
|
14
|
+
@test_data << { name: 'AVG_SLOW', prev_time: 10.2, cur_time: 14.2 }
|
6
15
|
configure_report_paths
|
7
|
-
previous_test_run
|
8
16
|
end
|
9
17
|
|
10
18
|
def teardown
|
@@ -12,8 +20,17 @@ module MinitestReportersTest
|
|
12
20
|
File.delete(@report_file_path) if File.exist?(@report_file_path)
|
13
21
|
end
|
14
22
|
|
23
|
+
def test_defaults
|
24
|
+
subject = Minitest::Reporters::MeanTimeReporter.new.send(:defaults)
|
25
|
+
|
26
|
+
expected_prefix = "#{Dir.tmpdir}#{File::Separator}"
|
27
|
+
assert_match expected_prefix, subject[:previous_runs_filename]
|
28
|
+
assert_match expected_prefix, subject[:report_filename]
|
29
|
+
end
|
30
|
+
|
15
31
|
def test_sorts_avg_numerically
|
16
|
-
|
32
|
+
prev_output = generate_report(:avg, :prev_time)
|
33
|
+
report_output = generate_report(:avg, :cur_time)
|
17
34
|
|
18
35
|
expected_order = [
|
19
36
|
'AVG_SLOW',
|
@@ -24,11 +41,12 @@ module MinitestReportersTest
|
|
24
41
|
'MAX_FAST',
|
25
42
|
'AVG_FAST'
|
26
43
|
]
|
27
|
-
verify_result_order(report_output, expected_order)
|
44
|
+
verify_result_order(report_output, expected_order, prev_output)
|
28
45
|
end
|
29
46
|
|
30
47
|
def test_sorts_min_numerically
|
31
|
-
|
48
|
+
prev_output = generate_report(:min, :prev_time)
|
49
|
+
report_output = generate_report(:min, :cur_time)
|
32
50
|
|
33
51
|
expected_order = [
|
34
52
|
'MIN_SLOW',
|
@@ -39,11 +57,12 @@ module MinitestReportersTest
|
|
39
57
|
'AVG_FAST',
|
40
58
|
'MIN_FAST'
|
41
59
|
]
|
42
|
-
verify_result_order(report_output, expected_order)
|
60
|
+
verify_result_order(report_output, expected_order, prev_output)
|
43
61
|
end
|
44
62
|
|
45
63
|
def test_sorts_max_numerically
|
46
|
-
|
64
|
+
prev_output = generate_report(:max, :prev_time)
|
65
|
+
report_output = generate_report(:max, :cur_time)
|
47
66
|
|
48
67
|
expected_order = [
|
49
68
|
'MAX_SLOW',
|
@@ -54,11 +73,12 @@ module MinitestReportersTest
|
|
54
73
|
'AVG_FAST',
|
55
74
|
'MAX_FAST'
|
56
75
|
]
|
57
|
-
verify_result_order(report_output, expected_order)
|
76
|
+
verify_result_order(report_output, expected_order, prev_output)
|
58
77
|
end
|
59
78
|
|
60
79
|
def test_sorts_last_numerically
|
61
|
-
|
80
|
+
prev_output = generate_report(:last, :prev_time)
|
81
|
+
report_output = generate_report(:last, :cur_time)
|
62
82
|
|
63
83
|
expected_order = [
|
64
84
|
'AVG_SLOW',
|
@@ -69,7 +89,7 @@ module MinitestReportersTest
|
|
69
89
|
'MAX_FAST',
|
70
90
|
'AVG_FAST'
|
71
91
|
]
|
72
|
-
verify_result_order(report_output, expected_order)
|
92
|
+
verify_result_order(report_output, expected_order, prev_output)
|
73
93
|
end
|
74
94
|
|
75
95
|
private
|
@@ -80,27 +100,9 @@ module MinitestReportersTest
|
|
80
100
|
Minitest::Reporters.stub(:clock_time, base_clock_time - run_time) do
|
81
101
|
@reporter.before_suite(test_suite)
|
82
102
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
def previous_test_run
|
87
|
-
@reporter = Minitest::Reporters::MeanTimeReporter.new(
|
88
|
-
previous_runs_filename: @previous_run_path,
|
89
|
-
report_filename: @report_file_path
|
90
|
-
)
|
91
|
-
|
92
|
-
simulate_suite_runtime('MIDDLE', 5.0)
|
93
|
-
simulate_suite_runtime('MIN_FAST', 0.5)
|
94
|
-
simulate_suite_runtime('MIN_SLOW', 10.5)
|
95
|
-
simulate_suite_runtime('MAX_FAST', 1.2)
|
96
|
-
simulate_suite_runtime('MAX_SLOW', 16.3)
|
97
|
-
simulate_suite_runtime('AVG_FAST', 1.3)
|
98
|
-
simulate_suite_runtime('AVG_SLOW', 10.2)
|
99
|
-
@reporter.tests << Minitest::Test.new('Final')
|
100
|
-
# Generate a "previous" run
|
101
|
-
@reporter.io = StringIO.new
|
102
|
-
@reporter.start
|
103
|
-
@reporter.report
|
103
|
+
Minitest::Reporters.stub(:clock_time, base_clock_time) do
|
104
|
+
@reporter.after_suite(test_suite)
|
105
|
+
end
|
104
106
|
end
|
105
107
|
|
106
108
|
def configure_report_paths
|
@@ -114,20 +116,14 @@ module MinitestReportersTest
|
|
114
116
|
report_file.delete
|
115
117
|
end
|
116
118
|
|
117
|
-
def generate_report(sort_column)
|
119
|
+
def generate_report(sort_column, time_name)
|
118
120
|
# Reset the reporter for the test run
|
119
121
|
@reporter = Minitest::Reporters::MeanTimeReporter.new(
|
120
122
|
previous_runs_filename: @previous_run_path,
|
121
123
|
report_filename: @report_file_path,
|
122
124
|
sort_column: sort_column
|
123
125
|
)
|
124
|
-
simulate_suite_runtime(
|
125
|
-
simulate_suite_runtime('MIN_FAST', 3.5)
|
126
|
-
simulate_suite_runtime('MIN_SLOW', 10.5)
|
127
|
-
simulate_suite_runtime('MAX_FAST', 0.9)
|
128
|
-
simulate_suite_runtime('MAX_SLOW', 6.3)
|
129
|
-
simulate_suite_runtime('AVG_FAST', 0.65)
|
130
|
-
simulate_suite_runtime('AVG_SLOW', 14.2)
|
126
|
+
@test_data.each { |hash| simulate_suite_runtime(hash[:name], hash[time_name])}
|
131
127
|
@reporter.tests << Minitest::Test.new('Final')
|
132
128
|
|
133
129
|
report_output = StringIO.new
|
@@ -137,16 +133,22 @@ module MinitestReportersTest
|
|
137
133
|
report_output
|
138
134
|
end
|
139
135
|
|
140
|
-
def verify_result_order(report_output, expected_order)
|
141
|
-
|
142
|
-
test_lines = report_output
|
143
|
-
test_lines.select! { |line| line.start_with?('Avg:') }
|
136
|
+
def verify_result_order(report_output, expected_order, prev_output)
|
137
|
+
prev_lines = extract_test_lines(prev_output)
|
138
|
+
test_lines = extract_test_lines(report_output)
|
144
139
|
|
145
|
-
# Exclude the final placeholder 0 second test from assertions
|
146
|
-
test_lines.reject! { |line| line.end_with?('Minitest::Test') }
|
147
140
|
actual_order = test_lines.map { |line| line.gsub(/.*Description: /, '') }
|
148
141
|
|
149
|
-
assert_equal(expected_order, actual_order, "\n#{test_lines.join("\n")}")
|
142
|
+
assert_equal(expected_order, actual_order, "\nCurrent report:\n#{test_lines.join("\n")}\n\nPrevious report:\n#{prev_lines.join("\n")}")
|
143
|
+
end
|
144
|
+
|
145
|
+
def extract_test_lines(report_output)
|
146
|
+
report_output.rewind
|
147
|
+
test_lines = report_output.read.split("\n")
|
148
|
+
test_lines.select! {|line| line.start_with?('Avg:')}
|
149
|
+
# Exclude the final placeholder 0 second test from assertions
|
150
|
+
test_lines.reject! {|line| line.end_with?('Minitest::Test')}
|
151
|
+
test_lines
|
150
152
|
end
|
151
153
|
end
|
152
154
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-reporters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Kern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|