minitest-heat 0.0.14 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4009f20d5e5d4d92d8e0796e853df4da059e3ec7a6b49cae98a8ce71352316fd
4
- data.tar.gz: adf5692ab8af5f08ec97607f43ac8f454ad91fb62d15d9f867ee354d920a7a45
3
+ metadata.gz: 887dc01f3a08341f1e88cb24b539d0843cdce81fdb49246fbce8af875ff00d3f
4
+ data.tar.gz: 875d197ab5c65c2cb85b192201375be653ba30da2fc91896b4a3e61702cacefd
5
5
  SHA512:
6
- metadata.gz: 8e0d422fbc88d79598464f1640ffb7b6ea3e8ab7324e85f9a059a61f1d14e6c8792f277525dadf6cf81ee493168708dd0eb1a3f9b836b7efd0af3e73b959f25b
7
- data.tar.gz: dfa2aa6267e1c026da29b93e1e7ab73f4a1fc65d9d1132228efff315622b742ebe40074eec7a639e6246b7bad27f14a31feee647c9c1274b77d8a57b8d8ed22b
6
+ metadata.gz: 6ef73c9df5b91b5950cc444f6ea7a18ccd867bda4fbdb015b8d713eaebe91b925a2cfb48b596a43a0d36af023dcb04f5c8ec0803602ab27bf709372fe6f9b0f3
7
+ data.tar.gz: d338944e9d32e8ec326cce9dbe861c5b8bec408bb455e4e984d45567ef9d9c5af9154f4475c2862ddc43778c95d8e58f12beef8757aa37f6b76d91da1b17a4c5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minitest-heat (0.0.14)
4
+ minitest-heat (1.0.0)
5
5
  minitest
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Minitest::Heat
1
+ # 🔥 Minitest::Heat 🔥
2
2
  Minitest::Heat helps you identify problems faster so you can more efficiently resolve test failures. It does this through a few different methods.
3
3
 
4
4
  It collects failures and inspects backtraces to identify patterns and provide a heat map summary of the files and line numbers that most frequently appear to be the causes of issues.
@@ -38,7 +38,7 @@ module Minitest
38
38
  break unless traces.any?
39
39
 
40
40
  # A short summary explaining the details that will follow
41
- @tokens << [[:muted, " Issues on Line #{line_number} initially triggered from these locations:"]]
41
+ @tokens << [[:default, " Line #{line_number}"], [:muted, ' issues triggered from:']]
42
42
 
43
43
  # The last relevant location for each error's backtrace
44
44
  @tokens += origination_sources(traces)
@@ -51,23 +51,27 @@ module Minitest
51
51
  private
52
52
 
53
53
  def origination_sources(traces)
54
- # 1. Sort the traces by the most recent line number so they're displayed in numeric order
55
- # 2. Get the final relevant location from the trace
54
+ # 1. Only pull the traces that have proper locations
55
+ # 2. Sort the traces by the most recent line number so they're displayed in numeric order
56
+ # 3. Get the final relevant location from the trace
56
57
  traces.
58
+ select { |trace| trace.locations.any? }.
57
59
  sort_by { |trace| trace.locations.last.line_number }.
58
60
  map { |trace| origination_location_token(trace) }
59
61
  end
60
62
 
61
63
  def file_summary_tokens(hit)
62
64
  pathname_tokens = pathname(hit)
63
- line_number_list_tokens = sorted_line_number_list(hit)
65
+ line_number_list_tokens = line_number_tokens_for_hit(hit)
64
66
 
65
67
  [*pathname_tokens, *line_number_list_tokens]
66
68
  end
67
69
 
68
70
  def origination_location_token(trace)
69
71
  # The earliest project line from the backtrace—this is probabyl wholly incorrect in terms
70
- # of what would be the most helpful line to display, but it's a start.
72
+ # of what would be the most helpful line to display, but it's a start. Otherwise, the
73
+ # logic will need to compare all traces for the issue and find the unique origination
74
+ # lines
71
75
  location = trace.locations.last
72
76
 
