minitest-heat 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/minitest/heat/hit.rb +5 -9
- data/lib/minitest/heat/map.rb +0 -16
- data/lib/minitest/heat/output/map.rb +31 -22
- data/lib/minitest/heat/results.rb +4 -2
- data/lib/minitest/heat/version.rb +1 -1
- data/lib/minitest/heat_reporter.rb +2 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c787ecc1dc1259c0dd25a3f245476c353d7b2dcab4050876965470c1f117a17
|
4
|
+
data.tar.gz: 1eab9c751b578a6eedfeffe8b7029df9699e25e7d9e644b2e472a47b3fba1f0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56ad59e3df9468d7157f43e7d033e9187a66da1c11e388286ad25d140094ace8219e5c86e86891afe587f86d2c11df3e16ef900cef7db815ca50df3e35320fe8
|
7
|
+
data.tar.gz: 35fc16047ced8c8718b42cfcaa0cf0ee6796c8953f21f67db6edab23fc802a1659858bdffb77d853c4530359afea83417f6efa32485d7053d48b7baf568c7dff
|
data/Gemfile.lock
CHANGED
data/lib/minitest/heat/hit.rb
CHANGED
@@ -15,11 +15,11 @@ module Minitest
|
|
15
15
|
# test is broken (i.e. raising an exception), that's a special sort of failure that would be
|
16
16
|
# misleading. It doesn't represent a proper failure, but rather a test that doesn't work.
|
17
17
|
WEIGHTS = {
|
18
|
-
error:
|
19
|
-
broken:
|
20
|
-
failure:
|
21
|
-
skipped:
|
22
|
-
painful:
|
18
|
+
error: 5, # exceptions from source code have the highest likelihood of a ripple effect
|
19
|
+
broken: 4, # broken tests won't have ripple effects but can't help if they can't run
|
20
|
+
failure: 3, # failures are kind of the whole point, and they could have ripple effects
|
21
|
+
skipped: 2, # skips aren't failures, but they shouldn't go ignored
|
22
|
+
painful: 1, # slow tests aren't failures, but they shouldn't be ignored
|
23
23
|
slow: 0
|
24
24
|
}.freeze
|
25
25
|
|
@@ -43,10 +43,6 @@ module Minitest
|
|
43
43
|
(Time.now - mtime).to_i
|
44
44
|
end
|
45
45
|
|
46
|
-
def critical_issues?
|
47
|
-
issues[:error].any? || issues[:broken].any? || issues[:failure].any?
|
48
|
-
end
|
49
|
-
|
50
46
|
def issue_count
|
51
47
|
count = 0
|
52
48
|
Issue::TYPES.each do |issue_type|
|
data/lib/minitest/heat/map.rb
CHANGED
@@ -7,22 +7,6 @@ module Minitest
|
|
7
7
|
|
8
8
|
attr_reader :hits
|
9
9
|
|
10
|
-
# So we can sort hot spots by liklihood of being the most important spot to check out before
|
11
|
-
# trying to fix something. These are ranked based on the possibility they represent ripple
|
12
|
-
# effects where fixing one problem could potentially fix multiple other failures.
|
13
|
-
#
|
14
|
-
# For example, if there's an exception in the file, start there. Broken code can't run. If a
|
15
|
-
# test is broken (i.e. raising an exception), that's a special sort of failure that would be
|
16
|
-
# misleading. It doesn't represent a proper failure, but rather a test that doesn't work.
|
17
|
-
WEIGHTS = {
|
18
|
-
error: 3, # exceptions from source code have the highest liklihood of a ripple effect
|
19
|
-
broken: 2, # broken tests won't have ripple effects but can't help if they can't run
|
20
|
-
failure: 1, # failures are kind of the whole point, and they could have ripple effects
|
21
|
-
skipped: 0, # skips aren't failures, but they shouldn't go ignored
|
22
|
-
painful: 0, # slow tests aren't failures, but they shouldn't be ignored
|
23
|
-
slow: 0
|
24
|
-
}.freeze
|
25
|
-
|
26
10
|
def initialize
|
27
11
|
@hits = {}
|
28
12
|
end
|
@@ -4,22 +4,23 @@ module Minitest
|
|
4
4
|
module Heat
|
5
5
|
class Output
|
6
6
|
class Map
|
7
|
-
|
7
|
+
attr_accessor :results
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
# def_delegators :@results, :errors, :brokens, :failures, :slows, :skips, :problems?, :slows?
|
12
|
-
|
13
|
-
def initialize(map)
|
14
|
-
@map = map
|
9
|
+
def initialize(results)
|
10
|
+
@results = results
|
15
11
|
@tokens = []
|
16
12
|
end
|
17
13
|
|
18
14
|
def tokens
|
19
|
-
map.file_hits.each do |
|
15
|
+
map.file_hits.each do |hit|
|
16
|
+
file_tokens = pathname(hit)
|
17
|
+
line_number_tokens = line_numbers(hit)
|
18
|
+
|
19
|
+
next if line_number_tokens.empty?
|
20
|
+
|
20
21
|
@tokens << [
|
21
|
-
*
|
22
|
-
*
|
22
|
+
*file_tokens,
|
23
|
+
*line_number_tokens
|
23
24
|
]
|
24
25
|
end
|
25
26
|
|
@@ -28,6 +29,20 @@ module Minitest
|
|
28
29
|
|
29
30
|
private
|
30
31
|
|
32
|
+
def map
|
33
|
+
results.heat_map
|
34
|
+
end
|
35
|
+
|
36
|
+
def relevant_issue_types
|
37
|
+
issue_types = %i[error broken failure]
|
38
|
+
|
39
|
+
issue_types << :skipped unless results.problems?
|
40
|
+
issue_types << :painful unless results.problems? || results.skips.any?
|
41
|
+
issue_types << :slow unless results.problems? || results.skips.any?
|
42
|
+
|
43
|
+
issue_types
|
44
|
+
end
|
45
|
+
|
31
46
|
def pathname(file)
|
32
47
|
directory = "#{file.pathname.dirname.to_s.delete_prefix(Dir.pwd)}/"
|
33
48
|
filename = file.pathname.basename.to_s
|
@@ -40,11 +55,8 @@ module Minitest
|
|
40
55
|
end
|
41
56
|
|
42
57
|
def hit_line_numbers(file, issue_type)
|
43
|
-
line_numbers_for_issue_type = file.issues.fetch(issue_type) { [] }
|
44
|
-
|
45
|
-
return nil if line_numbers_for_issue_type.empty?
|
46
|
-
|
47
58
|
numbers = []
|
59
|
+
line_numbers_for_issue_type = file.issues.fetch(issue_type) { [] }
|
48
60
|
line_numbers_for_issue_type.sort.map do |line_number|
|
49
61
|
numbers << [issue_type, "#{line_number} "]
|
50
62
|
end
|
@@ -52,14 +64,11 @@ module Minitest
|
|
52
64
|
end
|
53
65
|
|
54
66
|
def line_numbers(file)
|
55
|
-
[
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
*hit_line_numbers(file, :painful),
|
61
|
-
*hit_line_numbers(file, :slow)
|
62
|
-
].compact.sort_by { |number_token| number_token[1] }
|
67
|
+
line_number_tokens = []
|
68
|
+
relevant_issue_types.each do |issue_type|
|
69
|
+
line_number_tokens += hit_line_numbers(file, issue_type)
|
70
|
+
end
|
71
|
+
line_number_tokens.compact.sort_by { |number_token| number_token[1] }
|
63
72
|
end
|
64
73
|
end
|
65
74
|
end
|
@@ -4,14 +4,16 @@ module Minitest
|
|
4
4
|
module Heat
|
5
5
|
# A collection of test failures
|
6
6
|
class Results
|
7
|
-
attr_reader :issues
|
7
|
+
attr_reader :issues, :heat_map
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@issues = []
|
11
|
+
@heat_map = Heat::Map.new
|
11
12
|
end
|
12
13
|
|
13
14
|
def record(issue)
|
14
|
-
@issues
|
15
|
+
@issues.push(issue)
|
16
|
+
@heat_map.add(*issue.to_hit) if issue.hit?
|
15
17
|
end
|
16
18
|
|
17
19
|
def problems?
|
@@ -32,15 +32,13 @@ 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 = {})
|
39
38
|
@options = options
|
40
39
|
|
41
40
|
@timer = Heat::Timer.new
|
42
41
|
@results = Heat::Results.new
|
43
|
-
@map = Heat::Map.new
|
44
42
|
@output = Heat::Output.new(io)
|
45
43
|
end
|
46
44
|
|
@@ -68,7 +66,6 @@ module Minitest
|
|
68
66
|
|
69
67
|
timer.increment_counts(issue.result.assertions)
|
70
68
|
results.record(issue)
|
71
|
-
map.add(*issue.to_hit) if issue.hit?
|
72
69
|
|
73
70
|
output.marker(issue.type)
|
74
71
|
end
|
@@ -97,7 +94,7 @@ module Minitest
|
|
97
94
|
|
98
95
|
# If there were issues, shows a short heat map summary of which files and lines were the most
|
99
96
|
# common sources of issues
|
100
|
-
output.heat_map(
|
97
|
+
output.heat_map(results)
|
101
98
|
|
102
99
|
# A blank line to create some breathing room
|
103
100
|
output.newline
|
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.8
|
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-10-
|
11
|
+
date: 2021-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|