warning 0.10.0 → 0.10.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
  SHA1:
3
- metadata.gz: c0a00f58401bfb0c3b182b5e472de7d417e5e9c7
4
- data.tar.gz: 6e4a3377be9ee85d5de9848e4eaaa20b367035a4
3
+ metadata.gz: '08cf870b5689f1fc79b3a2c1c9bd787c10802ed0'
4
+ data.tar.gz: 43f33015143cf420dd92f3db2ad0c5b91f05335d
5
5
  SHA512:
6
- metadata.gz: 1e3c7971f5ec2a5b28ec263aa6847778f45790b3554cdfee4fc8b4c08af21e3459dcf148fd8618b4d632cbd285e6afd6518ededc69a01469ea676666df564a5c
7
- data.tar.gz: 674820530875fa42a1920f06673add77b66210fee9b50bd150cbafdce603e275c30c422cf985838e6f5500096aeb815c40d2a5d7cb5766b430a7912bf7f2238b
6
+ metadata.gz: 2f35fc384e25902773a66ec191ccdf522a762a3c6006d339b66ce4b16c11e1e67df9454d12be4a941c2ad0458b978707b1fc98bfde052c0918c48304d9bea30e
7
+ data.tar.gz: 6cd8864633508b1bcf4928d4d25c4d8e19763a48f58b1160eb9f03aa3a178413f4b42270bb92b9bf7f7d8941de2c5f02c53f05463ea5f003ab0eff769f535bea
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.10.1 (2017-11-16)
2
+
3
+ * Correctly handle Warning.freeze (jeremyevans)
4
+
1
5
  === 0.10.0 (2016-11-16)
2
6
 
3
7
  * Add support for :arg_prefix and :shadow as regexp argument to Warning.ignore (jeremyevans)
data/Rakefile CHANGED
@@ -15,11 +15,19 @@ end
15
15
  desc "Run test"
16
16
  Rake::TestTask.new do |t|
17
17
  t.libs.push "lib"
18
- t.test_files = FileList['test/test_*.rb']
18
+ t.test_files = FileList['test/test_warning.rb']
19
19
  t.verbose = true
20
20
  end
21
21
 
22
- task :default=>:test
22
+ desc "Run test"
23
+ Rake::TestTask.new(:test_freeze) do |t|
24
+ t.libs.push "lib"
25
+ t.test_files = FileList['test/test_freeze_warning.rb']
26
+ t.verbose = true
27
+ end
28
+
29
+ desc "Run all tests"
30
+ task :default=>[:test, :test_freeze]
23
31
 
24
32
  ### RDoc
25
33
 
@@ -24,6 +24,12 @@ module Warning
24
24
  @process.clear
25
25
  end
26
26
  end
27
+
28
+ def freeze
29
+ @ignore.freeze
30
+ @process.freeze
31
+ super
32
+ end
27
33
 
28
34
  # Ignore any warning messages matching the given regexp, if they
29
35
  # start with the given path.
@@ -117,11 +123,17 @@ module Warning
117
123
 
118
124
  super
119
125
  end
126
+
127
+ private
128
+
129
+ def synchronize(&block)
130
+ @monitor.synchronize(&block)
131
+ end
120
132
  end
121
133
 
122
134
  @ignore = []
123
135
  @process = []
136
+ @monitor = Monitor.new
124
137
 
125
- extend MonitorMixin
126
138
  extend Processor
127
139
  end
@@ -0,0 +1,69 @@
1
+ require 'minitest/autorun'
2
+ require 'warning'
3
+
4
+ class WarningFreezeTest < Minitest::Test
5
+ module EnvUtil
6
+ def verbose_warning
7
+ class << (stderr = "")
8
+ alias write <<
9
+ end
10
+ stderr, $stderr, verbose, $VERBOSE = $stderr, stderr, $VERBOSE, true
11
+ yield stderr
12
+ return $stderr
13
+ ensure
14
+ stderr, $stderr, $VERBOSE = $stderr, stderr, verbose
15
+ end
16
+ module_function :verbose_warning
17
+
18
+ def with_default_internal(enc)
19
+ verbose, $VERBOSE = $VERBOSE, nil
20
+ origenc, Encoding.default_internal = Encoding.default_internal, enc
21
+ $VERBOSE = verbose
22
+ yield
23
+ ensure
24
+ verbose, $VERBOSE = $VERBOSE, nil
25
+ Encoding.default_internal = origenc
26
+ $VERBOSE = verbose
27
+ end
28
+ module_function :with_default_internal
29
+ end
30
+
31
+ def assert_warning(pat, msg = nil)
32
+ stderr = EnvUtil.verbose_warning {
33
+ EnvUtil.with_default_internal(pat.encoding) {
34
+ yield
35
+ }
36
+ }
37
+ msg = message(msg) {diff pat, stderr}
38
+ assert(pat === stderr, msg)
39
+ end
40
+
41
+ def test_warning_ignore
42
+ obj = Object.new
43
+ w = nil
44
+
45
+ Warning.ignore(/instance variable @ivar not initialized/)
46
+ Warning.process do |warning|
47
+ w = [4, warning]
48
+ end
49
+ Warning.freeze
50
+
51
+ assert_raises RuntimeError do
52
+ Warning.ignore(/instance variable @ivar not initialized/)
53
+ end
54
+ assert_raises RuntimeError do
55
+ Warning.process{|warning| w = [4, warning]}
56
+ end
57
+
58
+ assert_warning '' do
59
+ assert_nil(obj.instance_variable_get(:@ivar))
60
+ end
61
+ assert_nil w
62
+
63
+ assert_warning '' do
64
+ assert_nil(obj.instance_variable_get(:@ivar6))
65
+ end
66
+ assert_equal(4, w.first)
67
+ assert_match(/instance variable @ivar6 not initialized/, w.last)
68
+ end
69
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-16 00:00:00.000000000 Z
11
+ date: 2017-11-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  ruby-warning adds custom processing for warnings, including the
@@ -28,6 +28,7 @@ files:
28
28
  - README.rdoc
29
29
  - Rakefile
30
30
  - lib/warning.rb
31
+ - test/test_freeze_warning.rb
31
32
  - test/test_warning.rb
32
33
  homepage: https://github.com/jeremyevans/ruby-warning
33
34
  licenses:
@@ -56,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
57
  version: '0'
57
58
  requirements: []
58
59
  rubyforge_project:
59
- rubygems_version: 2.6.8
60
+ rubygems_version: 2.6.13
60
61
  signing_key:
61
62
  specification_version: 4
62
63
  summary: Add custom processing for warnings