test-unit 3.0.7 → 3.0.8

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: f581555a5f5e042d125194d870c79a4e8fd4c78e
4
- data.tar.gz: a35bda12604b51db52009764c5439e657c3964a7
3
+ metadata.gz: 93a1e018c9d985f96f57f4a1cb7c166ac584d4d7
4
+ data.tar.gz: 90fc5bcea7299d0fe43153e2eb6a447e9b3823f2
5
5
  SHA512:
6
- metadata.gz: 90dd03711e6fe149f451de04c211ec5248a63cb8915a551444920f4b5f0a06f361af028613ac178f05b7f268461d06a3b465b90bf9cd62d51d368aa45deded4c
7
- data.tar.gz: bfc59126ae597c329b5819a91556ce55710bba21f2a443838f596fe31d4f6366715a2eb533abcbd8c4e7ca016046d9ac04c12d8b53953241a359da7303ddd3e6
6
+ metadata.gz: 22541bbd0a7fe30eb6227f6498e1af4316d749f2f766da3f9266562c9d39ac3f7650ea7e1764b05ec43b150019e8e073045f4a876a7f9ac305cffeb197cc5a79
7
+ data.tar.gz: bd5da3acef525e1c3f3539dd09a5509fa531c3be20c15567e955ce79573f57cbe7467cc143e25e9bcaf5dbe83a6289ad084262ccec99ff7cba18351a2be7553d
data/README.md CHANGED
@@ -34,7 +34,8 @@ writing tests, checking results and automated testing in Ruby.
34
34
 
35
35
  ## How To
36
36
 
37
- * [doc/text/how-to.md](doc/text/how-to.md)
37
+ * [How To](doc/text/how-to.md) (link for GitHub)
38
+ * {file:doc/text/how-to.md How To} (link for YARD)
38
39
 
39
40
  ## Install
40
41
 
@@ -1,5 +1,29 @@
1
1
  # News
2
2
 
