minitest-heat 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +36 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/minitest/heat/backtrace.rb +93 -0
- data/lib/minitest/heat/issue.rb +139 -0
- data/lib/minitest/heat/location.rb +64 -0
- data/lib/minitest/heat/map.rb +57 -0
- data/lib/minitest/heat/output.rb +271 -0
- data/lib/minitest/heat/results.rb +112 -0
- data/lib/minitest/heat/source.rb +149 -0
- data/lib/minitest/heat/version.rb +5 -0
- data/lib/minitest/heat.rb +32 -0
- data/lib/minitest/heat_plugin.rb +26 -0
- data/lib/minitest/heat_reporter.rb +99 -0
- data/minitest-heat.gemspec +39 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 949b2b45d4b42493bc74bc98571eefbbde523ef18a70077cc32bf944e30cc172
|
4
|
+
data.tar.gz: e716f191d2053ed286ed8e342e0578fe9bc97ad818d4ca89dbf199003d6b64d0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f662e4944204010df9e2f29ab49959b978f7b0c54e5beb9ece51e80bf8830d7c6cf988f5834dbfc3b44037f6303ac5a82817132810a508ff1fa7064e19800a74
|
7
|
+
data.tar.gz: 292ecef2bd8473f74937356d8c68171801d4eb50e67849d76160fb24c9ee61838183c3c385240425ad1587c4cedf7375e292f806d593706915175cd489702520
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at email@garrettdimon.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
minitest-heat (0.0.1)
|
5
|
+
minitest
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.3)
|
11
|
+
docile (1.4.0)
|
12
|
+
method_source (1.0.0)
|
13
|
+
minitest (5.14.4)
|
14
|
+
pry (0.14.1)
|
15
|
+
coderay (~> 1.1)
|
16
|
+
method_source (~> 1.0)
|
17
|
+
rake (12.3.3)
|
18
|
+
simplecov (0.21.2)
|
19
|
+
docile (~> 1.1)
|
20
|
+
simplecov-html (~> 0.11)
|
21
|
+
simplecov_json_formatter (~> 0.1)
|
22
|
+
simplecov-html (0.12.3)
|
23
|
+
simplecov_json_formatter (0.1.3)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
minitest (~> 5.0)
|
30
|
+
minitest-heat!
|
31
|
+
pry
|
32
|
+
rake (~> 12.0)
|
33
|
+
simplecov
|
34
|
+
|
35
|
+
BUNDLED WITH
|
36
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Garrett Dimon
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Minitest::Heat
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/minitest/heat`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'minitest-heat'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install minitest-heat
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/minitest-heat. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/minitest-heat/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the Minitest::Heat project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/minitest-heat/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "minitest/heat"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Minitest
|
4
|
+
module Heat
|
5
|
+
# Wrapper for separating backtrace into component parts
|
6
|
+
class Backtrace
|
7
|
+
Line = Struct.new(:path, :file, :number, :container, :mtime, keyword_init: true) do
|
8
|
+
def to_s
|
9
|
+
"#{path}/#{file}:#{line} in `#{container}` #{age_in_seconds}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_file
|
13
|
+
"#{path}/#{file}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def age_in_seconds
|
17
|
+
(Time.now - mtime).to_i
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :raw_backtrace
|
22
|
+
|
23
|
+
def initialize(raw_backtrace)
|
24
|
+
@raw_backtrace = raw_backtrace
|
25
|
+
end
|
26
|
+
|
27
|
+
def empty?
|
28
|
+
raw_backtrace.nil? || raw_backtrace.empty?
|
29
|
+
end
|
30
|
+
|
31
|
+
def final_location
|
32
|
+
parsed.first
|
33
|
+
end
|
34
|
+
|
35
|
+
def final_project_location
|
36
|
+
project.first
|
37
|
+
end
|
38
|
+
|
39
|
+
def final_test_location
|
40
|
+
tests.first
|
41
|
+
end
|
42
|
+
|
43
|
+
def freshest_project_location
|
44
|
+
recently_modified.first
|
45
|
+
end
|
46
|
+
|
47
|
+
def project
|
48
|
+
@project ||= parsed.select { |line| line[:path].include?(Dir.pwd) }
|
49
|
+
end
|
50
|
+
|
51
|
+
def tests
|
52
|
+
@tests ||= project.select { |line| test_file?(line) }
|
53
|
+
end
|
54
|
+
|
55
|
+
def recently_modified
|
56
|
+
@recently_modified ||= project.sort_by { |line| line[:mtime] }.reverse
|
57
|
+
end
|
58
|
+
|
59
|
+
def parsed
|
60
|
+
return [] if raw_backtrace.nil?
|
61
|
+
|
62
|
+
@parsed ||= raw_backtrace.map { |line| parse(line) }
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def reduce_container(container)
|
68
|
+
container.delete_prefix('in `').delete_suffix("'")
|
69
|
+
end
|
70
|
+
|
71
|
+
def parse(line)
|
72
|
+
Line.new(line_attributes(line))
|
73
|
+
end
|
74
|
+
|
75
|
+
def line_attributes(line)
|
76
|
+
parts = line.split(':')
|
77
|
+
pathname = Pathname.new(parts[0])
|
78
|
+
|
79
|
+
{
|
80
|
+
path: pathname.dirname.to_s,
|
81
|
+
file: pathname.basename.to_s,
|
82
|
+
number: parts[1],
|
83
|
+
container: reduce_container(parts[2]),
|
84
|
+
mtime: pathname.exist? ? pathname.mtime : nil
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_file?(line)
|
89
|
+
line[:file].end_with?('_test.rb') || line[:file].start_with?('test_')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
module Minitest
|
6
|
+
module Heat
|
7
|
+
# Wrapper for Result to provide a more natural-language approach to result details
|
8
|
+
class Issue
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
SLOW_THRESHOLD = 0.5
|
12
|
+
|
13
|
+
SHARED_SYMBOLS = {
|
14
|
+
spacer: ' · ',
|
15
|
+
arrow: ' > '
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
attr_reader :result, :location, :failure
|
19
|
+
|
20
|
+
def_delegators :@result, :passed?, :error?, :skipped?
|
21
|
+
def_delegators :@location, :backtrace
|
22
|
+
|
23
|
+
def initialize(result)
|
24
|
+
@result = result
|
25
|
+
|
26
|
+
@failure = result.failures.any? ? result.failures.first : nil
|
27
|
+
@location = Location.new(result.source_location, @failure&.backtrace)
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_hit
|
31
|
+
[
|
32
|
+
location.source_file,
|
33
|
+
location.source_failure_line,
|
34
|
+
type
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
38
|
+
def spacer
|
39
|
+
SHARED_SYMBOLS[:spacer]
|
40
|
+
end
|
41
|
+
|
42
|
+
def arrow
|
43
|
+
SHARED_SYMBOLS[:arrow]
|
44
|
+
end
|
45
|
+
|
46
|
+
def type # rubocop:disable Metrics/MethodLength
|
47
|
+
if error? && in_test?
|
48
|
+
:broken
|
49
|
+
elsif error?
|
50
|
+
:error
|
51
|
+
elsif skipped?
|
52
|
+
:skipped
|
53
|
+
elsif !passed?
|
54
|
+
:failure
|
55
|
+
elsif slow?
|
56
|
+
:slow
|
57
|
+
else
|
58
|
+
:success
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def slow?
|
63
|
+
time > SLOW_THRESHOLD
|
64
|
+
end
|
65
|
+
|
66
|
+
def in_test?
|
67
|
+
location.failure_in_test?
|
68
|
+
end
|
69
|
+
|
70
|
+
def in_source?
|
71
|
+
location.failure_in_source?
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_class
|
75
|
+
result.klass.delete_prefix('Minitest::')
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_identifier
|
79
|
+
result.name
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_name
|
83
|
+
test_identifier.delete_prefix('test_').gsub('_', ' ').capitalize
|
84
|
+
end
|
85
|
+
|
86
|
+
def exception
|
87
|
+
failure.exception
|
88
|
+
end
|
89
|
+
|
90
|
+
def time
|
91
|
+
result.time
|
92
|
+
end
|
93
|
+
|
94
|
+
def slowness
|
95
|
+
"#{time.round(2)}s"
|
96
|
+
end
|
97
|
+
|
98
|
+
def label
|
99
|
+
if error? && in_test?
|
100
|
+
# When the exception came out of the test itself, that's a different kind of exception
|
101
|
+
# that really only indicates there's a problem with the code in the test. It's kind of
|
102
|
+
# between an error and a test.
|
103
|
+
'Broken Test'
|
104
|
+
elsif error? || !passed?
|
105
|
+
failure.result_label
|
106
|
+
elsif slow?
|
107
|
+
'Passed but Slow'
|
108
|
+
else
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def marker
|
114
|
+
case type
|
115
|
+
when :broken then 'B'
|
116
|
+
when :error then 'E'
|
117
|
+
when :skipped then 'S'
|
118
|
+
when :failure then 'F'
|
119
|
+
when :slow then 'S'
|
120
|
+
else '.'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def summary
|
125
|
+
error? ? exception_parts[0] : exception.message
|
126
|
+
end
|
127
|
+
|
128
|
+
def freshest_file
|
129
|
+
backtrace.recently_modified.first
|
130
|
+
end
|
131
|
+
|
132
|
+
private
|
133
|
+
|
134
|
+
def exception_parts
|
135
|
+
exception.message.split("\n")
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|