73
77
  [
@@ -137,8 +141,10 @@ module Minitest
137
141
  line_numbers_for_issue_type = hit.issues.fetch(issue_type) { [] }
138
142
 
139
143
  # Build the list of tokens representing styled line numbers
140
- line_numbers_for_issue_type.each do |line_number|
141
- line_number_tokens << line_number_token(issue_type, line_number)
144
+ line_numbers_for_issue_type.uniq.sort.each do |line_number|
145
+ frequency = line_numbers_for_issue_type.count(line_number)
146
+
147
+ line_number_tokens += line_number_token(issue_type, line_number, frequency)
142
148
  end
143
149
  end
144
150
 
@@ -151,27 +157,34 @@ module Minitest
151
157
  # @param line_number [Integer] the affected line number
152
158
  #
153
159
  # @return [Array<Symbol,Integer>] array token representing the line number and issue type
154
- def line_number_token(style, line_number)
155
- [style, "#{line_number} "]
156
- end
157
-
158
- # Sorts line number tokens so that line numbers are displayed in order regardless of their
159
- # underlying issue type
160
- #
161
- # @param hit [Hit] the instance of the hit file details to build the heat map entry
162
- #
163
- # @return [Array] the arrays representing the line number tokens to display next to a file
164
- # name in the heat map. ex [[:error, 12], [:falure, 13]]
165
- def sorted_line_number_list(hit)
166
- # Sort the collected group of line number hits so they're in order
167
- line_number_tokens_for_hit(hit).sort do |a, b|
168
- # Ensure the line numbers are integers for sorting (otherwise '100' comes before '12')
169
- first_line_number = Integer(a[1].strip)
170
- second_line_number = Integer(b[1].strip)
171
-
172
- first_line_number <=> second_line_number
160
+ def line_number_token(style, line_number, frequency)
161
+ if frequency > 1
162
+ [
163
+ [style, "#{line_number}"],
164
+ [:muted, "✕#{frequency} "]
165
+ ]
166
+ else
167
+ [[style, "#{line_number} "]]
173
168
  end
174
169
  end
170
+
171
+ # # Sorts line number tokens so that line numbers are displayed in order regardless of their
172
+ # # underlying issue type
173
+ # #
174
+ # # @param hit [Hit] the instance of the hit file details to build the heat map entry
175
+ # #
176
+ # # @return [Array] the arrays representing the line number tokens to display next to a file
177
+ # # name in the heat map. ex [[:error, 12], [:falure, 13]]
178
+ # def sorted_line_number_list(hit)
179
+ # # Sort the collected group of line number hits so they're in order
180
+ # line_number_tokens_for_hit(hit).sort do |a, b|
181
+ # # Ensure the line numbers are integers for sorting (otherwise '100' comes before '12')
182
+ # first_line_number = Integer(a[1].strip)
183
+ # second_line_number = Integer(b[1].strip)
184
+
185
+ # first_line_number <=> second_line_number
186
+ # end
187
+ # end
175
188
  end
176
189
  end
177
190
  end
@@ -57,7 +57,11 @@ module Minitest
57
57
  # suppress them until the more critical issues are resolved.
58
58
  next unless show?(issue_category, results)
59
59
 
60
- results.send(issue_category).each { |issue| issue_details(issue) }
60
+ issues = results.send(issue_category)
61
+
62
+ issues
63
+ .sort_by { |issue| issue.locations.most_relevant.to_a }
64
+ .each { |issue| issue_details(issue) }
61
65
  end
62
66
  rescue StandardError => e
63
67
  message = "Sorry, but Minitest Heat couldn't display the details of any failures."
@@ -30,8 +30,20 @@ module Minitest
30
30
  # For heat map purposes, only the project backtrace lines are interesting
31
31
  pathname, line_number = issue.locations.project.to_a
32
32
 
33
- # Backtrace is only relevant for exception-generating issues, not slows, skips, or failures
34
- backtrace = issue.error? ? issue.locations.backtrace.project_locations : []
33
+ # A backtrace is only relevant for exception-generating issues (i.e. errors), not slows or skips
34
+ # However, while assertion failures won't have a backtrace, there can still be repeated line
35
+ # numbers if the tests reference a shared method with an assertion in it. So in those cases,
36
+ # the backtrace is simply the test definition
37
+ backtrace = if issue.error?
38
+ # With errors, we have a backtrace
39
+ issue.locations.backtrace.project_locations
40
+ else
41
+ # With failures, the test definition is the most granular backtrace equivalent
42
+ location = issue.locations.test_definition
43
+ location.raw_container = issue.test_identifier
44
+
45
+ [location]
46
+ end
35
47
 
36
48
  @heat_map.add(pathname, line_number, issue.type, backtrace: backtrace)
37
49
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minitest
4
4
  module Heat
5
- VERSION = '0.0.14'
5
+ VERSION = '1.0.0'
6
6
  end
7
7
  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.14
4
+ version: 1.0.0
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-29 00:00:00.000000000 Z
11
+ date: 2021-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest