test-unit 3.2.9 → 3.3.0

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: eebbbc103686122dad1c46de5d2cf1b481c072594dcaf0ec7e2b8b3b06f40845
4
- data.tar.gz: be70b1db775b562d54aa4e24fec9fbc607f13604850dde5064232163dc6c2992
3
+ metadata.gz: c6d7db2480ed758082e59182df3607410a66eb81c5c3433b3dd76bd1cf31e5f3
4
+ data.tar.gz: e25d8749320d74cef4eb57f44acee0d7797bab72568e1e3cdf9b23249b1ebf97
5
5
  SHA512:
6
- metadata.gz: f55eac7e767c89b5434d6ff8f19824a2509d0e6d25e48d2494df30dd9178b7e231063c95ba3399806e0e0bd98b0de947f2b35522a1e2867246eca7420e3e5aec
7
- data.tar.gz: bd1e47fbd0ddb58908b9b95df05d95960ccf90aa7b89a4ff93ec5de979f01af75b3662dd746be20e6bc9dc2ef1780aa77448a769124dd305109fbb2020ee0df5
6
+ metadata.gz: 4b18901db0bab8ecfbba34de97e02163598b729e6be44a176ebfb1b06586e7f9079fe674f18275e2c06dfedea024a88bb06596040b250bfa6f5d2ae40e99c181
7
+ data.tar.gz: 1a6ebdaeebe74f649aa06f94e205d216300aeb018f762b2082382cbef405e5482a03a8095b2b3b86210ad6379bce8ba481b7fd25dec60a15b8206340c18b45a8
@@ -1,5 +1,35 @@
1
1
  # News
2
2
 
