minitest-allow 1.1.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f24ec8511a2369224f41c4a036d52efa431c102690aa1f933097a863e13df8e0
4
- data.tar.gz: b5e459178923fd55debdc76f1bd8e0647ababe7fccb457839c2f2599c0bb8f7c
3
+ metadata.gz: 16c4cd0305f4340a7b8a948ddf81ab474389da5c1ee31e5b3a7a928cbdb877c7
4
+ data.tar.gz: 072e6a2a88033153ddeaa5cbd0790fb2eea50f15a0a109ec32f6080b34cacaf8
5
5
  SHA512:
6
- metadata.gz: a4e5a3e8bfda70b669f185b92280ea1146a18a61533d5508d256ea72f04672e1f3691505dad3b0c643d46ec98577bf681170cc7605c0db1edc82f1d60861eaa3
7
- data.tar.gz: e9d36c2adcb5fa8005b4e2a7eeeecfe35b20bc0822f02ecccd71b419f6e63ffa46a7d544363ffffcf917d4105cc3e3bb23a9b8e36f3248a47ff088702cd46b21
6
+ metadata.gz: 4a99f0cf46cc6831b643fcc8cbfcb6aae763fc4ae2384f829fc83e4fb5f2c0a2deb1082dcbe549c31501c8e62e3bdfd9e6c6545b0338dc316b7435dc73ff9b1d
7
+ data.tar.gz: 3b0e6200c3f493fc9e3800c3b8559f74b37434d810993109bfd6e47685d65b08e3d9448b2572c69de8a6e0db1271cf82f805f1f69b3265651cec6bd1435491cd
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,28 @@
1
+ === 1.2.2 / 2022-08-23
2
+
3
+ * 1 bug fix:
4
+
5
+ * Show skipped tests as good if they're listed in allow file.
6
+
7
+ === 1.2.1 / 2022-07-01
8
+
9
+ * 1 bug fix:
10
+
11
+ * Filter skipped tests from failures.
12
+
13
+ === 1.2.0 / 2022-05-12
14
+
15
+ * 1 major enhancement:
16
+
17
+ * The allow file allows for regexps to match errors and names by pattern.
18
+
19
+ * 5 minor enhancements:
20
+
21
+ * Don't print allow fixes unless allow_save
22
+ * Explicity use psych. Don't ask.
23
+ * Output of good/bad tests is now in YAML format with easily searchable headers.
24
+ * Use safe_load_file if it is available and allow Regexps.
25
+
1
26
  === 1.1.0 / 2021-04-19
2
27
 
3
28
  * 2 minor enhancements:
@@ -10,4 +35,3 @@
10
35
  * 1 major enhancement
11
36
 
12
37
  * 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,4 @@
1
1
  ---
2
2
  - TestMinitest::TestAllow#test_sanity
3
+ - TestMinitest::TestAllow#test_was_bad_now_skip
4
+ - !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.2"
39
45
 
40
46
  attr_accessor :allow, :allow_save, :allow_seen
41
47
 
@@ -57,25 +63,85 @@ 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
+ # the same goes for when the test is listed as bad but is now skipped:
111
+
112
+ hit[name] = true if by_name && !by_regx && !r.skipped?
113
+
114
+ by_name || by_regx
115
+ }
116
+ end
117
+
118
+ # 5. remove string and regexps that matched any of the above from allow
119
+ self.allow -= hit.keys
120
+
121
+ errored, failed = allow_results
122
+ .flatten
123
+ .reject(&:skipped?)
124
+ .partition { |t| Minitest::UnexpectedError === t.failure }
125
+
126
+ failed = failed.map(&:full_name)
127
+ errors = Hash.new { |h,k| h[k] = [] }
128
+
129
+ errored.each do |t|
130
+ msg = t.failure.message.lines.first.chomp.gsub(/0x\h+/, "0xHHHH")
131
+
132
+ errors[Regexp.new(Regexp.escape(msg))] << t.full_name
72
133
  end
73
134
 
135
+ extra_bad = failed.uniq
136
+ extra_bad << errors.transform_values(&:uniq) unless errors.empty?
137
+
138
+ # 6. report new failures including regular expressions for errors
139
+
74
140
  unless extra_bad.empty? then
75
141
  io.puts
76
142
  io.puts "Bad tests that are NOT allowed:"
143
+ Psych.dump extra_bad, io, line_width:-1
77
144
  io.puts
78
- io.puts extra_bad.to_yaml
79
145
  end
80
146
  end
81
147
 
@@ -85,10 +151,8 @@ module Minitest
85
151
  unless good.empty? then
86
152
  io.puts
87
153
  io.puts "Excluded tests that now pass:"
154
+ Psych.dump good, io, line_width:-1
88
155
  io.puts
89
- good.each do |name|
90
- io.puts " :allow_good: %p" % [name]
91
- end
92
156
  end
93
157
  end
94
158
 
@@ -4,7 +4,31 @@ require "minitest/allow_plugin"
4
4
  module TestMinitest; end
5
5
 
6
6
  class TestMinitest::TestAllow < Minitest::Test
7
+ def test_good
8
+ assert true
9
+ end
10
+
11
+ def test_skipped
12
+ skip "nah"
13
+ end
14
+
15
+ def test_was_bad_now_skip
16
+ skip "nah" if ENV["OLD_BAD"]
17
+ flunk "nah"
18
+ end
19
+
20
+ def test_unknown_bad
21
+ flunk "bad!"
22
+ end if ENV["NEW_BAD"]
23
+
7
24
  def test_sanity
8
- flunk "write tests or I will kneecap you"
25
+ flunk "nah"
26
+ end
27
+
28
+ 3.times do |n|
29
+ name = "test_regexp_%02d" % [n]
30
+ define_method name do
31
+ raise "This is bad %02d" % [n]
32
+ end
9
33
  end
10
34
  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.2
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
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTIwMTIyMjIwMzgzMFoXDTIxMTIyMjIwMzgzMFowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTIxMTIyMzIzMTkwNFoXDTIyMTIyMzIzMTkwNFowRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +22,14 @@ cert_chain:
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
24
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
25
- AQAE3XRm1YZcCVjAJy5yMZvTOFrS7B2SYErc+0QwmKYbHztTTDY2m5Bii+jhpuxh
26
- H+ETcU1z8TUKLpsBUP4kUpIRowkVN1p/jKapV8T3Rbwq+VuYFe+GMKsf8wGZSecG
27
- oMQ8DzzauZfbvhe2kDg7G9BBPU0wLQlY25rDcCy9bLnD7R0UK3ONqpwvsI5I7x5X
28
- ZIMXR0a9/DG+55mawwdGzCQobDKiSNLK89KK7OcNTALKU0DfgdTkktdgKchzKHqZ
29
- d/AHw/kcnU6iuMUoJEcGiJd4gVCTn1l3cDcIvxakGslCA88Jubw0Sqatan0TnC9g
30
- KToW560QIey7SPfHWduzFJnV
25
+ AQCKB5jfsuSnKb+t/Wrh3UpdkmX7TrEsjVmERC0pPqzQ5GQJgmEXDD7oMgaKXaAq
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-08-24 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.24'
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.24'
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