minitest-heat 0.0.10 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/README.md +48 -13
- data/examples/exceptions.png +0 -0
- data/examples/failures.png +0 -0
- data/examples/map.png +0 -0
- data/examples/markers.png +0 -0
- data/examples/skips.png +0 -0
- data/examples/slows.png +0 -0
- data/lib/minitest/heat/backtrace/line_parser.rb +25 -0
- data/lib/minitest/heat/backtrace.rb +21 -59
- data/lib/minitest/heat/hit.rb +18 -6
- data/lib/minitest/heat/issue.rb +35 -17
- data/lib/minitest/heat/location.rb +113 -132
- data/lib/minitest/heat/locations.rb +105 -0
- data/lib/minitest/heat/map.rb +3 -4
- data/lib/minitest/heat/output/backtrace.rb +88 -70
- data/lib/minitest/heat/output/issue.rb +56 -83
- data/lib/minitest/heat/output/map.rb +116 -28
- data/lib/minitest/heat/output.rb +27 -13
- data/lib/minitest/heat/results.rb +11 -6
- data/lib/minitest/heat/source.rb +1 -1
- data/lib/minitest/heat/version.rb +1 -1
- data/lib/minitest/heat.rb +1 -0
- data/lib/minitest/heat_plugin.rb +1 -1
- data/lib/minitest/heat_reporter.rb +13 -6
- metadata +11 -4
- data/lib/minitest/heat/backtrace/line.rb +0 -118
@@ -1,118 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'forwardable'
|
4
|
-
|
5
|
-
module Minitest
|
6
|
-
module Heat
|
7
|
-
class Backtrace
|
8
|
-
# Represents a line from a backtrace to provide more convenient access to information about
|
9
|
-
# the relevant file and line number for displaying in test results
|
10
|
-
class Line
|
11
|
-
attr_accessor :pathname, :number, :container
|
12
|
-
alias line_number number
|
13
|
-
|
14
|
-
# Creates an instance of a line number reference
|
15
|
-
# @param pathname: [Pathname, String] the full pathname to the file
|
16
|
-
# @param number: [Integer, String] the line number in question
|
17
|
-
# @param container: nil [String] the containing method or block for the line of code
|
18
|
-
#
|
19
|
-
# @return [self]
|
20
|
-
def initialize(pathname:, number:, container: nil)
|
21
|
-
@pathname = Pathname(pathname)
|
22
|
-
@number = number.to_i
|
23
|
-
@container = container.to_s
|
24
|
-
end
|
25
|
-
|
26
|
-
# Parses a line from a backtrace in order to convert it to usable components
|
27
|
-
def self.parse_backtrace(raw_text)
|
28
|
-
raw_pathname, raw_line_number, raw_container = raw_text.split(':')
|
29
|
-
raw_container = raw_container.delete_prefix('in `').delete_suffix("'")
|
30
|
-
|
31
|
-
new(pathname: raw_pathname, number: raw_line_number, container: raw_container)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Generates a formatted string describing the line of code similar to the original backtrace
|
35
|
-
#
|
36
|
-
# @return [String] a consistently-formatted, human-readable string about the line of code
|
37
|
-
def to_s
|
38
|
-
"#{location} in `#{container}`"
|
39
|
-
end
|
40
|
-
|
41
|
-
# A safe interface to getting a string representing the path portion of the file
|
42
|
-
#
|
43
|
-
# @return [String] either the path/directory portion of the file name or '(Unrecognized File)'
|
44
|
-
# if the offending file can't be found for some reason
|
45
|
-
def path
|
46
|
-
pathname.exist? ? pathname.dirname : UNRECOGNIZED
|
47
|
-
end
|
48
|
-
|
49
|
-
# A safe interface for getting a string representing the filename portion of the file
|
50
|
-
#
|
51
|
-
# @return [String] either the filename portion of the file or '(Unrecognized File)'
|
52
|
-
# if the offending file can't be found for some reason
|
53
|
-
def file
|
54
|
-
pathname.exist? ? pathname.basename : UNRECOGNIZED
|
55
|
-
end
|
56
|
-
|
57
|
-
# A safe interface to getting the last modified time for the file in question
|
58
|
-
#
|
59
|
-
# @return [Time] the timestamp for when the file in question was last modified or `Time.at(0)`
|
60
|
-
# if the offending file can't be found for some reason
|
61
|
-
def mtime
|
62
|
-
pathname.exist? ? pathname.mtime : UNKNOWN_MODIFICATION_TIME
|
63
|
-
end
|
64
|
-
|
65
|
-
# A safe interface to getting the number of seconds since the file was modified
|
66
|
-
#
|
67
|
-
# @return [Integer] the number of seconds since the file was modified or `-1` if the offending
|
68
|
-
# file can't be found for some reason
|
69
|
-
def age_in_seconds
|
70
|
-
pathname.exist? ? seconds_ago : UNKNOWN_MODIFICATION_SECONDS
|
71
|
-
end
|
72
|
-
|
73
|
-
# A convenient method for getting the full location identifier using the full pathname and
|
74
|
-
# line number separated by a `:`
|
75
|
-
#
|
76
|
-
# @return [String] the full pathname and line number
|
77
|
-
def location
|
78
|
-
"#{pathname}:#{number}"
|
79
|
-
end
|
80
|
-
|
81
|
-
# A convenient method for getting the short location with `Dir.pwd` removed
|
82
|
-
#
|
83
|
-
# @return [String] the relative pathname and line number
|
84
|
-
def short_location
|
85
|
-
"#{file}:#{number}"
|
86
|
-
end
|
87
|
-
|
88
|
-
# A convenient method for getting the line of source code for the offending line number
|
89
|
-
#
|
90
|
-
# @return [String] the source code for the file/line number combination
|
91
|
-
def source_code(max_line_count: 1)
|
92
|
-
Minitest::Heat::Source.new(
|
93
|
-
pathname.to_s,
|
94
|
-
line_number: line_number,
|
95
|
-
max_line_count: max_line_count
|
96
|
-
)
|
97
|
-
end
|
98
|
-
|
99
|
-
# Determines if a given file follows the standard approaching to naming test files.
|
100
|
-
#
|
101
|
-
# @return [Boolean] true if the file name starts with `test_` or ends with `_test.rb`
|
102
|
-
def test_file?
|
103
|
-
file.to_s.start_with?('test_') || file.to_s.end_with?('_test.rb')
|
104
|
-
end
|
105
|
-
|
106
|
-
private
|
107
|
-
|
108
|
-
UNRECOGNIZED = '(Unrecognized File)'
|
109
|
-
UNKNOWN_MODIFICATION_TIME = Time.at(0)
|
110
|
-
UNKNOWN_MODIFICATION_SECONDS = -1
|
111
|
-
|
112
|
-
def seconds_ago
|
113
|
-
(Time.now - mtime).to_i
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|