Skip to content

Commit 97fa3dc

Browse files
authored
Merge pull request #536 from ruby/use-test-unit
Switch to use test-unit
2 parents 1a8bee9 + 83ce43e commit 97fa3dc

18 files changed

+129
-87
lines changed

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
with:
1515
ruby-version: '3.0'
1616
- name: Install dependencies
17-
run: gem install minitest -v "5.15.0"
17+
run: gem install test-unit coveralls
1818
- name: Run test
1919
env:
2020
COVERALLS: "yes"

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ jobs:
3232
with:
3333
ruby-version: ${{ matrix.ruby }}
3434
- name: Install dependencies
35-
run: gem install minitest -v "5.15.0"
35+
run: gem install test-unit
3636
- name: Run test
3737
run: ruby -Ilib exe/rake

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source "https://rubygems.org"
33
gemspec
44

55
group :development do
6-
gem "minitest"
6+
gem "test-unit"
77
gem "coveralls"
88
gem "rubocop"
99
end

test/helper.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@
1010
rescue Gem::LoadError
1111
end
1212

13-
gem "minitest", "~> 5"
14-
require "minitest/autorun"
13+
require "test/unit"
1514
require "rake"
1615
require "tmpdir"
1716

1817
require_relative "support/file_creation"
1918
require_relative "support/ruby_runner"
2019
require_relative "support/rakefile_definitions"
2120

22-
class Rake::TestCase < Minitest::Test
21+
class Rake::TestCase < Test::Unit::TestCase
2322
include FileCreation
2423

2524
include Rake::DSL

test/test_rake_application.rb

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_display_exception_details
4848
rescue => ex
4949
end
5050

51-
out, err = capture_io do
51+
out, err = capture_output do
5252
@app.set_default_options # reset trace output IO
5353

5454
@app.display_error_message ex
@@ -72,7 +72,7 @@ def detailed_message(**)
7272
rescue error_class => ex
7373
end
7474

75-
out, err = capture_io do
75+
out, err = capture_output do
7676
@app.set_default_options # reset trace output IO
7777

7878
@app.display_error_message ex
@@ -91,7 +91,7 @@ def test_display_exception_details_bad_encoding
9191
rescue => ex
9292
end
9393

94-
out, err = capture_io do
94+
out, err = capture_output do
9595
@app.set_default_options # reset trace output IO
9696

9797
@app.display_error_message ex
@@ -111,7 +111,7 @@ def test_display_exception_details_cause
111111
end
112112
end
113113

114-
out, err = capture_io do
114+
out, err = capture_output do
115115
@app.set_default_options # reset trace output IO
116116

