minitest-heat 1.1.0 → 1.2.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: cf4115aeb375e2fef72d98e7f706dc023ae1e61fa9d1fc3e8f490797a31e2ae0
4
- data.tar.gz: ba968646ff2b12fa2891b47fb58d2d98330d117c2a038e29f1caef449bfbd857
3
+ metadata.gz: e19adf67c01638e6cf3c53f5840c1d0a1fa82b3d41b3a8f1965d9ae24735e606
4
+ data.tar.gz: 3b8ced671f3aafaa3beaea45a0222ace34a8d37f3a0ea50b5085231d24e916cb
5
5
  SHA512:
6
- metadata.gz: 67a7e17e10fe0f75f5a5cad93bd97a7f4f87e136e6dfe6f338b0e8df0e80f83533d8e70b07e218fc0431e3e7c5bbdc2d14f71c8c3d32a98d846f276cb573f225
7
- data.tar.gz: 2a0cb94a433fe5b69bef58cd4fe24393adaad5bf69e76120b9296a3f8224b2e9a55da10e176bb0fa13e228e3aa57f0836d61fe0ca8116bd973681cc7e458912f
6
+ metadata.gz: 81c762ce455b684275d490f57839c4b1090ad7d0c723b4df479094a5aba5a722ffe74ef16e9b16ca549795c6cba95e863f7b2ff4b71476def525857c7c4dbffc
7
+ data.tar.gz: 889ebfb98b36a7d7c2877f89b89aabf39c610ae220badb85587c1a29bf99f5651a60107dec3c892364099974cbce7c8fc7eb2bccbbb9180ecae1578307f7e76c
@@ -10,7 +10,7 @@ jobs:
10
10
  strategy:
11
11
  matrix:
12
12
  os: [ubuntu-latest, macos-latest]
13
- ruby: [2.5.9, 2.6.9, 2.7.5, 3.0.3, 3.1.0-preview1]
13
+ ruby: [2.7.6, 3.0.4, 3.1.2, 3.2.0-preview2]
14
14
  runs-on: ubuntu-latest
15
15
  steps:
16
16
  - uses: actions/checkout@v2
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  Nothing at the moment.
4
4
 
5
+ ## [1.2.0] - 2022-10-31
6
+
7
+ Mainly some improvements to make test failures more resilient and improve the formatting when there are issues.
8
+
9
+ - Don't consider binstubs project files when colorizing the stacktrace.
10
+ - Switch debugging from Pry to debug
11
+ - Ensure overly-long exception messages are truncated to reduce excessive scrolling
12
+ - Make backtrace display smarter about how many lines to display
13
+ - Fix bug that was incorrectly deleting the bin directory
14
+ - Prepare for better handling of "stack level too deep" traces
15
+
5
16
  ## [1.1.0] - 2021-12-09
6
17
 
7
18
  The biggest update is that the slow thresholds are now configurable.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minitest-heat (1.1.0)
4
+ minitest-heat (1.2.0)
5
5
  minitest
6
6
 
7
7
  GEM
@@ -9,33 +9,38 @@ GEM
9
9
  specs:
10
10
  ast (2.4.2)
11
11
  awesome_print (1.9.2)
12
- coderay (1.1.3)
13
- dead_end (3.0.2)
12
+ dead_end (4.0.0)
13
+ debug (1.6.2)
14
+ irb (>= 1.3.6)
15
+ reline (>= 0.3.1)
14
16
  docile (1.4.0)
15
- method_source (1.0.0)
16
- minitest (5.14.4)
17
- parallel (1.21.0)
18
- parser (3.0.2.0)
17
+ io-console (0.5.11)
18
+ irb (1.4.1)
19
+ reline (>= 0.3.0)
20
+ json (2.6.2)
21
+ minitest (5.16.3)
22
+ parallel (1.22.1)
23
+ parser (3.1.2.1)
19
24
  ast (~> 2.4.1)
20
- pry (0.14.1)
21
- coderay (~> 1.1)
22
- method_source (~> 1.0)
23
- rainbow (3.0.0)
25
+ rainbow (3.1.1)
24
26
  rake (12.3.3)
25
- regexp_parser (2.1.1)
27
+ regexp_parser (2.5.0)
28
+ reline (0.3.1)
29
+ io-console (~> 0.5)
26
30
  rexml (3.2.5)
27
- rubocop (1.22.3)
31
+ rubocop (1.36.0)
32
+ json (~> 2.3)
28
33
  parallel (~> 1.10)
29
- parser (>= 3.0.0.0)
34
+ parser (>= 3.1.2.1)
30
35
  rainbow (>= 2.2.2, < 4.0)
31
36
  regexp_parser (>= 1.8, < 3.0)
32
- rexml
33
- rubocop-ast (>= 1.12.0, < 2.0)
37
+ rexml (>= 3.2.5, < 4.0)
38
+ rubocop-ast (>= 1.20.1, < 2.0)
34
39
  ruby-progressbar (~> 1.7)
35
40
  unicode-display_width (>= 1.4.0, < 3.0)
36
- rubocop-ast (1.13.0)
37
- parser (>= 3.0.1.1)
38
- rubocop-minitest (0.15.2)
41
+ rubocop-ast (1.21.0)
42
+ parser (>= 3.1.1.0)
43
+ rubocop-minitest (0.22.1)
39
44
  rubocop (>= 0.90, < 2.0)
40
45
  rubocop-rake (0.6.0)
41
46
  rubocop (~> 1.0)
@@ -45,18 +50,19 @@ GEM
45
50
  simplecov-html (~> 0.11)
46
51
  simplecov_json_formatter (~> 0.1)
47
52
  simplecov-html (0.12.3)
48
- simplecov_json_formatter (0.1.3)
49
- unicode-display_width (2.1.0)
53
+ simplecov_json_formatter (0.1.4)
54
+ unicode-display_width (2.3.0)
50
55
 
51
56
  PLATFORMS
52
- ruby
57
+ arm64-darwin-21
58
+ x86_64-linux
53
59
 
54
60
  DEPENDENCIES
55
61
  awesome_print
56
62
  dead_end
63
+ debug
57
64
  minitest (~> 5.0)
58
65
  minitest-heat!
59
- pry
60
66
  rake (~> 12.0)
61
67
  rubocop
62
68
  rubocop-minitest
@@ -64,4 +70,4 @@ DEPENDENCIES
64
70
  simplecov
65
71
 
66
72
  BUNDLED WITH
67
- 2.2.30
73
+ 2.3.22
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # 🔥 Minitest::Heat 🔥
2
- Minitest::Heat helps you identify problems faster so you can more efficiently resolve test failures. It does this through a few different methods.
1
+ # 🔥 Minitest Heat 🔥
2
+ Minitest Heat helps you identify problems faster so you can more efficiently resolve test failures by generating a heat map that shows where failures are concentrated.
3
3
 
