test-unit 3.3.2 → 3.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -540,13 +540,28 @@ module Test
540
540
  color("#{@result.status}-marker")
541
541
  end
542
542
 
543
+ TERM_COLOR_SUPPORT = /
544
+ color| # explicitly claims color support in the name
545
+ direct| # explicitly claims "direct color" (24 bit) support
546
+ #{ColorScheme::TERM_256}|
547
+ \Acygwin|
548
+ \Alinux|
549
+ \Ansterm-bce|
550
+ \Ansterm-c-|
551
+ \Aputty|
552
+ \Arxvt|
553
+ \Ascreen|
554
+ \Atmux|
555
+ \Axterm
556
+ /x
557
+
543
558
  def guess_color_availability
544
559
  return false unless @output.tty?
545
560
  return true if windows? and ruby_2_0_or_later?
546
561
  case ENV["TERM"]
547
562
  when /(?:term|screen)(?:-(?:256)?color)?\z/
548
563
  true
549
- when /\Arxvt/
564
+ when TERM_COLOR_SUPPORT
550
565
  true
551
566
  else
552
567
  return true if ENV["EMACS"] == "t"
@@ -26,8 +26,8 @@ module Test
26
26
  # returned, making it very easy to use the proc
27
27
  # itself as the listener_key:
28
28
  #
29
- # listener = add_listener("Channel") { ... }
30
- # remove_listener("Channel", listener)
29
+ # listener = add_listener("Channel") { ... }
30
+ # remove_listener("Channel", listener)
31
31
  def add_listener(channel_name, listener_key=NOTHING, &listener) # :yields: value
32
32
  unless(block_given?)
33
33
  raise ArgumentError.new("No callback was passed as a listener")
@@ -7,10 +7,11 @@ module Test
7
7
  # error as string.
8
8
  #
9
9
  # Example:
10
- # capture_output do
11
- # puts("stdout")
12
- # warn("stderr")
13
- # end # -> ["stdout\n", "stderr\n"]
10
+ #
11
+ # capture_output do
12
+ # puts("stdout")
13
+ # warn("stderr")
14
+ # end # -> ["stdout\n", "stderr\n"]
14
15
  def capture_output
15
16
  require 'stringio'
16
17
 
@@ -1,5 +1,5 @@
1
1
  module Test
2
2
  module Unit
3
- VERSION = "3.3.2"
3
+ VERSION = "3.3.7"
4
4
  end
5
5
  end
@@ -98,7 +98,7 @@ module Test
98
98
 
99
99
  def check_fail_exception(expected_message, options={}, &proc)
100
100
  normalizer = lambda do |actual_message|
101
- actual_message.gsub(/(^[^:\n]+:\d+:.+\n?)+\z/, "")
101
+ actual_message.gsub(/^(?:<internal:core> )?[^:\n]+:\d+:.+\n/, "")
102
102
  end