3
+ ## 3.3.0 - 2019-01-23 {#version-3-3-0}
4
+
5
+ ### Improvements
6
+
7
+ * Added support for auto test run when all tests are defined in
8
+ modules.
9
+
10
+ * Added support for defining methods to test case class in multiple
11
+ threads.
12
+ [GitHub#159][Reported by Charles Oliver Nutter]
13
+
14
+ * Suppressed warnings on Ruby 2.5.
15
+ [GitHub#160][Reported by Daniel Berger]
16
+
17
+ * Suppressed warnings on Ruby 2.7.
18
+
19
+ ### Fixes
20
+
21
+ * Fixed a code snippet fetch failure when source code isn't UTF-8
22
+ and the default external encoding is set to not UTF-8.
23
+ [GitHub#161][Reported by masa kunikata]
24
+
25
+ ### Thanks
26
+
27
+ * Charles Oliver Nutter
28
+
29
+ * Daniel Berger
30
+
31
+ * masa kunikata
32
+
3
33
  ## 3.2.9 - 2018-12-01 {#version-3-2-9}
4
34
 
5
35
  ### Improvements
@@ -204,7 +204,8 @@ module Test
204
204
  end
205
205
 
206
206
  @@attribute_observers = StringifyKeyHash.new
207
- def register_attribute_observer(attribute_name, observer=Proc.new)
207
+ def register_attribute_observer(attribute_name, observer=nil, &block)
208
+ observer ||= Proc.new(&block)
208
209
  @@attribute_observers[attribute_name] ||= []
209
210
  @@attribute_observers[attribute_name] << observer
210
211
  end
@@ -15,7 +15,8 @@ module Test
15
15
  PREPARE_HOOKS = []
16
16
 
17
17
  class << self
18
- def register_runner(id, runner_builder=Proc.new)
18
+ def register_runner(id, runner_builder=nil, &block)
19
+ runner_builder ||= Proc.new(&block)
19
20
  RUNNERS[id] = runner_builder
20
21
  RUNNERS[id.to_s] = runner_builder
21
22
  end
@@ -33,7 +34,8 @@ module Test
33
34
  @@default_runner = id
34
35
  end
35
36
 
36
- def register_collector(id, collector_builder=Proc.new)
37
+ def register_collector(id, collector_builder=nil, &block)
38
+ collector_builder ||= Proc.new(&block)
37
39
  COLLECTORS[id] = collector_builder
38
40
  COLLECTORS[id.to_s] = collector_builder
39
41
  end
@@ -46,11 +48,13 @@ module Test
46
48
  ColorScheme[id] = scheme
47
49
  end
48
50
 
49
- def setup_option(option_builder=Proc.new)
51
+ def setup_option(option_builder=nil, &block)
52
+ option_builder ||= Proc.new(&block)
50
53
  ADDITIONAL_OPTIONS << option_builder
51
54
  end
52
55
 
53
- def prepare(hook=Proc.new)
56
+ def prepare(hook=nil, &block)
57
+ hook ||= Proc.new(&block)
54
58
  PREPARE_HOOKS << hook
55
59
  end
56
60
 
@@ -26,14 +26,12 @@ module Test
26
26
  def read_source(path)
27
27
  return nil unless File.exist?(path)
28
28
  lines = []
29
- File.open(path) do |file|
29
+ File.open(path, "rb") do |file|
30
30
  first_line = file.gets
31
31
  break if first_line.nil?
32
- encoding = detect_encoding(first_line)
33
- if encoding
34
- first_line.force_encoding(encoding)
35
- file.set_encoding(encoding, encoding)
36
- end
32
+ encoding = detect_encoding(first_line) || Encoding::UTF_8
33
+ first_line.force_encoding(encoding)
34
+ file.set_encoding(encoding)
37
35
  lines << first_line
38
36
  lines.concat(file.readlines)
39
37
  end
@@ -83,8 +83,8 @@ module Test
83
83
  grouped_variables = variables.group_by do |_, options|
84
84
  options[:group]
85
85
  end
86
- grouped_variables.each do |group, variables|
87
- each_raw_pattern(variables) do |cell|
86
+ grouped_variables.each do |group, group_variables|
87
+ each_raw_pattern(group_variables) do |cell|
88
88
  label = String.new
89
89
  label << "group: #{group.inspect}" unless group.nil?
90
90
  data = {}
@@ -130,6 +130,15 @@ module Test
130
130
  super
131
131
  end
132
132
 
133
+ def include(*modules, &block) # :nodoc:
134
+ super
135
+ modules.each do |mod|
136
+ mod.public_instance_methods(false).each do |method_name|
137
+ AutoRunnerLoader.check(self, method_name.to_s)
138
+ end
139
+ end
140
+ end
141
+
133
142
  @@added_method_names = {}
134
143
  def method_added(name) # :nodoc:
135
144
  super
@@ -150,11 +159,12 @@ module Test
150
159
  path, line, = caller[0].split(/:(\d+)/, 2)
151
160
  line = line.to_i if line
152
161
  end
153
- method_locations << {
162
+ location = {
154
163
  :method_name => stringified_name,
155
164
  :path => File.expand_path(path),
156
165
  :line => line,
157
166
  }
167
+ add_method_location(location)
158
168
  added_method_names[stringified_name] = true
159
169
  AutoRunnerLoader.check(self, stringified_name)
160
170
  end
@@ -426,31 +436,43 @@ module Test
426
436
  private
427
437
  # @private
428
438
  @@method_locations = {}
439
+ # @private
440
+ @@method_location_mutex = Mutex.new
441
+
429
442
  # @private
430
443
  def method_locations
431
444
  @@method_locations[self] ||= []
432
445
  end
433
446
 
434
447
  # @private
435
- def target_method_locations(path)
436
- if path.nil?
437
- self_location = method_locations.first
438
- path = self_location[:path] if self_location
448
+ def add_method_location(location)
449
+ @@method_location_mutex.synchronize do
450
+ method_locations << location
439
451
  end
440
- return [] if path.nil?
441
-
442
- target_locations = []
443
- @@method_locations.each do |test_case, locations|
444
- locations.each do |location|
445
- absolete_path = File.expand_path(path)
446
- location_path = location[:path]
447
- location_basename = File.basename(location_path)
448
- if location_path == absolete_path or location_basename == path
449
- target_locations << location.merge(:test_case => test_case)
452
+ end
453
+
454
+ # @private
455
+ def target_method_locations(path)
456
+ @@method_location_mutex.synchronize do
457
+ if path.nil?
458
+ self_location = method_locations.first
459
+ path = self_location[:path] if self_location
460
+ end
461
+ return [] if path.nil?
462
+
463
+ target_locations = []
464
+ @@method_locations.each do |test_case, locations|
465
+ locations.each do |location|
466
+ absolete_path = File.expand_path(path)
467
+ location_path = location[:path]
468
+ location_basename = File.basename(location_path)
469
+ if location_path == absolete_path or location_basename == path
470
+ target_locations << location.merge(:test_case => test_case)
471
+ end
450
472
  end
451
473
  end
474
+ target_locations
452
475
  end
453
- target_locations
454
476
  end
455
477
  end
456
478
 
@@ -1,5 +1,5 @@
1
1
  module Test
2
2
  module Unit
3
- VERSION = "3.2.9"
3
+ VERSION = "3.3.0"
4
4
  end
5
5
  end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require "test-unit"
2
4
  require "testunit-test-util"
3
5
 
@@ -34,4 +36,44 @@ class TestCodeSnippet < Test::Unit::TestCase
34
36
  end
35
37
  end
36
38
  end
39
+
40
+ class TestDefaultExternal < self
41
+ def suppress_warning
42
+ verbose = $VERBOSE
43
+ begin
44
+ $VERBOSE = false
45
+ yield
46
+ ensure
47
+ $VERBOSE = verbose
48
+ end
49
+ end
50
+
51
+ def setup
52
+ suppress_warning do
53
+ @default_external = Encoding.default_external
54
+ end
55
+ @fetcher = Test::Unit::CodeSnippetFetcher.new
56
+ end
57
+
58
+ def teardown
59
+ suppress_warning do
60
+ Encoding.default_external = @default_external
61
+ end
62
+ end
63
+
64
+ def test_windows_31j
65
+ source = Tempfile.new(["test-code-snippet", ".rb"])
66
+ source.puts(<<-SOURCE)
67
+ puts("あいうえお")
68
+ SOURCE
69
+ source.flush
70
+ suppress_warning do
71
+ Encoding.default_external = "Windows-31J"
72
+ end
73
+ assert_equal([
74
+ [1, "puts(\"あいうえお\")", {:target_line? => false}],
75
+ ],
76
+ @fetcher.fetch(source.path, 0))
77
+ end
78
+ end
37
79
  end
@@ -1,3 +1,5 @@
1
+ require "tempfile"
2
+
1
3
  module TestUnitTestUtil
2
4
  private
3
5
  def jruby?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.9
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-12-01 00:00:00.000000000 Z
12
+ date: 2019-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: power_assert
@@ -231,49 +231,48 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
231
  - !ruby/object:Gem::Version
232
232
  version: '0'
233
233
  requirements: []
234
- rubyforge_project:
235
- rubygems_version: 3.0.0.beta2
234
+ rubygems_version: 3.0.2
236
235
  signing_key:
237
236
  specification_version: 4
238
237
  summary: An xUnit family unit testing framework for Ruby.
239
238
  test_files:
240
- - test/test-code-snippet.rb
241
- - test/test-fault-location-detector.rb
242
- - test/test-attribute.rb
239
+ - test/run-test.rb
240
+ - test/testunit-test-util.rb
243
241
  - test/test-priority.rb
244
- - test/test-color-scheme.rb
245
- - test/test-failure.rb
246
- - test/test-color.rb
247
- - test/ui/test_testrunmediator.rb
248
- - test/test-attribute-matcher.rb
249
242
  - test/test-test-suite.rb
243
+ - test/test-error.rb
244
+ - test/test-notification.rb
245
+ - test/test-fault-location-detector.rb
250
246
  - test/test-test-suite-creator.rb
251
- - test/test-diff.rb
252
- - test/test-emacs-runner.rb
253
247
  - test/test-data.rb
254
- - test/fixtures/header.csv
248
+ - test/util/test-output.rb
249
+ - test/util/test_backtracefilter.rb
250
+ - test/util/test_procwrapper.rb
251
+ - test/util/test_observable.rb
252
+ - test/util/test-method-owner-finder.rb
253
+ - test/test-failure.rb
254
+ - test/test-pending.rb
255
+ - test/test-test-case.rb
256
+ - test/test-attribute-matcher.rb
257
+ - test/test-omission.rb
258
+ - test/test-color.rb
259
+ - test/ui/test_testrunmediator.rb
260
+ - test/test-fixture.rb
261
+ - test/test-attribute.rb
262
+ - test/test-code-snippet.rb
263
+ - test/collector/test_objectspace.rb
264
+ - test/collector/test-load.rb
265
+ - test/collector/test-descendant.rb
266
+ - test/collector/test_dir.rb
267
+ - test/test-color-scheme.rb
268
+ - test/test-assertions.rb
269
+ - test/fixtures/plus.csv
270
+ - test/fixtures/header-label.csv
255
271
  - test/fixtures/header.tsv
256
272
  - test/fixtures/no-header.tsv
257
- - test/fixtures/plus.csv
258
- - test/fixtures/no-header.csv
273
+ - test/fixtures/header.csv
259
274
  - test/fixtures/header-label.tsv
260
- - test/fixtures/header-label.csv
261
- - test/test-assertions.rb
275
+ - test/fixtures/no-header.csv
276
+ - test/test-emacs-runner.rb
262
277
  - test/test-test-result.rb
263
- - test/testunit-test-util.rb
264
- - test/collector/test-load.rb
265
- - test/collector/test_dir.rb
266
- - test/collector/test_objectspace.rb
267
- - test/collector/test-descendant.rb
268
- - test/test-error.rb
269
- - test/run-test.rb
270
- - test/test-pending.rb
271
- - test/test-fixture.rb
272
- - test/util/test-output.rb
273
- - test/util/test-method-owner-finder.rb
274
- - test/util/test_observable.rb
275
- - test/util/test_procwrapper.rb
276
- - test/util/test_backtracefilter.rb
277
- - test/test-notification.rb
278
- - test/test-omission.rb
279
- - test/test-test-case.rb
278
+ - test/test-diff.rb