4
- For a more detailed explanation of Minitest Heat with screenshots, [head over the wiki for the full story](https://github.com/garrettdimon/minitest-heat/wiki).
4
+ For a more detailed explanation of Minitest Heat with screenshots, [head over to the wiki for the full story](https://github.com/garrettdimon/minitest-heat/wiki).
5
5
 
6
6
  Or for some additional insight about priorities and how it works, this [Twitter thread](https://twitter.com/garrettdimon/status/1432703746526560266) is a good read.
7
7
 
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Minitest
4
+ module Heat
5
+ class Backtrace
6
+ # Determines an optimal line count for backtrace locations in order to have relevant
7
+ # information but keep the backtrace as compact as possible
8
+ class LineCount
9
+ DEFAULT_LINE_COUNT = 20
10
+
11
+ attr_accessor :locations
12
+
13
+ def initialize(locations)
14
+ @locations = locations
15
+ end
16
+
17
+ def earliest_project_location
18
+ locations.rindex { |element| element.project_file? }
19
+ end
20
+
21
+ def max_location
22
+ locations.size - 1
23
+ end
24
+
25
+ def limit
26
+ [
27
+ DEFAULT_LINE_COUNT,
28
+ earliest_project_location,
29
+ max_location
30
+ ].compact.min
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -11,7 +11,7 @@ module Minitest
11
11
  # Parses a line from a backtrace in order to convert it to usable components
12
12
  def self.read(raw_text)
13
13
  raw_pathname, raw_line_number, raw_container = raw_text.split(':')
14
- raw_container = raw_container.delete_prefix('in `').delete_suffix("'")
14
+ raw_container = raw_container&.delete_prefix('in `')&.delete_suffix("'")
15
15
 
16
16
  ::Minitest::Heat::Location.new(
17
17
  pathname: raw_pathname,
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'backtrace/line_count'
3
4
  require_relative 'backtrace/line_parser'
4
5
 
5
6
  module Minitest
@@ -6,12 +6,17 @@ module Minitest
6
6
  module Heat
7
7
  # For managing configuration options on how Minitest Heat should handle results
8
8
  class Configuration
9
+ DEFAULTS = {
10
+ slow_threshold: 1.0,
11
+ painfully_slow_threshold: 3.0
12
+ }.freeze
13
+
9
14
  attr_accessor :slow_threshold,
10
15
  :painfully_slow_threshold
11
16
 
12
17
  def initialize
13
- @slow_threshold = 1.0
14
- @painfully_slow_threshold = 3.0
18
+ @slow_threshold = DEFAULTS[:slow_threshold]
19
+ @painfully_slow_threshold = DEFAULTS[:painfully_slow_threshold]
15
20
  end
16
21
  end
17
22
  end
@@ -10,12 +10,12 @@ module Minitest
10
10
 
11
11
  TYPES = %i[error broken failure skipped painful slow].freeze
12
12
 
13
- # Long-term, these could be configurable so that people can determine their own thresholds of
14
- # pain for slow tests
15
- SLOW_THRESHOLDS = {
16
- slow: 1.0,
17
- painful: 3.0
18
- }.freeze
13
+ # # Long-term, these could be configurable so that people can determine their own thresholds of
14
+ # # pain for slow tests
15
+ # SLOW_THRESHOLDS = {
16
+ # slow: 1.0,
17
+ # painful: 3.0
18
+ # }.freeze
19
19
 
20
20
  attr_reader :assertions,
21
21
  :locations,
@@ -120,14 +120,14 @@ module Minitest
120
120
  #
121
121
  # @return [Float] number of seconds after which a test is considered slow
122
122
  def slow_threshold
123
- Minitest::Heat.configuration.slow_threshold || SLOW_THRESHOLDS[:slow]
123
+ Minitest::Heat.configuration.slow_threshold
124
124
  end
125
125
 
126
126
  # The number, in seconds, for a test to be considered "painfully slow"
127
127
  #
128
128
  # @return [Float] number of seconds after which a test is considered painfully slow
129
129
  def painfully_slow_threshold
130
- Minitest::Heat.configuration.painfully_slow_threshold || SLOW_THRESHOLDS[:painful]
130
+ Minitest::Heat.configuration.painfully_slow_threshold
131
131
  end
132
132
 
133
133
  # Determines if a test should be considered slow by comparing it to the low end definition of
@@ -200,7 +200,13 @@ module Minitest
200
200
  #
201
201
  # @return [String] the first line of the exception message
202
202
  def first_line_of_exception_message
203
- message.split("\n")[0]
203
+ text = message.split("\n")[0]
204
+
205
+ text.size > exception_message_limit ? "#{text[0..exception_message_limit]}..." : text
206
+ end
207
+
208
+ def exception_message_limit
209
+ 200
204
210
  end
205
211
  end
206
212
  end
@@ -133,7 +133,7 @@ module Minitest
133
133
  #
134
134
  # @return [Boolean] true if the file is in the project (source code or test) but not vendored
135
135
  def project_file?
136
- path.include?(project_root_dir) && !bundled_file?
136
+ path.include?(project_root_dir) && !bundled_file? && !binstub_file?
137
137
  end
138
138
 
139
139
  # Determines if the file is in the project `vendor/bundle` directory.
@@ -143,6 +143,15 @@ module Minitest
143
143
  path.include?("#{project_root_dir}/vendor/bundle")
144
144
  end
145
145
 
146
+ # Determines if the file is in the project `bin` directory. With binstub'd gems, they'll
147
+ # appear to be source code because the code is located in the project directory. This helps
148
+ # make sure the backtraces don't think that's the case
149
+ #
150
+ # @return [Boolean] true if the file is in `<project_root>/bin
151
+ def binstub_file?
152
+ path.include?("#{project_root_dir}/bin")
153
+ end
154
+
146
155
  # Determines if a given file follows the standard approaching to naming test files.
147
156
  #
148
157
  # @return [Boolean] true if the file name starts with `test_` or ends with `_test.rb`
@@ -154,7 +163,7 @@ module Minitest
154
163
  #
155
164
  # @return [Boolean] true if the file is in the project but not a test file or vendored file
156
165
  def source_code_file?
157
- project_file? && !test_file? && !bundled_file?
166
+ project_file? && !test_file?
158
167
  end
159
168
 
160
169
  # A safe interface to getting the last modified time for the file in question
@@ -5,7 +5,6 @@ module Minitest
5
5
  class Output
6
6
  # Builds the collection of tokens for displaying a backtrace when an exception occurs
7
7
  class Backtrace
8
- DEFAULT_LINE_COUNT = 10
9
8
  DEFAULT_INDENTATION_SPACES = 2
10
9
 
11
10
  attr_accessor :locations, :backtrace
@@ -25,14 +24,14 @@ module Minitest
25
24
  #
26
25
  # @return [Integer] the number of lines to limit the backtrace to
27
26
  def line_count
28
- # Defined as a method instead of using the constant directlyr in order to easily support
27
+ # Defined as a method instead of using the constant directly in order to easily support
29
28
  # adding options for controlling how many lines are displayed from a backtrace.
30
29
  #
31
30
  # For example, instead of a fixed number, the backtrace could dynamically calculate how
32
31
  # many lines it should displaye in order to get to the origination point. Or it could have
33
32
  # a default, but inteligently go back further if the backtrace meets some criteria for
34
33
  # displaying more lines.
35
- DEFAULT_LINE_COUNT
34
+ ::Minitest::Heat::Backtrace::LineCount.new(backtrace.locations).limit
36
35
  end
37
36
 
38
37
  # A subset of parsed lines from the backtrace.
@@ -49,7 +48,7 @@ module Minitest
49
48
  # it could display the entire backtrace without filtering anything.
50
49
  # - It could scan the backtrace to the first appearance of project files and then display
51
50
  # all of the lines that occurred after that instance
52
- # - It coudl filter the lines differently whether the issue originated from a test or from
51
+ # - It could filter the lines differently whether the issue originated from a test or from
53
52
  # the source code.
54
53
  # - It could allow supporting a "compact" or "robust" reporter style so that someone on
55
54
  # a smaller screen could easily reduce the information shown so that the results could
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minitest
4
4
  module Heat
5
- VERSION = '1.1.0'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Presents test results in a visual manner to guide you to where to look first.'
13
13
  spec.homepage = 'https://github.com/garrettdimon/minitest-heat'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5.9')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.6')
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['bug_tracker_uri'] = 'https://github.com/garrettdimon/minitest-heat/issues'
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  spec.add_development_dependency 'awesome_print'
36
36
  spec.add_development_dependency 'dead_end'
37
- spec.add_development_dependency 'pry'
37
+ spec.add_development_dependency 'debug'
38
38
  spec.add_development_dependency 'rubocop'
39
39
  spec.add_development_dependency 'rubocop-minitest'
40
40
  spec.add_development_dependency 'rubocop-rake'
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: 1.1.0
4
+ version: 1.2.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-12-09 00:00:00.000000000 Z
11
+ date: 2022-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: pry
56
+ name: debug
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -146,6 +146,7 @@ files:
146
146
  - bin/setup
147
147
  - lib/minitest/heat.rb
148
148
  - lib/minitest/heat/backtrace.rb
149
+ - lib/minitest/heat/backtrace/line_count.rb
149
150
  - lib/minitest/heat/backtrace/line_parser.rb
150
151
  - lib/minitest/heat/configuration.rb
151
152
  - lib/minitest/heat/hit.rb
@@ -186,14 +187,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
187
  requirements:
187
188
  - - ">="
188
189
  - !ruby/object:Gem::Version
189
- version: 2.5.9
190
+ version: 2.7.6
190
191
  required_rubygems_version: !ruby/object:Gem::Requirement
191
192
  requirements:
192
193
  - - ">="
193
194
  - !ruby/object:Gem::Version
194
195
  version: '0'
195
196
  requirements: []
196
- rubygems_version: 3.2.22
197
+ rubygems_version: 3.3.22
197
198
  signing_key:
198
199
  specification_version: 4
199
200
  summary: Presents test results in a visual manner to guide you to where to look first.