3
+ ## 3.0.8 - 2014-12-12 {#version-3-0-8}
4
+
5
+ It's a release that support Ruby 2.2.0 preview2.
6
+
7
+ ### Improvements
8
+
9
+ * Added a link for YARD in README.
10
+ [GitHub:test-unit.github.io#2][Reported by sunnyone]
11
+ * Added description about "/PATTERN/" style value in auto runner usage.
12
+ [GitHub#86][Suggested by sunnyone]
13
+ * Supported Ruby 2.2.0 preview2 in `assert_throw` and
14
+ `assert_nothing_thrown`.
15
+
16
+ ### Fixes
17
+
18
+ * Fixed a bug that error report is failed when source encoding and
19
+ locale encoding are different.
20
+ [GitHub#87][Reported by scivola]
21
+
22
+ ### Thanks
23
+
24
+ * sunnyone
25
+ * scivola
26
+
3
27
  ## 3.0.7 - 2014-11-14 {#version-3-0-7}
4
28
 
5
29
  It's a minor update release.
@@ -739,11 +739,47 @@ EOT
739
739
  end
740
740
 
741
741
  # @private
742
- UncaughtThrow = {
743
- NameError => /^uncaught throw `(.+)'$/,
744
- ArgumentError => /^uncaught throw (`.+'|.+)$/,
745
- ThreadError => /^uncaught throw `(.+)' in thread /,
746
- }
742
+ class ThrowTagExtractor
743
+ @@have_uncaught_throw_error = const_defined?(:UncaughtThrowError)
744
+
745
+ UncaughtThrowPatterns = {
746
+ NameError => /^uncaught throw `(.+)'$/,
747
+ ArgumentError => /^uncaught throw (`.+'|.+)$/,
748
+ ThreadError => /^uncaught throw `(.+)' in thread /,
749
+ }
750
+
751
+ def initialize(error)
752
+ @error = error
753
+ end
754
+
755
+ def extract_tag
756
+ tag = nil
757
+ if @@have_uncaught_throw_error
758
+ return nil unless @error.is_a?(UncaughtThrowError)
759
+ tag = @error.tag
760
+ else
761
+ pattern = UncaughtThrowPatterns[@error.class]
762
+ return nil if pattern.nil?
763
+ return nil unless pattern =~ @error.message
764
+ tag = $1
765
+ end
766
+ normalize_tag(tag)
767
+ end
768
+
769
+ private
770
+ def normalize_tag(tag)
771
+ case tag
772
+ when /\A:/
773
+ tag[1..-1].intern
774
+ when /\A`(.+)'\z/
775
+ $1.intern
776
+ when String
777
+ tag.intern
778
+ else
779
+ tag
780
+ end
781
+ end
782
+ end
747
783
 
748
784
  ##
749
785
  # Passes if the block throws +expected_object+
@@ -773,9 +809,10 @@ EOT
773
809
  "<?> should have been thrown.",
774
810
  expected_object)
775
811
  assert_block(full_message) {caught}
776
- rescue NameError, ArgumentError, ThreadError => error
777
- raise unless UncaughtThrow[error.class] =~ error.message
778
- tag = AssertionMessage.normalize_tag($1)
812
+ rescue => error
813
+ extractor = ThrowTagExtractor.new(error)
814
+ tag = extractor.extract_tag
815
+ raise if tag.nil?
779
816
  full_message = build_message(message,
780
817
  "<?> expected to be thrown but\n" +
781
818
  "<?> was thrown.",
@@ -802,9 +839,10 @@ EOT
802
839
  assert(block_given?, "Should have passed a block to assert_nothing_thrown")
803
840
  begin
804
841
  proc.call
805
- rescue NameError, ArgumentError, ThreadError => error
806
- raise unless UncaughtThrow[error.class] =~ error.message
807
- tag = AssertionMessage.normalize_tag($1)
842
+ rescue => error
843
+ extractor = ThrowTagExtractor.new(error)
844
+ tag = extractor.extract_tag
845
+ raise if tag.nil?
808
846
  full_message = build_message(message,
809
847
  "<?> was thrown when nothing was expected",
810
848
  tag)
@@ -1671,19 +1709,6 @@ EOT
1671
1709
  MaybeContainer.new(value, &formatter)
1672
1710
  end
1673
1711
 
1674
- def normalize_tag(tag)
1675
- case tag
1676
- when /\A:/
1677
- tag[1..-1].intern
1678
- when /\A`(.+)'\z/
1679
- $1.intern
1680
- when String
1681
- tag.intern
1682
- else
1683
- tag
1684
- end
1685
- end
1686
-
1687
1712
  MAX_DIFF_TARGET_STRING_SIZE = 1000
1688
1713
  def max_diff_target_string_size
1689
1714
  return @@max_diff_target_string_size if @@max_diff_target_string_size
@@ -212,7 +212,7 @@ module Test
212
212
 
213
213
  o.on('-n', '--name=NAME', String,
214
214
  "Runs tests matching NAME.",
215
- "(patterns may be used).") do |name|
215
+ "Use '/PATTERN/' for NAME to use regular expression.") do |name|
216
216
  name = (%r{\A/(.*)/\Z} =~ name ? Regexp.new($1) : name)
217
217
  @filters << lambda do |test|
218
218
  return true if name === test.method_name
@@ -226,7 +226,7 @@ module Test
226
226
 
227
227
  o.on('--ignore-name=NAME', String,
228
228
  "Ignores tests matching NAME.",
229
- "(patterns may be used).") do |n|
229
+ "Use '/PATTERN/' for NAME to use regular expression.") do |n|
230
230
  n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
231
231
  case n
232
232
  when Regexp
@@ -238,7 +238,7 @@ module Test
238
238
 
239
239
  o.on('-t', '--testcase=TESTCASE', String,
240
240
  "Runs tests in TestCases matching TESTCASE.",
241
- "(patterns may be used).") do |n|
241
+ "Use '/PATTERN/' for TESTCASE to use regular expression.") do |n|
242
242
  n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
243
243
  @filters << lambda do |test|
244
244
  match_test_case_name(test, n)
@@ -247,7 +247,7 @@ module Test
247
247
 
248
248
  o.on('--ignore-testcase=TESTCASE', String,
249
249
  "Ignores tests in TestCases matching TESTCASE.",
250
- "(patterns may be used).") do |n|
250
+ "Use '/PATTERN/' for TESTCASE to use regular expression.") do |n|
251
251
  n = (%r{\A/(.*)/\Z} =~ n ? Regexp.new($1) : n)
252
252
  @filters << lambda do |test|
253
253
  not match_test_case_name(test, n)
@@ -5,9 +5,9 @@ module Test
5
5
  @sources = {}
6
6
  end
7
7
 
8
- def fetch(file, line, options={})
8
+ def fetch(path, line, options={})
9
9
  n_context_line = options[:n_context_line] || 3
10
- lines = source(file)
10
+ lines = source(path)
11
11
  return [] if lines.nil?
12
12
  min_line = [line - n_context_line, 1].max
13
13
  max_line = [line + n_context_line, lines.length].min
