minitest-heat 0.0.2 → 0.0.6
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/.gitignore +1 -0
- data/.rubocop.yml +23 -0
- data/Gemfile +5 -3
- data/Gemfile.lock +32 -1
- data/README.md +12 -3
- data/Rakefile +8 -6
- data/lib/minitest/heat/backtrace.rb +25 -48
- data/lib/minitest/heat/hit.rb +83 -0
- data/lib/minitest/heat/issue.rb +67 -32
- data/lib/minitest/heat/line.rb +74 -0
- data/lib/minitest/heat/location.rb +144 -23
- data/lib/minitest/heat/map.rb +14 -24
- data/lib/minitest/heat/output/backtrace.rb +121 -0
- data/lib/minitest/heat/output/issue.rb +128 -0
- data/lib/minitest/heat/output/map.rb +67 -0
- data/lib/minitest/heat/output/marker.rb +50 -0
- data/lib/minitest/heat/output/results.rb +118 -0
- data/lib/minitest/heat/output/source_code.rb +131 -0
- data/lib/minitest/heat/output/token.rb +101 -0
- data/lib/minitest/heat/output.rb +31 -222
- data/lib/minitest/heat/results.rb +24 -13
- data/lib/minitest/heat/source.rb +6 -1
- data/lib/minitest/heat/version.rb +3 -1
- data/lib/minitest/heat.rb +2 -0
- data/lib/minitest/heat_plugin.rb +5 -5
- data/lib/minitest/heat_reporter.rb +28 -24
- data/minitest-heat.gemspec +5 -2
- metadata +83 -3
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module Minitest
|
4
4
|
module Heat
|
5
|
+
# A collection of test failures
|
5
6
|
class Results
|
6
|
-
|
7
7
|
attr_reader :test_count,
|
8
8
|
:assertion_count,
|
9
9
|
:success_count,
|
@@ -20,6 +20,7 @@ module Minitest
|
|
20
20
|
broken: [],
|
21
21
|
failure: [],
|
22
22
|
skipped: [],
|
23
|
+
painful: [],
|
23
24
|
slow: []
|
24
25
|
}
|
25
26
|
@start_time = nil
|
@@ -49,8 +50,8 @@ module Minitest
|
|
49
50
|
(assertion_count / total_time).round(2)
|
50
51
|
end
|
51
52
|
|
52
|
-
def
|
53
|
-
errors? || failures? || skips?
|
53
|
+
def problems?
|
54
|
+
errors? || brokens? || failures? || skips?
|
54
55
|
end
|
55
56
|
|
56
57
|
def errors
|
@@ -69,12 +70,20 @@ module Minitest
|
|
69
70
|
issues.fetch(:skipped) { [] }
|
70
71
|
end
|
71
72
|
|
73
|
+
def painfuls
|
74
|
+
issues
|
75
|
+
.fetch(:painful) { [] }
|
76
|
+
.sort_by(&:time)
|
77
|
+
.reverse
|
78
|
+
.take(5)
|
79
|
+
end
|
80
|
+
|
72
81
|
def slows
|
73
82
|
issues
|
74
83
|
.fetch(:slow) { [] }
|
75
|
-
.
|
84
|
+
.sort_by(&:time)
|
76
85
|
.reverse
|
77
|
-
.take(
|
86
|
+
.take(5)
|
78
87
|
end
|
79
88
|
|
80
89
|
def errors?
|
@@ -93,19 +102,21 @@ module Minitest
|
|
93
102
|
skips.any?
|
94
103
|
end
|
95
104
|
|
96
|
-
def
|
97
|
-
|
98
|
-
@assertion_count += result.assertions
|
99
|
-
@success_count += 1 if result.passed?
|
105
|
+
def painfuls?
|
106
|
+
painfuls.any?
|
100
107
|
end
|
101
108
|
|
102
|
-
def
|
103
|
-
|
109
|
+
def slows?
|
110
|
+
slows.any?
|
111
|
+
end
|
112
|
+
|
113
|
+
def record(issue)
|
114
|
+
@test_count += 1
|
115
|
+
@assertion_count += issue.result.assertions
|
116
|
+
@success_count += 1 if issue.result.passed?
|
104
117
|
|
105
118
|
@issues[issue.type] ||= []
|
106
119
|
@issues[issue.type] << issue
|
107
|
-
|
108
|
-
issue
|
109
120
|
end
|
110
121
|
end
|
111
122
|
end
|
data/lib/minitest/heat/source.rb
CHANGED
@@ -51,10 +51,15 @@ module Minitest
|
|
51
51
|
#
|
52
52
|
# @return [type] [description]
|
53
53
|
def file_lines
|
54
|
-
@raw_lines ||= File.readlines(
|
54
|
+
@raw_lines ||= File.readlines(filename, chomp: true)
|
55
55
|
@raw_lines.pop while @raw_lines.last.strip.empty?
|
56
56
|
|
57
57
|
@raw_lines
|
58
|
+
rescue Errno::ENOENT
|
59
|
+
# Occasionally, for a variety of reasons, a file can't be read. In those cases, it's best to
|
60
|
+
# return no source code lines rather than have the test suite raise an error unrelated to
|
61
|
+
# the code being tested becaues that gets confusing.
|
62
|
+
[]
|
58
63
|
end
|
59
64
|
|
60
65
|
private
|
data/lib/minitest/heat.rb
CHANGED
data/lib/minitest/heat_plugin.rb
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
require_relative 'heat_reporter'
|
4
4
|
|
5
5
|
module Minitest
|
6
|
-
def self.plugin_heat_options(opts,
|
7
|
-
opts.on '--show-fast',
|
6
|
+
def self.plugin_heat_options(opts, _options)
|
7
|
+
opts.on '--show-fast', 'Show failures as they happen instead of waiting for the entire suite.' do
|
8
8
|
# Heat.show_fast!
|
9
9
|
end
|
10
10
|
|
11
|
-
# TODO options.
|
11
|
+
# TODO: options.
|
12
12
|
# 1. Fail Fast
|
13
13
|
# 2. Don't worry about skips.
|
14
14
|
# 3. Skip coverage.
|
@@ -18,9 +18,9 @@ module Minitest
|
|
18
18
|
io = options[:io]
|
19
19
|
|
20
20
|
# Clean out the existing reporters.
|
21
|
-
|
21
|
+
reporter.reporters = []
|
22
22
|
|
23
23
|
# Use Reviewer as the sole reporter.
|
24
|
-
|
24
|
+
reporter << HeatReporter.new(io, options)
|
25
25
|
end
|
26
26
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'heat'
|
4
4
|
|
5
5
|
module Minitest
|
6
6
|
# Custom minitest reporter to proactively identify likely culprits in test failures by focusing on
|
@@ -29,50 +29,49 @@ module Minitest
|
|
29
29
|
# Pulls from minitest-color as well:
|
30
30
|
# https://github.com/teoljungberg/minitest-color/blob/master/lib/minitest/color_plugin.rb
|
31
31
|
class HeatReporter < AbstractReporter
|
32
|
-
|
33
32
|
attr_reader :output,
|
34
33
|
:options,
|
35
34
|
:results,
|
36
35
|
:map
|
37
36
|
|
38
37
|
def initialize(io = $stdout, options = {})
|
39
|
-
@output = Heat::Output.new(io)
|
40
38
|
@options = options
|
41
39
|
|
42
|
-
@results =
|
43
|
-
@map =
|
40
|
+
@results = Heat::Results.new
|
41
|
+
@map = Heat::Map.new
|
42
|
+
@output = Heat::Output.new(io)
|
44
43
|
end
|
45
44
|
|
46
45
|
# Starts reporting on the run.
|
47
46
|
def start
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
results.start_timer!
|
48
|
+
|
49
|
+
# A couple of blank lines to create some breathing room
|
50
|
+
output.newline
|
51
|
+
output.newline
|
51
52
|
end
|
52
53
|
|
53
54
|
# About to start running a test. This allows a reporter to show that it is starting or that we
|
54
55
|
# are in the middle of a test run.
|
55
|
-
def prerecord(klass, name)
|
56
|
-
end
|
56
|
+
def prerecord(klass, name); end
|
57
57
|
|
58
58
|
# Records the data from a result.
|
59
59
|
# Minitest::Result source:
|
60
60
|
# https://github.com/seattlerb/minitest/blob/f4f57afaeb3a11bd0b86ab0757704cb78db96cf4/lib/minitest.rb#L504
|
61
61
|
def record(result)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
output.marker(result.result_code)
|
69
|
-
end
|
62
|
+
issue = Heat::Issue.new(result)
|
63
|
+
|
64
|
+
results.record(issue)
|
65
|
+
map.add(*issue.to_hit) if issue.hit?
|
66
|
+
|
67
|
+
output.marker(issue.type)
|
70
68
|
end
|
71
69
|
|
72
70
|
# Outputs the summary of the run.
|
73
71
|
def report
|
74
|
-
|
72
|
+
results.stop_timer!
|
75
73
|
|
74
|
+
# A couple of blank lines to create some breathing room
|
76
75
|
output.newline
|
77
76
|
output.newline
|
78
77
|
|
@@ -80,15 +79,20 @@ module Minitest
|
|
80
79
|
# pressing issues are displayed at the bottom of the report in order to reduce scrolling.
|
81
80
|
# This way, as you fix issues, the list gets shorter, and eventually the least critical
|
82
81
|
# issues will be displayed without scrolling once more problematic issues are resolved.
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
results.brokens.each { |issue| output.issue_details(issue) }
|
87
|
-
results.errors.each { |issue| output.issue_details(issue) }
|
82
|
+
%i[slows painfuls skips failures brokens errors].each do |issue_category|
|
83
|
+
results.send(issue_category).each { |issue| output.issue_details(issue) }
|
84
|
+
end
|
88
85
|
|
86
|
+
# Display a short summary of the total issue counts fore ach category as well as performance
|
87
|
+
# details for the test suite as a whole
|
89
88
|
output.compact_summary(results)
|
90
89
|
|
90
|
+
# If there were issues, shows a short heat map summary of which files and lines were the most
|
91
|
+
# common sources of issues
|
91
92
|
output.heat_map(map)
|
93
|
+
|
94
|
+
# A blank line to create some breathing room
|
95
|
+
output.newline
|
92
96
|
end
|
93
97
|
|
94
98
|
# Did this run pass?
|
data/minitest-heat.gemspec
CHANGED
@@ -21,8 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.metadata['source_code_uri'] = 'https://github.com/garrettdimon/minitest-heat'
|
22
22
|
spec.metadata['wiki_uri'] = 'https://github.com/garrettdimon/minitest-heat/wiki'
|
23
23
|
|
24
|
-
|
25
|
-
|
26
24
|
# Specify which files should be added to the gem when it is released.
|
27
25
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
26
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
@@ -34,6 +32,11 @@ Gem::Specification.new do |spec|
|
|
34
32
|
|
35
33
|
spec.add_runtime_dependency 'minitest'
|
36
34
|
|
35
|
+
spec.add_development_dependency 'awesome_print'
|
36
|
+
spec.add_development_dependency 'dead_end'
|
37
37
|
spec.add_development_dependency 'pry'
|
38
|
+
spec.add_development_dependency 'rubocop'
|
39
|
+
spec.add_development_dependency 'rubocop-minitest'
|
40
|
+
spec.add_development_dependency 'rubocop-rake'
|
38
41
|
spec.add_development_dependency 'simplecov'
|
39
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-heat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garrett Dimon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08
|
11
|
+
date: 2021-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: awesome_print
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dead_end
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: pry
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +66,48 @@ dependencies:
|
|
38
66
|
- - ">="
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
41
111
|
- !ruby/object:Gem::Dependency
|
42
112
|
name: simplecov
|
43
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,6 +131,7 @@ extensions: []
|
|
61
131
|
extra_rdoc_files: []
|
62
132
|
files:
|
63
133
|
- ".gitignore"
|
134
|
+
- ".rubocop.yml"
|
64
135
|
- ".travis.yml"
|
65
136
|
- CODE_OF_CONDUCT.md
|
66
137
|
- Gemfile
|
@@ -72,10 +143,19 @@ files:
|
|
72
143
|
- bin/setup
|
73
144
|
- lib/minitest/heat.rb
|
74
145
|
- lib/minitest/heat/backtrace.rb
|
146
|
+
- lib/minitest/heat/hit.rb
|
75
147
|
- lib/minitest/heat/issue.rb
|
148
|
+
- lib/minitest/heat/line.rb
|
76
149
|
- lib/minitest/heat/location.rb
|
77
150
|
- lib/minitest/heat/map.rb
|
78
151
|
- lib/minitest/heat/output.rb
|
152
|
+
- lib/minitest/heat/output/backtrace.rb
|
153
|
+
- lib/minitest/heat/output/issue.rb
|
154
|
+
- lib/minitest/heat/output/map.rb
|
155
|
+
- lib/minitest/heat/output/marker.rb
|
156
|
+
- lib/minitest/heat/output/results.rb
|
157
|
+
- lib/minitest/heat/output/source_code.rb
|
158
|
+
- lib/minitest/heat/output/token.rb
|
79
159
|
- lib/minitest/heat/results.rb
|
80
160
|
- lib/minitest/heat/source.rb
|
81
161
|
- lib/minitest/heat/version.rb
|
@@ -107,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
187
|
- !ruby/object:Gem::Version
|
108
188
|
version: '0'
|
109
189
|
requirements: []
|
110
|
-
rubygems_version: 3.1.
|
190
|
+
rubygems_version: 3.1.6
|
111
191
|
signing_key:
|
112
192
|
specification_version: 4
|
113
193
|
summary: Presents test results in a visual manner to guide you to where to look first.
|