minitest-heat 0.0.7 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/Gemfile.lock +6 -6
- data/README.md +1 -1
- data/lib/minitest/heat/backtrace/line_parser.rb +25 -0
- data/lib/minitest/heat/backtrace.rb +39 -43
- data/lib/minitest/heat/hit.rb +41 -28
- data/lib/minitest/heat/issue.rb +96 -77
- data/lib/minitest/heat/location.rb +115 -116
- data/lib/minitest/heat/locations.rb +105 -0
- data/lib/minitest/heat/map.rb +16 -20
- data/lib/minitest/heat/output/backtrace.rb +52 -44
- data/lib/minitest/heat/output/issue.rb +69 -62
- data/lib/minitest/heat/output/map.rb +115 -32
- data/lib/minitest/heat/output/marker.rb +5 -3
- data/lib/minitest/heat/output/results.rb +3 -2
- data/lib/minitest/heat/output/source_code.rb +1 -1
- data/lib/minitest/heat/output/token.rb +2 -1
- data/lib/minitest/heat/output.rb +66 -6
- data/lib/minitest/heat/results.rb +26 -4
- data/lib/minitest/heat/source.rb +1 -1
- data/lib/minitest/heat/version.rb +1 -1
- data/lib/minitest/heat.rb +3 -2
- data/lib/minitest/heat_plugin.rb +9 -17
- data/lib/minitest/heat_reporter.rb +26 -39
- metadata +5 -4
- data/lib/minitest/heat/line.rb +0 -74
data/lib/minitest/heat_plugin.rb
CHANGED
@@ -2,25 +2,17 @@
|
|
2
2
|
|
3
3
|
require_relative 'heat_reporter'
|
4
4
|
|
5
|
-
module Minitest
|
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
|
-
# Heat.show_fast!
|
9
|
-
end
|
10
|
-
|
11
|
-
# TODO: options.
|
12
|
-
# 1. Fail Fast
|
13
|
-
# 2. Don't worry about skips.
|
14
|
-
# 3. Skip coverage.
|
15
|
-
end
|
16
|
-
|
5
|
+
module Minitest # rubocop:disable Style/Documentation
|
17
6
|
def self.plugin_heat_init(options)
|
18
|
-
io = options
|
7
|
+
io = options.fetch(:io, $stdout)
|
19
8
|
|
20
|
-
|
21
|
-
|
9
|
+
reporter.reporters.reject! do |reporter|
|
10
|
+
# Minitest Heat acts as a unified Progress *and* Summary reporter. Using other reporters of
|
11
|
+
# those types in conjunction with it creates some overly-verbose output
|
12
|
+
reporter.is_a?(ProgressReporter) || reporter.is_a?(SummaryReporter)
|
13
|
+
end
|
22
14
|
|
23
|
-
#
|
24
|
-
reporter << HeatReporter.new(io, options)
|
15
|
+
# Hook up Reviewer
|
16
|
+
self.reporter.reporters << HeatReporter.new(io, options)
|
25
17
|
end
|
26
18
|
end
|
@@ -32,15 +32,15 @@ module Minitest
|
|
32
32
|
attr_reader :output,
|
33
33
|
:options,
|
34
34
|
:timer,
|
35
|
-
:results
|
36
|
-
:map
|
35
|
+
:results
|
37
36
|
|
38
37
|
def initialize(io = $stdout, options = {})
|
38
|
+
super()
|
39
|
+
|
39
40
|
@options = options
|
40
41
|
|
41
42
|
@timer = Heat::Timer.new
|
42
43
|
@results = Heat::Results.new
|
43
|
-
@map = Heat::Map.new
|
44
44
|
@output = Heat::Output.new(io)
|
45
45
|
end
|
46
46
|
|
@@ -64,32 +64,37 @@ module Minitest
|
|
64
64
|
def record(result)
|
65
65
|
# Convert a Minitest Result into an "issue" to more consistently expose the data needed to
|
66
66
|
# adjust the failure output to the type of failure
|
67
|
-
issue = Heat::Issue.
|
67
|
+
issue = Heat::Issue.from_result(result)
|
68
|
+
|
69
|
+
# Note the number of assertions for the performance summary
|
70
|
+
timer.increment_counts(issue.assertions)
|
68
71
|
|
69
|
-
|
72
|
+
# Record the issue to show details later
|
70
73
|
results.record(issue)
|
71
|
-
map.add(*issue.to_hit) if issue.hit?
|
72
74
|
|
75
|
+
# Show the marker
|
73
76
|
output.marker(issue.type)
|
77
|
+
rescue StandardError => e
|
78
|
+
display_exception_guidance(e)
|
74
79
|
end
|
75
80
|
|
76
|
-
|
77
|
-
def report
|
78
|
-
timer.stop!
|
79
|
-
|
80
|
-
# A couple of blank lines to create some breathing room
|
81
|
+
def display_exception_guidance(exception)
|
81
82
|
output.newline
|
83
|
+
puts 'Sorry, but Minitest Heat encountered an exception recording an issue. Disabling Minitest Heat will get you back on track.'
|
84
|
+
puts 'Please use the following exception details to submit an issue at https://github.com/garrettdimon/minitest-heat/issues'
|
85
|
+
puts "#{exception.message}:"
|
86
|
+
exception.backtrace.each do |line|
|
87
|
+
puts " #{line}"
|
88
|
+
end
|
82
89
|
output.newline
|
90
|
+
end
|
83
91
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
# issues will be displayed without scrolling once more problematic issues are resolved.
|
88
|
-
%i[slows painfuls skips failures brokens errors].each do |issue_category|
|
89
|
-
next unless show?(issue_category)
|
92
|
+
# Outputs the summary of the run.
|
93
|
+
def report
|
94
|
+
timer.stop!
|
90
95
|
|
91
|
-
|
92
|
-
|
96
|
+
# The list of individual issues and their associated details
|
97
|
+
output.issues_list(results)
|
93
98
|
|
94
99
|
# Display a short summary of the total issue counts fore ach category as well as performance
|
95
100
|
# details for the test suite as a whole
|
@@ -97,9 +102,9 @@ module Minitest
|
|
97
102
|
|
98
103
|
# If there were issues, shows a short heat map summary of which files and lines were the most
|
99
104
|
# common sources of issues
|
100
|
-
output.heat_map(
|
105
|
+
output.heat_map(results)
|
101
106
|
|
102
|
-
|
107
|
+
output.newline
|
103
108
|
output.newline
|
104
109
|
end
|
105
110
|
|
@@ -107,23 +112,5 @@ module Minitest
|
|
107
112
|
def passed?
|
108
113
|
results.errors.empty? && results.failures.empty?
|
109
114
|
end
|
110
|
-
|
111
|
-
private
|
112
|
-
|
113
|
-
def no_problems?
|
114
|
-
!results.problems?
|
115
|
-
end
|
116
|
-
|
117
|
-
def no_problems_or_skips?
|
118
|
-
!results.problems? && !results.skips.any?
|
119
|
-
end
|
120
|
-
|
121
|
-
def show?(issue_category)
|
122
|
-
case issue_category
|
123
|
-
when :skips then no_problems?
|
124
|
-
when :painfuls, :slows then no_problems_or_skips?
|
125
|
-
else true
|
126
|
-
end
|
127
|
-
end
|
128
115
|
end
|
129
116
|
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.11
|
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-
|
11
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -143,10 +143,11 @@ files:
|
|
143
143
|
- bin/setup
|
144
144
|
- lib/minitest/heat.rb
|
145
145
|
- lib/minitest/heat/backtrace.rb
|
146
|
+
- lib/minitest/heat/backtrace/line_parser.rb
|
146
147
|
- lib/minitest/heat/hit.rb
|
147
148
|
- lib/minitest/heat/issue.rb
|
148
|
-
- lib/minitest/heat/line.rb
|
149
149
|
- lib/minitest/heat/location.rb
|
150
|
+
- lib/minitest/heat/locations.rb
|
150
151
|
- lib/minitest/heat/map.rb
|
151
152
|
- lib/minitest/heat/output.rb
|
152
153
|
- lib/minitest/heat/output/backtrace.rb
|
@@ -188,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
189
|
- !ruby/object:Gem::Version
|
189
190
|
version: '0'
|
190
191
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
192
|
+
rubygems_version: 3.2.22
|
192
193
|
signing_key:
|
193
194
|
specification_version: 4
|
194
195
|
summary: Presents test results in a visual manner to guide you to where to look first.
|
data/lib/minitest/heat/line.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'forwardable'
|
4
|
-
|
5
|
-
module Minitest
|
6
|
-
module Heat
|
7
|
-
# Represents a line of code from the project and provides convenient access to information about
|
8
|
-
# the line for displaying in test results
|
9
|
-
class Line
|
10
|
-
attr_accessor :pathname, :number, :container
|
11
|
-
alias line_number number
|
12
|
-
|
13
|
-
def initialize(pathname:, number:, container: nil)
|
14
|
-
@pathname = Pathname(pathname)
|
15
|
-
@number = number.to_i
|
16
|
-
@container = container.to_s
|
17
|
-
end
|
18
|
-
|
19
|
-
# Convenient interface to read a line from a backtrace convert it to usable components
|
20
|
-
def self.parse_backtrace(raw_text)
|
21
|
-
raw_pathname, raw_line_number, raw_container = raw_text.split(':')
|
22
|
-
raw_container = raw_container.delete_prefix('in `').delete_suffix("'")
|
23
|
-
|
24
|
-
new(pathname: raw_pathname, number: raw_line_number, container: raw_container)
|
25
|
-
end
|
26
|
-
|
27
|
-
def to_s
|
28
|
-
"#{location} in `#{container}`"
|
29
|
-
end
|
30
|
-
|
31
|
-
def path
|
32
|
-
pathname.exist? ? pathname.dirname : UNRECOGNIZED
|
33
|
-
end
|
34
|
-
|
35
|
-
def file
|
36
|
-
pathname.exist? ? pathname.basename : UNRECOGNIZED
|
37
|
-
end
|
38
|
-
|
39
|
-
def mtime
|
40
|
-
pathname.exist? ? pathname.mtime : UNKNOWN_MODIFICATION_TIME
|
41
|
-
end
|
42
|
-
|
43
|
-
def age_in_seconds
|
44
|
-
pathname.exist? ? seconds_ago : UNKNOWN_MODIFICATION_SECONDS
|
45
|
-
end
|
46
|
-
|
47
|
-
def location
|
48
|
-
"#{pathname}:#{number}"
|
49
|
-
end
|
50
|
-
|
51
|
-
def short_location
|
52
|
-
"#{file}:#{number}"
|
53
|
-
end
|
54
|
-
|
55
|
-
def source_code(max_line_count: 1)
|
56
|
-
Minitest::Heat::Source.new(
|
57
|
-
pathname.to_s,
|
58
|
-
line_number: line_number,
|
59
|
-
max_line_count: max_line_count
|
60
|
-
)
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
UNRECOGNIZED = '(Unrecognized File)'
|
66
|
-
UNKNOWN_MODIFICATION_TIME = Time.at(0)
|
67
|
-
UNKNOWN_MODIFICATION_SECONDS = -1
|
68
|
-
|
69
|
-
def seconds_ago
|
70
|
-
(Time.now - mtime).to_i
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|