minitest-holdify 1.3.3 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/holdify/feedback.rb +22 -16
- data/lib/holdify/hold.rb +4 -2
- data/lib/holdify.rb +2 -2
- data/lib/minitest/holdify_plugin.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d19382125e8e102ff0d8b01ca8227e68b44c7d0a532e99b5b2e7236a37a37407
|
|
4
|
+
data.tar.gz: cc34821ba517f701180baa40391421cc6d888d18a079be4c1445d6bda43578dc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0981c21b5932c8931c467642c6b1575bd3c61f34430f9330eb3c8c22d6712de5dba67ce6b31b8f8f59ed8e2778ddf3d393570721eda84496a35001e394e22588'
|
|
7
|
+
data.tar.gz: 5a73f8ab4dedddfe7694651d9a582641926648810c8dc30bec911a10c0f60dd63fa14b2b38422fd861b8abe18e9890b86de182cb73a28b7026b1bc8e7428912d
|
data/lib/holdify/feedback.rb
CHANGED
|
@@ -8,12 +8,8 @@ module Holdify
|
|
|
8
8
|
# Feedback report on failure
|
|
9
9
|
class Feedback
|
|
10
10
|
def initialize(hold, hold_ref, *args)
|
|
11
|
-
test_lno = hold.test_loc.lineno
|
|
12
|
-
index = hold.session[test_lno].size - 1 # current index
|
|
13
|
-
xxh = hold.store.xxh(test_lno)
|
|
14
11
|
yaml_path = hold.store.path
|
|
15
|
-
|
|
16
|
-
@yaml_lno = find_yaml_lno(yaml_path, test_lno, xxh, index)
|
|
12
|
+
@yaml_lno = find_yaml_lno(hold, yaml_path)
|
|
17
13
|
@yaml_ref = Holdify.relativize("#{yaml_path}:#{@yaml_lno}")
|
|
18
14
|
|
|
19
15
|
@hold_ref = Holdify.relativize(hold_ref)
|
|
@@ -34,7 +30,7 @@ module Holdify
|
|
|
34
30
|
extend Color::GitDiff
|
|
35
31
|
end
|
|
36
32
|
|
|
37
|
-
def
|
|
33
|
+
def render = [@message, *file_refs, *diff, ''].join("\n")
|
|
38
34
|
|
|
39
35
|
def file_refs
|
|
40
36
|
["--- @stored --> #{@yaml_ref}", "+++ @tested --> #{@hold_ref}"].tap do |refs|
|
|
@@ -46,7 +42,11 @@ module Holdify
|
|
|
46
42
|
|
|
47
43
|
private
|
|
48
44
|
|
|
49
|
-
def find_yaml_lno(
|
|
45
|
+
def find_yaml_lno(hold, yaml_path)
|
|
46
|
+
test_lno = hold.test_loc.lineno
|
|
47
|
+
index = hold.session[test_lno].size - 1 # current index
|
|
48
|
+
xxh = hold.store.xxh(test_lno)
|
|
49
|
+
|
|
50
50
|
found = false
|
|
51
51
|
count = -1
|
|
52
52
|
File.foreach(yaml_path).with_index(1) do |line, ln|
|
|
@@ -91,8 +91,8 @@ module Holdify
|
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def process_lines(lines)
|
|
94
|
-
width
|
|
95
|
-
lineno
|
|
94
|
+
width = 0
|
|
95
|
+
lineno = [@yaml_lno - 1]
|
|
96
96
|
lines.map.with_index do |line, i|
|
|
97
97
|
if i.zero? # @@ ... @@
|
|
98
98
|
width, line = render_hunk(line)
|
|
@@ -105,14 +105,16 @@ module Holdify
|
|
|
105
105
|
end.compact
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
+
# Reduce the hunk lines by 1 and calculate the gutter width
|
|
108
109
|
def render_hunk(line)
|
|
109
110
|
width = 0
|
|
110
111
|
hunk = line.gsub(/([-+]\d+),(\d+)\s+([-+]\d+),(\d+)/) do
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
v1, = $2.to_i - 1 # rubocop:disable Style/PerlBackrefs
|
|
113
|
+
v2 = $4.to_i - 1 # rubocop:disable Style/PerlBackrefs
|
|
114
|
+
width = (@yaml_lno + [v1, v2].max).to_s.length
|
|
115
|
+
"#{$1},#{v1} #{$3},#{v2}" # rubocop:disable Style/PerlBackrefs
|
|
116
|
+
end
|
|
117
|
+
|
|
116
118
|
[width, hunk]
|
|
117
119
|
end
|
|
118
120
|
|
|
@@ -149,7 +151,11 @@ module Holdify
|
|
|
149
151
|
|
|
150
152
|
# Methods enabling the git-diff ANSI feedback
|
|
151
153
|
module GitDiff
|
|
152
|
-
def git_command
|
|
154
|
+
def git_command
|
|
155
|
+
# Words/ruby entities | indent | other single-chars
|
|
156
|
+
re = '[[:alnum:]_:]+|[[:space:]]+|.'
|
|
157
|
+
"git diff --no-index --color-words='#{re}' --unified=1000 #{@exp_path} #{@act_path}"
|
|
158
|
+
end
|
|
153
159
|
|
|
154
160
|
def render_line(line, lineno, width)
|
|
155
161
|
clean = line.gsub(/\e\[(1|22|0)m/, '').lstrip
|
|
@@ -164,7 +170,7 @@ module Holdify
|
|
|
164
170
|
"#{sgr}#{type}#{' ' * width}#{SGR[:clear]}"
|
|
165
171
|
else
|
|
166
172
|
lineno[0] += 1
|
|
167
|
-
"#{sgr}#{type || ' '}#{lineno[0].to_s.rjust(width)}#{SGR[:clear]}"
|
|
173
|
+
"#{sgr}#{type || ' '}#{lineno[0].to_s.rjust(width)}#{SGR[:clear] if sgr}"
|
|
168
174
|
end
|
|
169
175
|
|
|
170
176
|
"#{gutter} #{line}"
|
data/lib/holdify/hold.rb
CHANGED
|
@@ -39,6 +39,10 @@ module Holdify
|
|
|
39
39
|
@session.each { |lineno, values| @store.set_values(lineno, values) }
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
def feedback(*) = Feedback.new(self, *).render
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
42
46
|
# Find the triggering LOC inside the test block/method
|
|
43
47
|
def find_test_loc
|
|
44
48
|
caller_locations(2).find do |location|
|
|
@@ -48,7 +52,5 @@ module Holdify
|
|
|
48
52
|
label == @test.name || label == '<top (required)>' || label == '<main>' || label.start_with?('<class:', '<module:')
|
|
49
53
|
end
|
|
50
54
|
end
|
|
51
|
-
|
|
52
|
-
def feedback(*) = Feedback.new(self, *).message
|
|
53
55
|
end
|
|
54
56
|
end
|
data/lib/holdify.rb
CHANGED
|
@@ -7,7 +7,7 @@ require_relative 'holdify/store'
|
|
|
7
7
|
|
|
8
8
|
# The container module
|
|
9
9
|
module Holdify
|
|
10
|
-
VERSION = '1.3.
|
|
10
|
+
VERSION = '1.3.5'
|
|
11
11
|
|
|
12
12
|
@fresh_mutex = Mutex.new
|
|
13
13
|
@fresh = []
|
|
@@ -23,7 +23,7 @@ module Holdify
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def
|
|
26
|
+
def warn_fresh_values
|
|
27
27
|
return if quiet
|
|
28
28
|
|
|
29
29
|
@fresh_mutex.synchronize do
|
|
@@ -19,8 +19,8 @@ module Minitest
|
|
|
19
19
|
opts.on '--holdify-no-color', 'Disable colored output' do
|
|
20
20
|
options[:holdify_no_color] = true
|
|
21
21
|
end
|
|
22
|
-
opts.on '--holdify-
|
|
23
|
-
options[:
|
|
22
|
+
opts.on '--holdify-absolute-paths', 'Disable relative paths in file references' do
|
|
23
|
+
options[:holdify_absolute_paths] = true
|
|
24
24
|
end
|
|
25
25
|
opts.on '--holdify-store-ext EXT', 'The yaml store extension (default .yaml)' do |ext|
|
|
26
26
|
options[:holdify_store_ext] = ext
|
|
@@ -38,19 +38,19 @@ module Minitest
|
|
|
38
38
|
Holdify.quiet = options[:holdify_quiet]
|
|
39
39
|
Holdify.git_diff = git unless options[:holdify_no_git_diff]
|
|
40
40
|
Holdify.color = !ENV.key?('NO_COLOR') unless options[:holdify_no_color]
|
|
41
|
-
Holdify.rel_paths = true unless options[:
|
|
41
|
+
Holdify.rel_paths = true unless options[:holdify_absolute_paths]
|
|
42
42
|
Holdify.store_ext = options[:holdify_store_ext] || '.yaml'
|
|
43
43
|
|
|
44
44
|
Minitest.after_run do
|
|
45
45
|
Holdify.persist_stores!
|
|
46
|
-
Holdify.
|
|
46
|
+
Holdify.warn_fresh_values
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
# Patching Minitest::Assertion
|
|
51
51
|
class Assertion
|
|
52
52
|
remove_const :RE
|
|
53
|
-
RE = /in [`'](?:[^']+[#.])?(?:assert|refute|flunk|pass|fail|raise|must|wont|to)/ #
|
|
53
|
+
RE = /in [`'](?:[^']+[#.])?(?:assert|refute|flunk|pass|fail|raise|must|wont|to)/ # add to (to_hold)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
# Reopen the minitest class
|