117117
@app.display_error_message ex
@@ -129,7 +129,7 @@ def test_display_tasks
129129
@app.options.show_task_pattern = //
130130
@app.last_description = "COMMENT"
131131
@app.define_task(Rake::Task, "t")
132-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
132+
out, = capture_output do @app.instance_eval { display_tasks_and_comments } end
133133
assert_match(/^rake t/, out)
134134
assert_match(/# COMMENT/, out)
135135
end
@@ -142,7 +142,7 @@ def test_display_tasks_with_long_comments
142142
@app.last_description = numbers
143143
@app.define_task(Rake::Task, "t")
144144

145-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
145+
out, = capture_output do @app.instance_eval { display_tasks_and_comments } end
146146

147147
assert_match(/^rake t/, out)
148148
assert_match(/# #{numbers[0, 65]}\.\.\./, out)
@@ -156,7 +156,7 @@ def test_display_tasks_with_task_name_wider_than_tty_display
156156
@app.last_description = "something short"
157157
@app.define_task(Rake::Task, task_name)
158158

159-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
159+
out, = capture_output do @app.instance_eval { display_tasks_and_comments } end
160160

161161
# Ensure the entire task name is output and we end up showing no description
162162
assert_match(/rake #{task_name} # .../, out)
@@ -171,7 +171,7 @@ def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comm
171171
@app.last_description = "something short"
172172
@app.define_task(Rake::Task, task_name)
173173

174-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
174+
out, = capture_output do @app.instance_eval { display_tasks_and_comments } end
175175

176176
# Ensure the entire task name is output and we end up showing no description
177177
assert_match(/rake #{task_name} # #{description}/, out)
@@ -183,7 +183,7 @@ def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
183183
@app.tty_output = false
184184
@app.last_description = "1234567890" * 8
185185
@app.define_task(Rake::Task, "t")
186-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
186+
out, = capture_output do @app.instance_eval { display_tasks_and_comments } end
187187
assert_match(/^rake t/, out)
188188
assert_match(/# #{@app.last_description}/, out)
189189
end
@@ -197,7 +197,7 @@ def test_truncating_comments_to_a_non_tty
197197
@app.last_description = numbers
198198
@app.define_task(Rake::Task, "t")
199199

200-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
200+
out, = capture_output do @app.instance_eval { display_tasks_and_comments } end
201201

202202
assert_match(/^rake t/, out)
203203
assert_match(/# #{numbers[0, 65]}\.\.\./, out)
@@ -208,7 +208,7 @@ def test_describe_tasks
208208
@app.options.show_task_pattern = //
209209
@app.last_description = "COMMENT"
210210
@app.define_task(Rake::Task, "t")
211-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
211+
out, = capture_output do @app.instance_eval { display_tasks_and_comments } end
212212
assert_match(/^rake t$/, out)
213213
assert_match(/^ {4}COMMENT$/, out)
214214
end
@@ -219,7 +219,7 @@ def test_show_lines
219219
@app.last_description = "COMMENT"
220220
@app.define_task(Rake::Task, "t")
221221
@app["t"].locations << "HERE:1"
222-
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
222+
out, = capture_output do @app.instance_eval { display_tasks_and_comments } end
223223
assert_match(/^rake t +[^:]+:\d+ *$/, out)
224224
end
225225

@@ -251,7 +251,7 @@ def test_load_rakefile
251251
def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir
252252
rakefile_unittest
253253

254-
_, err = capture_io do
254+
_, err = capture_output do
255255
@app.instance_eval do
256256
# pretend we started from the unittest dir
257257
@original_dir = File.expand_path(".")
@@ -283,7 +283,7 @@ def test_load_rakefile_prints_rakefile_directory_from_subdir
283283
app = Rake::Application.new
284284
app.options.rakelib = []
285285

286-
_, err = capture_io do
286+
_, err = capture_output do
287287
app.instance_eval do
288288
raw_load_rakefile
289289
end
@@ -296,7 +296,7 @@ def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
296296
rakefile_unittest
297297
Dir.chdir "subdir"
298298

299-
_, err = capture_io do
299+
_, err = capture_output do
300300
@app.instance_eval do
301301
handle_options []
302302
options.silent = true
@@ -308,7 +308,7 @@ def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
308308
end
309309

310310
def test_load_rakefile_not_found
311-
skip if jruby9?
311+
omit if jruby9?
312312

313313
Dir.chdir @tempdir
314314
ENV["RAKE_SYSTEM"] = "not_exist"
@@ -455,7 +455,7 @@ def test_good_run
455455

456456
rakefile_default
457457

458-
out, err = capture_io do
458+
out, err = capture_output do
459459
@app.run %w[--rakelib=""]
460460
end
461461

@@ -468,7 +468,7 @@ def test_display_task_run
468468
ran = false
469469
@app.last_description = "COMMENT"
470470
@app.define_task(Rake::Task, "default")
471-
out, = capture_io { @app.run %w[-f -s --tasks --rakelib=""] }
471+
out, = capture_output { @app.run %w[-f -s --tasks --rakelib=""] }
472472
assert @app.options.show_tasks
473473
assert ! ran
474474
assert_match(/rake default/, out)
@@ -482,7 +482,7 @@ def test_display_prereqs
482482
t.enhance([:a, :b])
483483
@app.define_task(Rake::Task, "a")
484484
@app.define_task(Rake::Task, "b")
485-
out, = capture_io { @app.run %w[-f -s --prereqs --rakelib=""] }
485+
out, = capture_output { @app.run %w[-f -s --prereqs --rakelib=""] }
486486
assert @app.options.show_prereqs
487487
assert ! ran
488488
assert_match(/rake a$/, out)
@@ -492,15 +492,15 @@ def test_display_prereqs
492492

493493
def test_bad_run
494494
@app.intern(Rake::Task, "default").enhance { fail }
495-
_, err = capture_io {
495+
_, err = capture_output {
496496
assert_raises(SystemExit) { @app.run %w[-f -s --rakelib=""] }
497497
}
498498
assert_match(/see full trace/i, err)
499499
end
500500

501501
def test_bad_run_with_trace
502502
@app.intern(Rake::Task, "default").enhance { fail }
503-
_, err = capture_io {
503+
_, err = capture_output {
504504
@app.set_default_options
505505
assert_raises(SystemExit) { @app.run %w[-f -s -t] }
506506
}
@@ -509,7 +509,7 @@ def test_bad_run_with_trace
509509

510510
def test_bad_run_with_backtrace
511511
@app.intern(Rake::Task, "default").enhance { fail }
512-
_, err = capture_io {
512+
_, err = capture_output {
513513
assert_raises(SystemExit) {
514514
@app.run %w[-f -s --backtrace]
515515
}
@@ -523,7 +523,7 @@ def test_bad_run_includes_exception_name
523523
@app.intern(Rake::Task, "default").enhance {
524524
raise CustomError, "intentional"
525525
}
526-
_, err = capture_io {
526+
_, err = capture_output {
527527
assert_raises(SystemExit) {
528528
@app.run %w[-f -s]
529529
}
@@ -535,7 +535,7 @@ def test_rake_error_excludes_exception_name
535535
@app.intern(Rake::Task, "default").enhance {
536536
fail "intentional"
537537
}
538-
_, err = capture_io {
538+
_, err = capture_output {
539539
assert_raises(SystemExit) {
540540
@app.run %w[-f -s]
541541
}
@@ -558,7 +558,7 @@ def test_printing_original_exception_cause
558558
raise custom_error, "Secondary Error"
559559
end
560560
}
561-
_ ,err = capture_io {
561+
_ ,err = capture_output {
562562
assert_raises(SystemExit) {
563563
@app.run %w[-f -s]
564564
}
@@ -572,12 +572,12 @@ def test_printing_original_exception_cause
572572
def test_run_with_bad_options
573573
@app.intern(Rake::Task, "default").enhance { fail }
574574
assert_raises(SystemExit) {
575-
capture_io { @app.run %w[-f -s --xyzzy] }
575+
capture_output { @app.run %w[-f -s --xyzzy] }
576576
}
577577
end
578578

579579
def test_standard_exception_handling_invalid_option
580-
out, err = capture_io do
580+
out, err = capture_output do
581581
e = assert_raises SystemExit do
582582
@app.standard_exception_handling do
583583
raise OptionParser::InvalidOption, "blah"
@@ -592,7 +592,7 @@ def test_standard_exception_handling_invalid_option
592592
end
593593

594594
def test_standard_exception_handling_other
595-
out, err = capture_io do
595+
out, err = capture_output do
596596
@app.set_default_options # reset trace output IO
597597

598598
e = assert_raises SystemExit do
@@ -610,7 +610,7 @@ def test_standard_exception_handling_other
610610
end
611611

612612
def test_standard_exception_handling_system_exit
613-
out, err = capture_io do
613+
out, err = capture_output do
614614
e = assert_raises SystemExit do
615615
@app.standard_exception_handling do
616616
exit 0
@@ -625,7 +625,7 @@ def test_standard_exception_handling_system_exit
625625
end
626626

627627
def test_standard_exception_handling_system_exit_nonzero
628-
out, err = capture_io do
628+
out, err = capture_output do
629629
e = assert_raises SystemExit do
630630
@app.standard_exception_handling do
631631
exit 5

test/test_rake_application_options.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_execute_and_continue
107107

108108
def test_execute_and_print
109109
$xyzzy = 0
110-
out, = capture_io do
110+
out, = capture_output do
111111
flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do
112112
assert_equal "pugh", $xyzzy
113113
assert_equal :exit, @exit
@@ -119,7 +119,7 @@ def test_execute_and_print
119119
end
120120

121121
def test_help
122-
out, = capture_io do
122+
out, = capture_output do
123123
flags "--help", "-H", "-h"
124124
end
125125

@@ -200,7 +200,7 @@ def test_require
200200
end
201201

202202
def test_missing_require
203-
skip if jruby?
203+
omit if jruby?
204204

205205
ex = assert_raises(LoadError) do
206206
flags(["--require", "test/missing"]) do |opts|
@@ -386,7 +386,7 @@ def test_no_deprecated_messages
386386
end
387387

388388
def test_verbose
389-
capture_io do
389+
capture_output do
390390
flags("--verbose", "-v") do |opts|
391391
assert Rake::FileUtilsExt.verbose_flag, "verbose should be true"
392392
assert ! opts.silent, "opts should not be silent"
@@ -395,7 +395,7 @@ def test_verbose
395395
end
396396

397397
def test_version
398-
out, _ = capture_io do
398+
out, _ = capture_output do
399399
flags "--version", "-V"
400400
end
401401

@@ -405,7 +405,7 @@ def test_version
405405
end
406406

407407
def test_bad_option
408-
_, err = capture_io do
408+
_, err = capture_output do
409409
ex = assert_raises(OptionParser::InvalidOption) do
410410
flags("--bad-option")
411411
end

test/test_rake_backtrace.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class TestRakeBacktrace < Rake::TestCase # :nodoc:
4040
def setup
4141
super
4242

43-
skip "tmpdir is suppressed in backtrace" if
43+
omit "tmpdir is suppressed in backtrace" if
4444
Rake::Backtrace::SUPPRESS_PATTERN =~ Dir.pwd
4545
end
4646

0 commit comments

Comments
 (0)