minitest-allow 1.1.0 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f24ec8511a2369224f41c4a036d52efa431c102690aa1f933097a863e13df8e0
4
- data.tar.gz: b5e459178923fd55debdc76f1bd8e0647ababe7fccb457839c2f2599c0bb8f7c
3
+ metadata.gz: 5561e1b5e01bbc7bc937a0532707bb5c03ae369c66f39fa9a6d345f33ae5fb21
4
+ data.tar.gz: f6c2ee76c8e82fd30ad9ea3a248f83fb0a8e605cd130bb0c0b20dec1807a465c
5
5
  SHA512:
6
- metadata.gz: a4e5a3e8bfda70b669f185b92280ea1146a18a61533d5508d256ea72f04672e1f3691505dad3b0c643d46ec98577bf681170cc7605c0db1edc82f1d60861eaa3
7
- data.tar.gz: e9d36c2adcb5fa8005b4e2a7eeeecfe35b20bc0822f02ecccd71b419f6e63ffa46a7d544363ffffcf917d4105cc3e3bb23a9b8e36f3248a47ff088702cd46b21
6
+ metadata.gz: 2dcd4745beb67f57cd66bd973c19429497b0ae0021af438f3540ba6bb0566e5eca7d6b8e4fc3a7362d9626e662c10eedb3e938ac38fb61b770e15464523741e3
7
+ data.tar.gz: bb735fe2bb7b7ec75b700e0d28c39e1d26466502638c1a086048c35243a10d7314224ea01f51ac346d3229dc097bb8a9990c65514e778c99696353e26d666421
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,16 @@
1
+ === 1.2.0 / 2022-05-12
2
+
3
+ * 1 major enhancement:
4
+
5
+ * The allow file allows for regexps to match errors and names by pattern.
6
+
7
+ * 5 minor enhancements:
8
+
9
+ * Don't print allow fixes unless allow_save
10
+ * Explicity use psych. Don't ask.
11
+ * Output of good/bad tests is now in YAML format with easily searchable headers.
12
+ * Use safe_load_file if it is available and allow Regexps.
13
+
1
14
  === 1.1.0 / 2021-04-19
2
15
 
3
16
  * 2 minor enhancements:
@@ -10,4 +23,3 @@
10
23
  * 1 major enhancement
11
24
 
12
25
  * Birthday!
13
-
data/Rakefile CHANGED
@@ -15,4 +15,16 @@ Hoe.spec "minitest-allow" do
15
15
  dependency "minitest", "~> 5.0"
16
16
  end
17
17
 
18
+ Rake.application["test"].clear # hack? is there a better way?
19
+
20
+ task :test => "test:filtered"
21
+
22
+ namespace "test" do
23
+ Minitest::TestTask.create "filtered" do |t|
24
+ t.extra_args << "--allow=allow.yml"
25
+ end
26
+
27
+ Minitest::TestTask.create "unfiltered"
28
+ end
29
+
18
30
  # vim: syntax=ruby
data/allow.yml CHANGED
@@ -1,2 +1,3 @@
1
1
  ---
2
2
  - TestMinitest::TestAllow#test_sanity
3
+ - !ruby/regexp /This is bad/
@@ -3,12 +3,18 @@ module Minitest
3
3
  @allow = @allow_save = false
4
4
 
5
5
  opts.on "-a", "--allow=path", String, "Allow listed tests to fail." do |f|
6
- require "yaml"
7
- @allow = YAML.load File.read f
6
+ # don't ask why I'm using this specifically:
7
+ require "psych"
8
+
9
+ @allow = if Psych.respond_to? :safe_load_file then
10
+ Psych.safe_load_file f, permitted_classes: [Regexp]
11
+ else
12
+ Psych.load_file f
13
+ end
8
14
  end
9
15
 
10
16
  opts.on "-A", "--save-allow=path", String, "Save failing tests." do |f|
11
- require "yaml"
17
+ require "psych"
12
18
  @allow_save = f
13
19
  end
14
20
  end
@@ -35,7 +41,7 @@ module Minitest
35
41
  end
36
42
 
37
43
  module Allow
38
- VERSION = "1.1.0"
44
+ VERSION = "1.2.0"
39
45
 
40
46
  attr_accessor :allow, :allow_save, :allow_seen
41
47
 
@@ -57,25 +63,82 @@ module Minitest
57
63
  .uniq
58
64
  .sort
59
65
 
60
- File.write allow_save, data.to_yaml
66
+ File.write allow_save, Psych.dump(data, line_width:-1)
61
67
  end
62
68
 
69
+ # Test runs call record, we put everything ran in allow_seen.
70
+ # This means allow_seen has everything RAN, regardless of pass/fail
71
+ # We use this intersected with the allowed file to determine what to report
72
+ # on... if it wasn't seen, we don't say add/remove at all.
73
+ #
74
+ # `allow` is all the stuff from the allow file. Test names and
75
+ # regexps that excuse failures.
76
+ #
77
+ # `allow_results` is an array of arrays of results: [[result, ...], ...]
78
+ #
79
+ # When the run is done, we want to tell the user what tests to
80
+ # remove or add from the allowed list:
81
+ #
82
+ # * If a test passed that is in the allowed list, it should be removed.
83
+ # * If a test failed that is NOT in the allowed list, it should be added.
84
+ # * If a test failed that is matched by a regexp, it's NAME should be removed
85
+ # if it is listed.
86
+
63
87
  def filter_allow