@@ -18,14 +18,39 @@ module Test
18
18
  end
19
19
  end
20
20
 
21
- def source(file)
22
- @sources[file] ||= read_source(file)
21
+ def source(path)
22
+ @sources[path] ||= read_source(path)
23
23
  end
24
24
 
25
25
  private
26
- def read_source(file)
27
- return nil unless File.exist?(file)
28
- File.readlines(file)
26
+ def read_source(path)
27
+ return nil unless File.exist?(path)
28
+ lines = []
29
+ File.open(path) do |file|
30
+ first_line = file.gets
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)
36
+ end
37
+ lines << first_line
38
+ lines.concat(file.readlines)
39
+ end
40
+ lines
41
+ end
42
+
43
+ def detect_encoding(first_line)
44
+ return nil unless first_line.ascii_only?
45
+ if /\b(?:en)?coding[:=]\s*([a-z\d_-]+)/i =~ first_line
46
+ begin
47
+ Encoding.find($1)
48
+ rescue ArgumentError
49
+ nil
50
+ end
51
+ else
52
+ nil
53
+ end
29
54
  end
30
55
  end
31
56
  end
@@ -1,5 +1,5 @@
1
1
  module Test
2
2
  module Unit
3
- VERSION = '3.0.7'
3
+ VERSION = '3.0.8'
4
4
  end
5
5
  end
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.0.7
4
+ version: 3.0.8
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: 2014-11-14 00:00:00.000000000 Z
12
+ date: 2014-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: power_assert
@@ -234,44 +234,44 @@ signing_key:
234
234
  specification_version: 4
235
235
  summary: An xUnit family unit testing framework for Ruby.
236
236
  test_files:
237
- - test/test-test-case.rb
238
237
  - test/test-assertions.rb
238
+ - test/test-color.rb
239
239
  - test/test-code-snippet.rb
240
240
  - test/test-test-suite-creator.rb
241
- - test/test-fault-location-detector.rb
242
- - test/test-omission.rb
243
241
  - test/test-test-result.rb
244
- - test/collector/test-descendant.rb
245
- - test/collector/test_dir.rb
246
- - test/collector/test-load.rb
247
- - test/collector/test_objectspace.rb
248
- - test/test-color.rb
249
- - test/test-attribute-matcher.rb
250
242
  - test/test-error.rb
251
- - test/test-diff.rb
243
+ - test/test-failure.rb
244
+ - test/run-test.rb
252
245
  - test/test-pending.rb
253
- - test/test-emacs-runner.rb
254
- - test/util/test_backtracefilter.rb
255
- - test/util/test_procwrapper.rb
246
+ - test/test-color-scheme.rb
247
+ - test/test-attribute-matcher.rb
248
+ - test/testunit-test-util.rb
249
+ - test/test-data.rb
250
+ - test/ui/test_testrunmediator.rb
251
+ - test/util/test-method-owner-finder.rb
256
252
  - test/util/test-output.rb
257
253
  - test/util/test_observable.rb
258
- - test/util/test-method-owner-finder.rb
259
- - test/test-data.rb
260
- - test/fixtures/no-header.tsv
261
- - test/fixtures/header-label.csv
254
+ - test/util/test_backtracefilter.rb
255
+ - test/util/test_procwrapper.rb
256
+ - test/test-omission.rb
257
+ - test/test-test-case.rb
258
+ - test/test-fixture.rb
262
259
  - test/fixtures/no-header.csv
263
260
  - test/fixtures/header-label.tsv
264
261
  - test/fixtures/plus.csv
262
+ - test/fixtures/no-header.tsv
263
+ - test/fixtures/header-label.csv
265
264
  - test/fixtures/header.csv
266
265
  - test/fixtures/header.tsv
267
- - test/test-test-suite.rb
268
- - test/test-color-scheme.rb
266
+ - test/collector/test-descendant.rb
267
+ - test/collector/test_objectspace.rb
268
+ - test/collector/test-load.rb
269
+ - test/collector/test_dir.rb
269
270
  - test/test-priority.rb
271
+ - test/test-test-suite.rb
272
+ - test/test-diff.rb
273
+ - test/test-emacs-runner.rb
270
274
  - test/test-attribute.rb
271
- - test/run-test.rb
272
- - test/test-fixture.rb
275
+ - test/test-fault-location-detector.rb
273
276
  - test/test-notification.rb
274
- - test/test-failure.rb
275
- - test/testunit-test-util.rb
276
- - test/ui/test_testrunmediator.rb
277
277
  has_rdoc: