minitest-heat 1.0.0 → 1.1.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: 887dc01f3a08341f1e88cb24b539d0843cdce81fdb49246fbce8af875ff00d3f
4
- data.tar.gz: 875d197ab5c65c2cb85b192201375be653ba30da2fc91896b4a3e61702cacefd
3
+ metadata.gz: cf4115aeb375e2fef72d98e7f706dc023ae1e61fa9d1fc3e8f490797a31e2ae0
4
+ data.tar.gz: ba968646ff2b12fa2891b47fb58d2d98330d117c2a038e29f1caef449bfbd857
5
5
  SHA512:
6
- metadata.gz: 6ef73c9df5b91b5950cc444f6ea7a18ccd867bda4fbdb015b8d713eaebe91b925a2cfb48b596a43a0d36af023dcb04f5c8ec0803602ab27bf709372fe6f9b0f3
7
- data.tar.gz: d338944e9d32e8ec326cce9dbe861c5b8bec408bb455e4e984d45567ef9d9c5af9154f4475c2862ddc43778c95d8e58f12beef8757aa37f6b76d91da1b17a4c5
6
+ metadata.gz: 67a7e17e10fe0f75f5a5cad93bd97a7f4f87e136e6dfe6f338b0e8df0e80f83533d8e70b07e218fc0431e3e7c5bbdc2d14f71c8c3d32a98d846f276cb573f225
7
+ data.tar.gz: 2a0cb94a433fe5b69bef58cd4fe24393adaad5bf69e76120b9296a3f8224b2e9a55da10e176bb0fa13e228e3aa57f0836d61fe0ca8116bd973681cc7e458912f
@@ -0,0 +1,3 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: garrettdimon
@@ -0,0 +1,23 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ env:
6
+ CI: true
7
+
8
+ jobs:
9
+ build:
10
+ strategy:
11
+ matrix:
12
+ os: [ubuntu-latest, macos-latest]
13
+ ruby: [2.5.9, 2.6.9, 2.7.5, 3.0.3, 3.1.0-preview1]
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+ bundler-cache: true
22
+ - name: Run Tests
23
+ run: bundle exec rake
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ ## [Unreleased]
2
+
3
+ Nothing at the moment.
4
+
5
+ ## [1.1.0] - 2021-12-09
6
+
7
+ The biggest update is that the slow thresholds are now configurable.
8
+
9
+ - Configurable Thresholds
10
+ - Fixed a bug where `vendor/bundle` gem files were considered project source code files
11
+ - Set up [GitHub Actions](https://github.com/garrettdimon/minitest-heat/actions) to ensure tests are run on Ubuntu latest and macOs for the [latest Ruby versions](https://github.com/garrettdimon/minitest-heat/blob/main/.github/workflows/main.yml)
12
+ - Fixed some tests that were accidentally left path-dependent and couldn't pass on other machines
13
+
14
+ ## [1.0.0] - 2021-12-01
15
+
16
+ Initial release.
17
+
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minitest-heat (1.0.0)
4
+ minitest-heat (1.1.0)
5
5
  minitest
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,39 +1,9 @@
1
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
- 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.
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).
5
5
 
6
- ![Example Heat Map Displayed by Minitest Heat](https://raw.githubusercontent.com/garrettdimon/minitest-heat/main/examples/map.png)
7
-
8
- It suppresses less critical issues like skips or slows when there are legitimate failures. It won't display information about slow tests unless all tests are passing (meaning no errors, failures, or skips)
9
-
10
- It presents failures differently depending on the context of failure. For instance, it treats exceptions differently based on whether they arose directly from a test or from source code. It also treats extremely slow tests differently from moderately slow tests.
11
-
12
- Markers get some nuance so that slow tests receive different markers than standard passing tests, and exception-triggered failures get different markers for source-code triggered exceptions (E) and test-triggered exceptions ('B' for 'Broken Test').
13
-
14
- ![Example Markers Displayed by Minitest Heat](https://raw.githubusercontent.com/garrettdimon/minitest-heat/main/examples/markers.png)
15
-
16
- It also formats the failure details and backtraces to make them more scannable by emphasizing the project-relates lines from the backtrace.
17
-
18
- It intelligently recognizes when an exception was raised from a test defintion vs. when an exception is genuinely triggered from the source code in order to help focus on fixing deeper exceptions first.
19
-
20
- ![Example Exceptions Displayed by Minitest Heat](https://raw.githubusercontent.com/garrettdimon/minitest-heat/main/examples/exceptions.png)
21
-
22
- Failures are displayed ina fairly predictable manner but formatted to show the source code from the test so you can see the assertion that failed in addition to the summary of values that didn't satisfy the assertion.
23
-
24
- ![Example Failures Displayed by Minitest Heat](https://raw.githubusercontent.com/garrettdimon/minitest-heat/main/examples/failures.png)
25
-
26
- Skipped tests are displayed in a simple manner as well so that it's easy to see the source of the skipped test as well as the reason it was skipped.
27
-
28
- ![Example Skips Displayed by Minitest Heat](https://raw.githubusercontent.com/garrettdimon/minitest-heat/main/examples/skips.png)
29
-
30
- Slow tests get slightly more informative labels to indicate that they did pass, but they could use performance improvements. Tests that are particularly slow are called out with a little more emphasis so it's easier to focus on really slow tests first as they frequently represent the most potential for performance gains.
31
-
32
- ![Example Slows Displayed by Minitest Heat](https://raw.githubusercontent.com/garrettdimon/minitest-heat/main/examples/slows.png)
33
-
34
- It also always displays the most significant issues at the bottom of the list in order to reduce the need to scroll up through the test failures. As you fix issues, the list becomes shorter, and the less significant issues will make there way to the bottom and be visible without scrolling.
35
-
36
- For some additional insight about priorities and how it works, this [Twitter thread](https://twitter.com/garrettdimon/status/1432703746526560266) is currently the best place to start.
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.
37
7
 
38
8
  ## Installation
39
9
  Add this line to your application's Gemfile:
@@ -57,7 +27,18 @@ require 'minitest/heat'
57
27
  ```
58
28
 
59
29
  ## Configuration
60
- Minitest Heat doesn't currently offer a significant set of configuration options, but it will eventually support customizing the thresholds for "Slow" and "Painfully Slow". By default, it considers anything over 1.0s to be 'slow' and anything over 3.0s to be 'painfully slow'.
30
+ Minitest Heat doesn't currently offer a significant set of configuration options, but the thresholds for "Slow" and "Painfully Slow" tests can be adjusted. By default, it considers anything over 1.0s to be 'slow' and anything over 3.0s to be 'painfully slow'.
31
+
32
+ You can add a configuration block to your `test_helper.rb` file after the `require 'minitest/heat'` line.
33
+
34
+ For example:
35
+
36
+ ```ruby
37
+ Minitest::Heat.configure do |config|
38
+ config.slow_threshold = 0.01
39
+ config.painfully_slow_threshold = 0.5
40
+ end
41
+ ```
61
42
 
62
43
  ## Development
63
44
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ module Minitest
6
+ module Heat
7
+ # For managing configuration options on how Minitest Heat should handle results
8
+ class Configuration
9
+ attr_accessor :slow_threshold,
10
+ :painfully_slow_threshold
11
+
12
+ def initialize
13
+ @slow_threshold = 1.0
14
+ @painfully_slow_threshold = 3.0
15
+ end
16
+ end
17
+ end
18
+ end
@@ -120,18 +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
- # Using a method here so that this can eventually be configurable such that the constant is
124
- # only a fallback value if it's not specified anywhere else
125
- SLOW_THRESHOLDS[:slow]
123
+ Minitest::Heat.configuration.slow_threshold || SLOW_THRESHOLDS[:slow]
126
124
  end
127
125
 
128
126
  # The number, in seconds, for a test to be considered "painfully slow"
129
127
  #
130
128
  # @return [Float] number of seconds after which a test is considered painfully slow
131
129
  def painfully_slow_threshold
132
- # Using a method here so that this can eventually be configurable such that the constant is
133
- # only a fallback value if it's not specified anywhere else
134
- SLOW_THRESHOLDS[:painful]
130
+ Minitest::Heat.configuration.painfully_slow_threshold || SLOW_THRESHOLDS[:painful]
135
131
  end
136
132
 
137
133
  # Determines if a test should be considered slow by comparing it to the low end definition of
@@ -131,9 +131,16 @@ module Minitest
131
131
 
132
132
  # Determines if a given file is from the project directory
133
133
  #
134
- # @return [Boolean] true if the file is in the project (source code or test)
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)
136
+ path.include?(project_root_dir) && !bundled_file?
137
+ end
138
+
139
+ # Determines if the file is in the project `vendor/bundle` directory.
140
+ #
141
+ # @return [Boolean] true if the file is in `<project_root>/vendor/bundle
142
+ def bundled_file?
143
+ path.include?("#{project_root_dir}/vendor/bundle")
137
144
  end
138
145
 
139
146
  # Determines if a given file follows the standard approaching to naming test files.
@@ -145,9 +152,9 @@ module Minitest
145
152
 
146
153
  # Determines if a given file is a non-test file from the project directory
147
154
  #
148
- # @return [Boolean] true if the file is in the project but not a test file
155
+ # @return [Boolean] true if the file is in the project but not a test file or vendored file
149
156
  def source_code_file?
150
- project_file? && !test_file?
157
+ project_file? && !test_file? && !bundled_file?
151
158
  end
152
159
 
153
160
  # A safe interface to getting the last modified time for the file in question
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minitest
4
4
  module Heat
5
- VERSION = '1.0.0'
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  end
data/lib/minitest/heat.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'heat/configuration'
3
4
  require_relative 'heat/backtrace'
4
5
  require_relative 'heat/hit'
5
6
  require_relative 'heat/issue'
@@ -32,5 +33,20 @@ module Minitest
32
33
  # Pulls from minitest-color as well:
33
34
  # https://github.com/teoljungberg/minitest-color/blob/master/lib/minitest/color_plugin.rb
34
35
  module Heat
36
+ class << self
37
+ attr_writer :configuration
38
+ end
39
+
40
+ def self.configuration
41
+ @configuration ||= Configuration.new
42
+ end
43
+
44
+ def self.reset
45
+ @configuration = Configuration.new
46
+ end
47
+
48
+ def self.configure
49
+ yield(configuration)
50
+ end
35
51
  end
36
52
  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: 1.0.0
4
+ version: 1.1.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-01 00:00:00.000000000 Z
11
+ date: 2021-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -130,9 +130,12 @@ executables: []
130
130
  extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
+ - ".github/FUNDING.yml"
134
+ - ".github/workflows/main.yml"
133
135
  - ".gitignore"
134
136
  - ".rubocop.yml"
135
137
  - ".travis.yml"
138
+ - CHANGELOG.md
136
139
  - CODE_OF_CONDUCT.md
137
140
  - Gemfile
138
141
  - Gemfile.lock
@@ -141,15 +144,10 @@ files:
141
144
  - Rakefile
142
145
  - bin/console
143
146
  - bin/setup
144
- - examples/exceptions.png
145
- - examples/failures.png
146
- - examples/map.png
147
- - examples/markers.png
148
- - examples/skips.png
149
- - examples/slows.png
150
147
  - lib/minitest/heat.rb
151
148
  - lib/minitest/heat/backtrace.rb
152
149
  - lib/minitest/heat/backtrace/line_parser.rb
150
+ - lib/minitest/heat/configuration.rb
153
151
  - lib/minitest/heat/hit.rb
154
152
  - lib/minitest/heat/issue.rb
155
153
  - lib/minitest/heat/location.rb
Binary file
Binary file
data/examples/map.png DELETED
Binary file
data/examples/markers.png DELETED
Binary file
data/examples/skips.png DELETED
Binary file
data/examples/slows.png DELETED
Binary file