test-unit 3.3.3 → 3.3.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,8 +47,6 @@ module Test
47
47
  @progress_row_max ||= guess_progress_row_max
48
48
  @show_detail_immediately = @options[:show_detail_immediately]
49
49
  @show_detail_immediately = true if @show_detail_immediately.nil?
50
- @reverse_output = @options[:reverse_output]
51
- @reverse_output = @output.tty? if @reverse_output.nil?
52
50
  @already_outputted = false
53
51
  @indent = 0
54
52
  @top_level = true
@@ -184,29 +182,15 @@ module Test
184
182
  if fault.is_a?(Failure) and
185
183
  fault.inspected_expected and
186
184
  fault.inspected_actual
187
- if @reverse_output
188
- output_fault_backtrace(fault)
189
- output_failure_message(fault)
190
- output_single("#{fault.label}: ")
191
- output(fault.test_name, fault_color(fault))
192
- else
193
- output_single("#{fault.label}: ")
194
- output(fault.test_name, fault_color(fault))
195
- output_fault_backtrace(fault)
196
- output_failure_message(fault)
197
- end
185
+ output_single("#{fault.label}: ")
186
+ output(fault.test_name, fault_color(fault))
187
+ output_fault_backtrace(fault)
188
+ output_failure_message(fault)
198
189
  else
199
- if @reverse_output
200
- output_fault_backtrace(fault)
201
- output_single("#{fault.label}: ")
202
- output_single(fault.test_name, fault_color(fault))
203
- output_fault_message(fault)
204
- else
205
- output_single("#{fault.label}: ")
206
- output_single(fault.test_name, fault_color(fault))
207
- output_fault_message(fault)
208
- output_fault_backtrace(fault)
209
- end
190
+ output_single("#{fault.label}: ")
191
+ output_single(fault.test_name, fault_color(fault))
192
+ output_fault_message(fault)
193
+ output_fault_backtrace(fault)
210
194
  end
211
195
  end
212
196
 
@@ -244,19 +228,10 @@ module Test
244
228
  end
245
229
  end
246
230
 
247
- if @reverse_output
248
- backtrace.each_with_index.reverse_each do |entry, i|
249
- if i == code_snippet_backtrace_index
250
- output_code_snippet(code_snippet_lines, fault_color(fault))
251
- end
252
- output(entry)
253
- end
254
- else
255
- backtrace.each_with_index do |entry, i|
256
- output(entry)
257
- if i == code_snippet_backtrace_index
258
- output_code_snippet(code_snippet_lines, fault_color(fault))
259
- end
231
+ backtrace.each_with_index do |entry, i|
232
+ output(entry)
233
+ if i == code_snippet_backtrace_index
234
+ output_code_snippet(code_snippet_lines, fault_color(fault))
260
235
  end
261
236
  end
262
237
  end
@@ -336,17 +311,10 @@ module Test
336
311
  end
337
312
 
338
313
  def output_fault_in_short(fault)
339
- if @reverse_output
340
- output(fault.location.first)
341
- output_single("#{fault.label}: ")
342
- output_single(fault.message, fault_color(fault))
343
- output(" [#{fault.test_name}]")
344
- else
345
- output_single("#{fault.label}: ")
346
- output_single(fault.message, fault_color(fault))
347
- output(" [#{fault.test_name}]")
348
- output(fault.location.first)
349
- end
314
+ output_single("#{fault.label}: ")
315
+ output_single(fault.message, fault_color(fault))
316
+ output(" [#{fault.test_name}]")
317
+ output(fault.location.first)
350
318
  end
351
319
 
352
320
  def format_fault(fault)
@@ -540,13 +508,28 @@ module Test
540
508
  color("#{@result.status}-marker")
541
509
  end
542
510
 
511
+ TERM_COLOR_SUPPORT = /
512
+ color| # explicitly claims color support in the name
513
+ direct| # explicitly claims "direct color" (24 bit) support
514
+ #{ColorScheme::TERM_256}|
515
+ \Acygwin|
516
+ \Alinux|
517
+ \Ansterm-bce|
518
+ \Ansterm-c-|
519
+ \Aputty|
520
+ \Arxvt|
521
+ \Ascreen|
522
+ \Atmux|
523
+ \Axterm
524
+ /x
525
+
543
526
  def guess_color_availability
544
527
  return false unless @output.tty?
545
528
  return true if windows? and ruby_2_0_or_later?
546
529
  case ENV["TERM"]
547
530
  when /(?:term|screen)(?:-(?:256)?color)?\z/
548
531
  true
549
- when /\Arxvt/
532
+ when TERM_COLOR_SUPPORT
550
533
  true
551
534
  else
552
535
  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.3"
3
+ VERSION = "3.3.8"
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
@@ -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.3
4
+ version: 3.3.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: 2019-05-10 00:00:00.000000000 Z
12
+ date: 2020-12-24 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