minitest-allow 1.0.0 → 1.2.1

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: 6d4b452b249bcbf28fd6a1fe02554605287695f5132a49355c1ff86d9670050c
4
- data.tar.gz: 43f8db6fc12c23fef4ea9ae778f67d49ddfea0a394f599c65258519913682d80
3
+ metadata.gz: 42269ba2ac0e790cf210d17c0a5f41d74678f17ce9044fee722e15b82ce1053d
4
+ data.tar.gz: 94c2be932cd4447b3e3ae70ff5b6c165e8aa653eef39c698e503e73337c4a698
5
5
  SHA512:
6
- metadata.gz: c440e3f3205155ff80a83bc5abbeb2e70b2a225c50097ae8a25a3346fe11a60d1d845aa71717e80f45649bbb61180926b6dfe8562ef6ae70ea5451e024685255
7
- data.tar.gz: cb00914e91781619a1ac7eb85cba9f2734b3163e0abdb96c4f474cf1e916274d6c35dcc82a50d07bf4e34f9bcc670c2f69dca1d063410666f9029cfc232930cd
6
+ metadata.gz: 4ddf765dcb88e7bccd9c18d4e049eb2c892a3fa6a17ab5e0f6e43bcad322de91b217a0afac0ba55c5c12837f67fc524b43148e9d044969fa8f1879b3b493f165
7
+ data.tar.gz: cf20a5b160feaddfa5cd1e0f45cbeb2d617f5e1393dc8a3c635069f43097e80ffeb0ba5cba45a7f9e0124783f153eb778af397466643a102d246234d1bcbddcd
checksums.yaml.gz.sig CHANGED
@@ -1 +1 @@
1
- -��&�\!�},:��?�Ʀ���X%(��D>��� <�2/|�MHi���Y�qX$�7������1A}?�K���IM*���{������12Ȁ��|�q��$���j���cjjHy��+�@�`P8$�Ro�"V#�T�� �E
1
+ �k/̊I�4^�����Q<> ��(�������/�e\;"�@p��`�=�kn����/y��y�C[�v�\[h�����M�TUv)Gˠ�$��%�Q
data/History.rdoc CHANGED
@@ -1,6 +1,31 @@
1
+ === 1.2.1 / 2022-07-01
2
+
3
+ * 1 bug fix:
4
+
5
+ * Filter skipped tests from failures.
6
+
7
+ === 1.2.0 / 2022-05-12
8
+
9
+ * 1 major enhancement:
10
+
11
+ * The allow file allows for regexps to match errors and names by pattern.
12
+
13
+ * 5 minor enhancements:
14
+
15
+ * Don't print allow fixes unless allow_save
16
+ * Explicity use psych. Don't ask.
17
+ * Output of good/bad tests is now in YAML format with easily searchable headers.
18
+ * Use safe_load_file if it is available and allow Regexps.
19
+
20
+ === 1.1.0 / 2021-04-19
21
+
22
+ * 2 minor enhancements:
23
+
24
+ * This works even when running subsets of tests (eg parallel in a CI)
25
+ * Tracks tests that are allowed yet pass and can thus be removed from allowed list.
26
+
1
27
  === 1.0.0 / 2021-04-02
2
28
 
3
29
  * 1 major enhancement
4
30
 
5
31
  * Birthday!
6
-
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/
@@ -1,12 +1,20 @@
1
1
  module Minitest
2
2
  def self.plugin_allow_options opts, _options # :nodoc:
3
+ @allow = @allow_save = false
4
+
3
5
  opts.on "-a", "--allow=path", String, "Allow listed tests to fail." do |f|
4
- require "yaml"
5
- @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
6
14
  end
7
15
 
8
16
  opts.on "-A", "--save-allow=path", String, "Save failing tests." do |f|
9
- require "yaml"
17
+ require "psych"
10
18
  @allow_save = f
11
19
  end
12
20
  end
@@ -14,10 +22,10 @@ module Minitest
14
22
  def self.plugin_allow_init options # :nodoc:
15
23
  if @allow || @allow_save then
16
24
  self.reporter.extend Allow
25
+ self.reporter.allow = @allow
26
+ self.reporter.allow_save = @allow_save
27
+ self.reporter.allow_seen = []
17
28
  end
18
-
19
- self.reporter.allow = @allow if @allow
20
- self.reporter.allow_save = @allow_save if @allow_save
21
29
  end
22
30
 
23
31
  class Result # TODO: push up
@@ -26,10 +34,21 @@ module Minitest
26
34
  end
27
35
  end
28
36
 
37
+ class Minitest::Test # sigh... rails
38
+ def full_name
39
+ "%s#%s" % [self.class, name]
40
+ end
41
+ end
42
+
29
43
  module Allow
30
- VERSION = "1.0.0"
44
+ VERSION = "1.2.1"
31
45
 
32
- attr_accessor :allow, :allow_save
46
+ attr_accessor :allow, :allow_save, :allow_seen
47
+
48
+ def record result
49
+ allow_seen << result.full_name
50
+ super
51
+ end
33
52
 
34
53
  def allow_results
35
54
  self.reporters
@@ -39,27 +58,99 @@ module Minitest
39
58
 
40
59
  def write_allow
41
60
  data = allow_results
42
- .flat_map { |rs| rs.map(&:full_name) }
61
+ .flatten
62
+ .map(&:full_name)
43
63
  .uniq
44
64
  .sort
45
65
 
46
- File.write allow_save, data.to_yaml
66
+ File.write allow_save, Psych.dump(data, line_width:-1)
47
67
  end
48
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
+
49
87
  def filter_allow
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
92
+
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?
96
+
97
+ hit = {}
98
+ allow_results = self.allow_results
50
99
  allow_results.each do |results|
51
- results.delete_if { |r| allow.delete 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
+ }
114
+ end
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
+ .reject(&:skipped?)
122
+ .partition { |t| Minitest::UnexpectedError === t.failure }
123
+
124
+ failed = failed.map(&:full_name)
125
+ errors = Hash.new { |h,k| h[k] = [] }
126
+
127
+ errored.each do |t|
128
+ msg = t.failure.message.lines.first.chomp.gsub(/0x\h+/, "0xHHHH")
129
+
130
+ errors[Regexp.new(Regexp.escape(msg))] << t.full_name
131
+ end
132
+
133
+ extra_bad = failed.uniq
134
+ extra_bad << errors.transform_values(&:uniq) unless errors.empty?
135
+
136
+ # 6. report new failures including regular expressions for errors
137
+
138
+ unless extra_bad.empty? then
139
+ io.puts
140
+ io.puts "Bad tests that are NOT allowed:"
141
+ Psych.dump extra_bad, io, line_width:-1
142
+ io.puts
52
143
  end
53
144
  end
54
145
 
55
146
  def report_extra_allow
56
- unless allow.empty? then
147
+ good = allow & allow_seen
148
+
149
+ unless good.empty? then
57
150
  io.puts
58
151
  io.puts "Excluded tests that now pass:"
152
+ Psych.dump good, io, line_width:-1
59
153
  io.puts
60
- allow.each do |name|
61
- io.puts " #{name}"
62
- end
63
154
  end
64
155
  end
65
156
 
@@ -4,7 +4,26 @@ 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_unknown_bad
16
+ flunk "bad!"
17
+ end if ENV["NEW_BAD"]
18
+
7
19
  def test_sanity
8
- flunk "write tests or I will kneecap you"
20
+ flunk "nah"
21
+ end
22
+
23
+ 3.times do |n|
24
+ name = "test_regexp_%02d" % [n]
25
+ define_method name do
26
+ raise "This is bad %02d" % [n]
27
+ end
9
28
  end
10
29
  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.0.0
4
+ version: 1.2.1
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
  AwwKcnlhbmQtcnVieTEZ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xn4h9YO/pVdB962BdBNNDia0kgIjI3ENnkLq0dKpYU3+F3KhEuTksLO0L6X/V
30
+ YsuyUzsMz6GQA4khyaMgKNSD
31
31
  -----END CERTIFICATE-----
32
- date: 2021-04-03 00:00:00.000000000 Z
32
+ date: 2022-07-02 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.15
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