64
- maybe_bad = allow_results.flatten.map(&:full_name).uniq
65
- to_remove = maybe_bad & allow
66
- extra_bad = maybe_bad - to_remove
88
+ # 1. split allow into strings and regexps
89
+ allowed_REs, allowed_names = allow.partition { |a| Regexp === a }
90
+
91
+ allowed_names = allowed_names.map { |x| [x, x] }.to_h
67
92
 
68
- self.allow -= to_remove
93
+ # 2. remove items from allow_results whose full_name matches the strings
94
+ # 3. remove items from allow_results whose message matches the regexps
95
+ # 4. remove items from allow_results whose full_name matches the regexps?
69
96
 
97
+ hit = {}
98
+ allow_results = self.allow_results
70
99
  allow_results.each do |results|
71
- results.delete_if { |r| to_remove.include? r.full_name }
100
+ results.delete_if { |r|
101
+ name = r.full_name
102
+
103
+ by_name = allowed_names[name]
104
+ by_regx = allowed_REs.find { |re| r.failure.message =~ re || name =~ re }
105
+
106
+ # this will add the name as bad unless hit by regexp as well
107
+ # if hit by regex, then we want to report it as "good" so
108
+ # the name gets removed from the allow list:
109
+
110
+ hit[name] = true if by_name && !by_regx
111
+
112
+ by_name || by_regx
113
+ }
72
114
  end
73
115
 
116
+ # 5. remove string and regexps that matched any of the above from allow
117
+ self.allow -= hit.keys
118
+
119
+ errored, failed = allow_results
120
+ .flatten
121
+ .partition { |t| Minitest::UnexpectedError === t.failure }
122
+
123
+ failed = failed.map(&:full_name)
124
+ errors = Hash.new { |h,k| h[k] = [] }
125
+
126
+ errored.each do |t|
127
+ msg = t.failure.message.lines.first.chomp.gsub(/0x\h+/, "0xHHHH")
128
+
129
+ errors[Regexp.new(Regexp.escape(msg))] << t.full_name
130
+ end
131
+
132
+ extra_bad = failed.uniq
133
+ extra_bad << errors.transform_values(&:uniq) unless errors.empty?
134
+
135
+ # 6. report new failures including regular expressions for errors
136
+
74
137
  unless extra_bad.empty? then
75
138
  io.puts
76
139
  io.puts "Bad tests that are NOT allowed:"
140
+ Psych.dump extra_bad, io, line_width:-1
77
141
  io.puts
78
- io.puts extra_bad.to_yaml
79
142
  end
80
143
  end
81
144
 
@@ -85,10 +148,8 @@ module Minitest
85
148
  unless good.empty? then
86
149
  io.puts
87
150
  io.puts "Excluded tests that now pass:"
151
+ Psych.dump good, io, line_width:-1
88
152
  io.puts
89
- good.each do |name|
90
- io.puts " :allow_good: %p" % [name]
91
- end
92
153
  end
93
154
  end
94
155
 
@@ -5,6 +5,13 @@ module TestMinitest; end
5
5
 
6
6
  class TestMinitest::TestAllow < Minitest::Test
7
7
  def test_sanity
8
- flunk "write tests or I will kneecap you"
8
+ flunk "nah"
9
+ end
10
+
11
+ 3.times do |n|
12
+ name = "test_regexp_%02d" % [n]
13
+ define_method name do
14
+ raise "This is bad %02d" % [n]
15
+ end
9
16
  end
10
17
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-allow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBBTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBBjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydW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q
26
+ x2m+KSZDrqk7c8uho5OX6YMqg4KdxehfSLqqTZGoeV78qwf/jpPQZKTf+W9gUSJh
27
+ zsWpo4K50MP+QtdSbKXZwjAafpQ8hK0MnnZ/aeCsW9ov5vdXpYbf3dpg6ADXRGE7
28
+ lQY2y1tJ5/chqu6h7dQmnm2ABUqx9O+JcN9hbCYoA5i/EeubUEtFIh2w3SpO6YfB
29
+ JFmxn4h9YO/pVdB962BdBNNDia0kgIjI3ENnkLq0dKpYU3+F3KhEuTksLO0L6X/V
30
+ YsuyUzsMz6GQA4khyaMgKNSD
31
31
  -----END CERTIFICATE-----
32
- date: 2021-04-19 00:00:00.000000000 Z
32
+ date: 2022-05-12 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: minitest
@@ -71,14 +71,14 @@ dependencies:
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '3.22'
74
+ version: '3.23'
75
75
  type: :development
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '3.22'
81
+ version: '3.23'
82
82
  description: |-
83
83
  Allows you to provide an exclusion list of allowed failures/errors.
84
84
  Failures and errors on this list still get run and reported as usual,
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.2.16
126
+ rubygems_version: 3.3.12
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Allows you to provide an exclusion list of allowed failures/errors
metadata.gz.sig CHANGED
Binary file