103
103
  check_assertions(true,
104
104
  options.merge(:expected_message => expected_message,
@@ -289,14 +289,19 @@ EOM
289
289
  end
290
290
 
291
291
  def test_same_inspected_objects
292
- now = Time.now
293
- now_without_usec = Time.at(now.to_i)
292
+ same_inspected_class = Class.new do
293
+ def inspect
294
+ "inspected"
295
+ end
296
+ end
297
+ object1 = same_inspected_class.new
298
+ object2 = same_inspected_class.new
294
299
  message = <<-EOM.chomp
295
- <#{now.inspect}> expected but was
296
- <#{now.inspect}>.
300
+ <inspected> expected but was
301
+ <inspected>.
297
302
  EOM
298
303
  check_fail(message) do
299
- assert_equal(now, now_without_usec)
304
+ assert_equal(object1, object2)
300
305
  end
301
306
  end
302
307
 
@@ -505,7 +510,8 @@ EOM
505
510
  message = <<-EOM.chomp
506
511
  failed assert_raise.
507
512
  <ArgumentError> exception expected but was
508
- <RuntimeError(<Error>)>.
513
+ <RuntimeError(<Error>)
514
+ >.
509
515
  EOM
510
516
  check_fail_exception(message) do
511
517
  assert_raise(ArgumentError, "failed assert_raise") do
@@ -566,7 +572,8 @@ EOM
566
572
  message = <<-EOM.chomp
567
573
  failed assert_raise.
568
574
  <[ArgumentError, TypeError]> exception expected but was
569
- <RuntimeError(<Error>)>.
575
+ <RuntimeError(<Error>)
576
+ >.
570
577
  EOM
571
578
  check_fail_exception(message) do
572
579
  assert_raise(ArgumentError, TypeError, "failed assert_raise") do
@@ -591,13 +598,8 @@ EOM
591
598
 
592
599
  message = <<-EOM.chomp
593
600
  <RuntimeError(<XXX>)> exception expected but was
594
- <RuntimeError(<Error>)>.
595
-
596
- diff:
597
- - RuntimeError(<XXX>)
598
- ? ^^^
599
- + RuntimeError(<Error>)
600
- ? ^^^^^
601
+ <RuntimeError(<Error>)
602
+ >.
601
603
  EOM
602
604
  check_fail_exception(message) do
603
605
  return_value = assert_raise(RuntimeError.new("XXX")) do
@@ -608,7 +610,8 @@ EOM
608
610
  different_error_class = Class.new(StandardError)
609
611
  message = <<-EOM.chomp
610
612
  <#{different_error_class.inspect}(<Error>)> exception expected but was
611
- <RuntimeError(<Error>)>.
613
+ <RuntimeError(<Error>)
614
+ >.
612
615
  EOM
613
616
  check_fail_exception(message) do
614
617
  assert_raise(different_error_class.new("Error")) do
@@ -622,7 +625,8 @@ EOM
622
625
  end
623
626
  message = <<-EOM.chomp
624
627
  <DifferentError: "Error"> exception expected but was
625
- <RuntimeError(<Error>)>.
628
+ <RuntimeError(<Error>)
629
+ >.
626
630
  EOM
627
631
  check_fail_exception(message) do
628
632
  assert_raise(different_error) do
@@ -640,7 +644,7 @@ EOM
640
644
  end
641
645
 
642
646
  def test_assert_raise_jruby
643
- omit("For JRuby") unless Object.const_defined?(:Java)
647
+ jruby_only_test
644
648
 
645
649
  exception = Java::JavaLang::StringIndexOutOfBoundsException
646
650
 
@@ -864,6 +868,7 @@ EOM
864
868
  expected_message = <<-EOM.chomp
865
869
  Exception raised:
866
870
  RuntimeError(<Error>)
871
+
867
872
  EOM
868
873
  check_fail_exception(expected_message) {
869
874
  assert_nothing_raised {
@@ -874,6 +879,7 @@ EOM
874
879
  failed assert_nothing_raised.
875
880
  Exception raised:
876
881
  RuntimeError(<Error>)
882
+
877
883
  EOM
878
884
  check_fail_exception(expected_message) {
879
885
  assert_nothing_raised("failed assert_nothing_raised") {
@@ -883,6 +889,7 @@ EOM
883
889
  expected_message = <<-EOM.chomp
884
890
  Exception raised:
885
891
  RuntimeError(<Error>)
892
+
886
893
  EOM
887
894
  check_fail_exception(expected_message) {
888
895
  assert_nothing_raised(StandardError, RuntimeError) {
@@ -1307,7 +1314,8 @@ EOM
1307
1314
 
1308
1315
  expected_message = <<-EOM.chomp
1309
1316
  <SystemCallError> family exception expected but was
1310
- <RuntimeError(<XXX>)>.
1317
+ <RuntimeError(<XXX>)
1318
+ >.
1311
1319
  EOM
1312
1320
  check_fail_exception(expected_message) do
1313
1321
  assert_raise_kind_of(SystemCallError) do
@@ -41,17 +41,23 @@ class TestUnitColorScheme < Test::Unit::TestCase
41
41
  Test::Unit::Color.new(name, options)
42
42
  end
43
43
 
44
- class TestFor8Colors < self
44
+ module CleanEnvironment
45
45
  def setup
46
46
  @original_term, ENV["TERM"] = ENV["TERM"], nil
47
47
  @original_color_term, ENV["COLORTERM"] = ENV["COLORTERM"], nil
48
+ @original_vte_version, ENV["VTE_VERSION"] = ENV["VTE_VERSION"], nil
48
49
  ENV["TERM"] = "xterm"
49
50
  end
50
51
 
51
52
  def teardown
52
53
  ENV["TERM"] = @original_term
53
54
  ENV["COLORTERM"] = @original_color_term
55
+ ENV["VTE_VERSION"] = @original_vte_version
54
56
  end
57
+ end
58
+
59
+ class TestFor8Colors < self
60
+ include CleanEnvironment
55
61
 
56
62
  def test_default
57
63
  expected_schema_keys = [
@@ -79,4 +85,39 @@ class TestUnitColorScheme < Test::Unit::TestCase
79
85
  Test::Unit::ColorScheme.default.to_hash.keys.sort)
80
86
  end
81
87
  end
88
+
89
+ class TestGuessAvailableColors < self
90
+ include CleanEnvironment
91
+ {
92
+ "rxvt" => 8,
93
+ "xterm-color" => 8,
94
+ "alacritty" => 256,
95
+ "iTerm.app" => 256,
96
+ "screen-256color" => 256,
97
+ "screenxterm-256color" => 256,
98
+ "tmux-256color" => 256,
99
+ "vte-256color" => 256,
100
+ "vscode-direct" => 2**24,
101
+ "vte-direct" => 2**24,
102
+ "xterm-direct" => 2**24,
103
+ }.each do |term, colors|
104
+ data("%20s => %8d" % [term, colors], {term: term, colors: colors})
105
+ end
106
+ def test_term_env(data)
107
+ ENV["TERM"] = data[:term]
108
+ assert_equal(data[:colors],
109
+ Test::Unit::ColorScheme.available_colors,
110
+ "Incorrect available_colors for TERM=%s" % [data[:term]])
111
+ end
112
+ end
113
+
114
+ class TestDefaultScheme < self
115
+ include CleanEnvironment
116
+
117
+ def test_direct_color
118
+ ENV["TERM"] = "xterm-direct"
119
+ assert_equal(Test::Unit::ColorScheme.default_for_256_colors,
120
+ Test::Unit::ColorScheme.default)
121
+ end
122
+ end
82
123
  end
@@ -104,7 +104,7 @@ class TestUnitPriority < Test::Unit::TestCase
104
104
 
105
105
  class TestClassName < self
106
106
  def test_colon
107
- assert_escaped_name("Test__Priority", "Test::Priority")
107
+ assert_escaped_name("Test_colon__colon_Priority", "Test::Priority")
108
108
  end
109
109
 
110
110
  def test_space
@@ -119,6 +119,18 @@ class TestUnitPriority < Test::Unit::TestCase
119
119
  assert_escaped_name("test_priority", "test\/priority")
120
120
  end
121
121
 
122
+ def test_question
123
+ assert_escaped_name("#question.predicate", "#question?")
124
+ end
125
+
126
+ def test_exclamation
127
+ assert_escaped_name("#exclamation.destructive", "#exclamation!")
128
+ end
129
+
130
+ def test_equal
131
+ assert_escaped_name("#equal.equal", "#equal=")
132
+ end
133
+
122
134
  def assert_escaped_name(expected, class_name)
123
135
  checker = Checker.new(nil)
124
136
  escaped_class_name = checker.send(:escape_class_name, class_name)
@@ -148,19 +160,18 @@ class TestUnitPriority < Test::Unit::TestCase
148
160
  end
149
161
 
150
162
  def test_question
151
- assert_escaped_name("test_question.predicate", "test_question?")
163
+ assert_escaped_name("test_colon__#question.predicate_case",
164
+ "test: #question? case")
152
165
  end
153
166
 
154
167
  def test_exclamation
155
- assert_escaped_name("test_exclamation.destructive", "test_exclamation!")
168
+ assert_escaped_name("test_colon__#exclamation.destructive_case",
169
+ "test: #exclamation! case")
156
170
  end
157
171
 
158
172
  def test_equal
159
- assert_escaped_name("test_equal.equal", "test_equal=")
160
- end
161
-
162
- def test_colon_and_space
163
- assert_escaped_name("test_colon__have_space", "test: have space")
173
+ assert_escaped_name("test_colon__#equal.equal_case",
174
+ "test: #equal= case")
164
175
  end
165
176
 
166
177
  def assert_escaped_name(expected, test_method_name)
@@ -61,10 +61,15 @@ module Test
61
61
  entry.start_with?("kernel/")
62
62
  end
63
63
 
64
+ def internal_backtrace_entry?(entry)
65
+ entry.start_with?("<internal:")
66
+ end
67
+
64
68
  def normalize_location(location)
65
69
  filtered_location = location.reject do |entry|
66
70
  jruby_backtrace_entry?(entry) or
67
- rubinius_backtrace_entry?(entry)
71
+ rubinius_backtrace_entry?(entry) or
72
+ internal_backtrace_entry?(entry)
68
73
  end
69
74
  filtered_location.collect do |entry|
70
75
  entry.sub(/:\d+:/, ":0:")
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.3.2
4
+ version: 3.3.7
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: 2019-04-10 00:00:00.000000000 Z
12
+ date: 2020-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: power_assert
@@ -107,9 +107,8 @@ executables: []
107
107
  extensions: []
108
108
  extra_rdoc_files: []
109
109
  files:
110
+ - BSDL
110
111
  - COPYING
111
- - GPL
112
- - LGPL
113
112
  - PSFL
114
113
  - README.md
115
114
  - Rakefile
@@ -213,6 +212,7 @@ files:
213
212
  homepage: http://test-unit.github.io/
214
213
  licenses:
215
214
  - Ruby
215
+ - BSDL
216
216
  - PSFL
217
217
  metadata:
218
218
  source_code_uri: https://github.com/test-unit/test-unit
@@ -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: 2.7.6.2
234
+ rubygems_version: 3.2.0.rc.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/util/test_procwrapper.rb
241
- - test/util/test_observable.rb
242
- - test/util/test-output.rb
243
- - test/util/test-method-owner-finder.rb
244
- - test/util/test_backtracefilter.rb
245
- - test/test-diff.rb
246
- - test/test-assertions.rb
247
- - test/testunit-test-util.rb
248
- - test/run-test.rb
249
- - test/test-emacs-runner.rb
250
- - test/test-color.rb
251
- - test/test-pending.rb
252
- - test/test-omission.rb
253
- - test/test-color-scheme.rb
254
- - test/test-test-result.rb
255
- - test/test-test-suite.rb
256
- - test/test-code-snippet.rb
257
- - test/test-test-case.rb
258
- - test/test-failure.rb
259
- - test/fixtures/no-header.csv
239
+ - test/collector/test-descendant.rb
240
+ - test/collector/test-load.rb
241
+ - test/collector/test_dir.rb
242
+ - test/collector/test_objectspace.rb
243
+ - test/fixtures/header-label.csv
260
244
  - test/fixtures/header-label.tsv
261
- - test/fixtures/no-header.tsv
262
245
  - test/fixtures/header.csv
263
- - test/fixtures/header-label.csv
264
- - test/fixtures/plus.csv
265
246
  - test/fixtures/header.tsv
266
- - test/ui/test_testrunmediator.rb
247
+ - test/fixtures/no-header.csv
248
+ - test/fixtures/no-header.tsv
249
+ - test/fixtures/plus.csv
250
+ - test/run-test.rb
251
+ - test/test-assertions.rb
252
+ - test/test-attribute-matcher.rb
253
+ - test/test-attribute.rb
254
+ - test/test-code-snippet.rb
255
+ - test/test-color-scheme.rb
256
+ - test/test-color.rb
257
+ - test/test-data.rb
258
+ - test/test-diff.rb
259
+ - test/test-emacs-runner.rb
260
+ - test/test-error.rb
261
+ - test/test-failure.rb
262
+ - test/test-fault-location-detector.rb
267
263
  - test/test-fixture.rb
264
+ - test/test-notification.rb
265
+ - test/test-omission.rb
266
+ - test/test-pending.rb
268
267
  - test/test-priority.rb
268
+ - test/test-test-case.rb
269
+ - test/test-test-result.rb
269
270
  - test/test-test-suite-creator.rb
270
- - test/test-attribute.rb
271
- - test/test-notification.rb
272
- - test/test-attribute-matcher.rb
273
- - test/test-fault-location-detector.rb
274
- - test/collector/test-descendant.rb
275
- - test/collector/test_objectspace.rb
276
- - test/collector/test-load.rb
277
- - test/collector/test_dir.rb
278
- - test/test-error.rb
279
- - test/test-data.rb
271
+ - test/test-test-suite.rb
272
+ - test/testunit-test-util.rb
273
+ - test/ui/test_testrunmediator.rb
274
+ - test/util/test-method-owner-finder.rb
275
+ - test/util/test-output.rb
276
+ - test/util/test_backtracefilter.rb
277
+ - test/util/test_observable.rb
278
+ - test/util/test_procwrapper.rb