Skip to content

Commit 9fef7c8

Browse files
committed
Merge pull request rails#10527 from zenspider/squishy_minitest5
Squishy minitest5
2 parents 2857496 + de4dcac commit 9fef7c8

File tree

13 files changed

+50
-146
lines changed

13 files changed

+50
-146
lines changed

Diff for: Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
22

33
gemspec
44

5-
gem 'mocha', '~> 0.13.0', require: false
5+
gem 'mocha', git: 'https://github.com/freerange/mocha', require: false
66
gem 'rack-cache', '~> 1.2'
77
gem 'bcrypt-ruby', '~> 3.0.0'
88
gem 'jquery-rails', '~> 2.2.0'

Diff for: actionpack/lib/action_view/test_case.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ def view
211211
alias_method :_view, :view
212212

213213
INTERNAL_IVARS = [
214-
:@__name__,
214+
:@NAME,
215+
:@failures,
216+
:@assertions,
215217
:@__io__,
216218
:@_assertion_wrapped,
217219
:@_assertions,

Diff for: activemodel/test/cases/railtie_test.rb

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ def setup
99

1010
@app ||= Class.new(::Rails::Application) do
1111
config.eager_load = false
12-
config.logger = Logger.new(STDOUT)
1312
end
1413
end
1514

Diff for: activesupport/activesupport.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
2323
s.add_dependency('i18n', '~> 0.6', '>= 0.6.4')
2424
s.add_dependency 'json', '~> 1.7'
2525
s.add_dependency 'tzinfo', '~> 0.3.37'
26-
s.add_dependency 'minitest', '~> 4.2'
26+
s.add_dependency 'minitest', '~> 5.0'
2727
s.add_dependency 'thread_safe','~> 0.1'
2828
end

Diff for: activesupport/lib/active_support/test_case.rb

+21-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,28 @@
1616
rescue LoadError
1717
end
1818

19+
module Minitest # :nodoc:
20+
class << self
21+
remove_method :__run
22+
end
23+
24+
def self.__run reporter, options # :nodoc:
25+
# FIXME: MT5's runnables is not ordered. This is needed because
26+
# we have have tests have cross-class order-dependent bugs.
27+
suites = Runnable.runnables.sort_by { |ts| ts.name.to_s }
28+
29+
parallel, serial = suites.partition { |s| s.test_order == :parallel }
30+
31+
ParallelEach.new(parallel).map { |suite| suite.run reporter, options } +
32+
serial.map { |suite| suite.run reporter, options }
33+
end
34+
end
35+
1936
module ActiveSupport
20-
class TestCase < ::MiniTest::Unit::TestCase
21-
Assertion = MiniTest::Assertion
22-
alias_method :method_name, :__name__
37+
class TestCase < ::Minitest::Test
38+
Assertion = Minitest::Assertion
39+
40+
alias_method :method_name, :name
2341

2442
$tags = {}
2543
def self.for_tag(tag)

Diff for: activesupport/lib/active_support/testing/autorun.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
gem 'minitest'
22

3-
require 'minitest/unit'
3+
require 'minitest'
44

5-
MiniTest::Unit.autorun
5+
Minitest.autorun

Diff for: activesupport/lib/active_support/testing/isolation.rb

+6-11
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,12 @@ def _run_class_setup # class setup method should only happen in parent
7272
end
7373
end
7474

75-
def run(runner)
76-
_run_class_setup
77-
78-
serialized = run_in_isolation do |isolated_runner|
79-
super(isolated_runner)
75+
def run
76+
serialized = run_in_isolation do
77+
super
8078
end
8179

82-
retval, proxy = Marshal.load(serialized)
83-
proxy.__replay__(runner)
84-
retval
80+
Marshal.load(serialized)
8581
end
8682

8783
module Forking
@@ -90,9 +86,8 @@ def run_in_isolation(&blk)
9086

9187
pid = fork do
9288
read.close
93-
proxy = ProxyTestResult.new
94-
retval = yield proxy
95-
write.puts [Marshal.dump([retval, proxy])].pack("m")
89+
yield
90+
write.puts [Marshal.dump(self.dup)].pack("m")
9691
exit!
9792
end
9893

Diff for: activesupport/lib/active_support/testing/tagged_logging.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module TaggedLogging #:nodoc:
77

88
def before_setup
99
if tagged_logger
10-
heading = "#{self.class}: #{__name__}"
10+
heading = "#{self.class}: #{name}"
1111
divider = '-' * heading.size
1212
tagged_logger.info divider
1313
tagged_logger.info heading

Diff for: activesupport/test/test_case_test.rb

-110
Original file line numberDiff line numberDiff line change
@@ -2,116 +2,6 @@
22

33
module ActiveSupport
44
class TestCaseTest < ActiveSupport::TestCase
5-
class FakeRunner
6-
attr_reader :puked
7-
8-
def initialize
9-
@puked = []
10-
end
11-
12-
def puke(klass, name, e)
13-
@puked << [klass, name, e]
14-
end
15-
16-
def options
17-
nil
18-
end
19-
20-
def record(*args)
21-
end
22-
23-
def info_signal
24-
end
25-
end
26-
27-
def test_standard_error_raised_within_setup_callback_is_puked
28-
tc = Class.new(TestCase) do
29-
def self.name; nil; end
30-
31-
setup :bad_callback
32-
def bad_callback; raise 'oh noes' end
33-
def test_true; assert true end
34-
end
35-
36-
test_name = 'test_true'
37-
fr = FakeRunner.new
38-
39-
test = tc.new test_name
40-
test.run fr
41-
klass, name, exception = *fr.puked.first
42-
43-
assert_equal tc, klass
44-
assert_equal test_name, name
45-
assert_equal 'oh noes', exception.message
46-
end
47-
48-
def test_standard_error_raised_within_teardown_callback_is_puked
49-
tc = Class.new(TestCase) do
50-
def self.name; nil; end
51-
52-
teardown :bad_callback
53-
def bad_callback; raise 'oh noes' end
54-
def test_true; assert true end
55-
end
56-
57-
test_name = 'test_true'
58-
fr = FakeRunner.new
59-
60-
test = tc.new test_name
61-
test.run fr
62-
klass, name, exception = *fr.puked.first
63-
64-
assert_equal tc, klass
65-
assert_equal test_name, name
66-
assert_equal 'oh noes', exception.message
67-
end
68-
69-
def test_passthrough_exception_raised_within_test_method_is_not_rescued
70-
tc = Class.new(TestCase) do
71-
def self.name; nil; end
72-
73-
def test_which_raises_interrupt; raise Interrupt; end
74-
end
75-
76-
test_name = 'test_which_raises_interrupt'
77-
fr = FakeRunner.new
78-
79-
test = tc.new test_name
80-
assert_raises(Interrupt) { test.run fr }
81-
end
82-
83-
def test_passthrough_exception_raised_within_setup_callback_is_not_rescued
84-
tc = Class.new(TestCase) do
85-
def self.name; nil; end
86-
87-
setup :callback_which_raises_interrupt
88-
def callback_which_raises_interrupt; raise Interrupt; end
89-
def test_true; assert true end
90-
end
91-
92-
test_name = 'test_true'
93-
fr = FakeRunner.new
94-
95-
test = tc.new test_name
96-
assert_raises(Interrupt) { test.run fr }
97-
end
98-
99-
def test_passthrough_exception_raised_within_teardown_callback_is_not_rescued
100-
tc = Class.new(TestCase) do
101-
def self.name; nil; end
102-
103-
teardown :callback_which_raises_interrupt
104-
def callback_which_raises_interrupt; raise Interrupt; end
105-
def test_true; assert true end
106-
end
107-
108-
test_name = 'test_true'
109-
fr = FakeRunner.new
110-
111-
test = tc.new test_name
112-
assert_raises(Interrupt) { test.run fr }
113-
end
114-
1155
def test_pending_deprecation
1166
assert_deprecated do
1177
pending "should use #skip instead"

Diff for: activesupport/test/test_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,6 @@ def before_setup
201201
end
202202

203203
def test_logs_tagged_with_current_test_case
204-
assert_match "#{self.class}: #{__name__}\n", @out.string
204+
assert_match "#{self.class}: #{name}\n", @out.string
205205
end
206206
end

Diff for: railties/test/application/rake_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def test_scaffold_tests_pass_by_default
214214
bundle exec rake db:migrate db:test:clone test`
215215
end
216216

217-
assert_match(/7 tests, 13 assertions, 0 failures, 0 errors/, output)
217+
assert_match(/7 runs, 13 assertions, 0 failures, 0 errors/, output)
218218
assert_no_match(/Errors running/, output)
219219
end
220220

@@ -224,7 +224,7 @@ def test_scaffold_with_references_columns_tests_pass_by_default
224224
bundle exec rake db:migrate db:test:clone test`
225225
end
226226

227-
assert_match(/7 tests, 13 assertions, 0 failures, 0 errors/, output)
227+
assert_match(/7 runs, 13 assertions, 0 failures, 0 errors/, output)
228228
assert_no_match(/Errors running/, output)
229229
end
230230

Diff for: railties/test/application/test_runner_test.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ def test_env
3232
def test_run_single_file
3333
create_test_file :models, 'foo'
3434
create_test_file :models, 'bar'
35-
assert_match "1 tests, 1 assertions, 0 failures", run_test_command("test/models/foo_test.rb")
35+
assert_match "1 runs, 1 assertions, 0 failures", run_test_command("test/models/foo_test.rb")
3636
end
3737

3838
def test_run_multiple_files
3939
create_test_file :models, 'foo'
4040
create_test_file :models, 'bar'
41-
assert_match "2 tests, 2 assertions, 0 failures", run_test_command("test/models/foo_test.rb test/models/bar_test.rb")
41+
assert_match "2 runs, 2 assertions, 0 failures", run_test_command("test/models/foo_test.rb test/models/bar_test.rb")
4242
end
4343

4444
def test_run_file_with_syntax_error
@@ -59,7 +59,7 @@ def test_run_models
5959
run_test_models_command.tap do |output|
6060
assert_match "FooTest", output
6161
assert_match "BarTest", output
62-
assert_match "2 tests, 2 assertions, 0 failures", output
62+
assert_match "2 runs, 2 assertions, 0 failures", output
6363
end
6464
end
6565

@@ -70,7 +70,7 @@ def test_run_helpers
7070
run_test_helpers_command.tap do |output|
7171
assert_match "FooHelperTest", output
7272
assert_match "BarHelperTest", output
73-
assert_match "2 tests, 2 assertions, 0 failures", output
73+
assert_match "2 runs, 2 assertions, 0 failures", output
7474
end
7575
end
7676

@@ -83,7 +83,7 @@ def test_run_units
8383
assert_match "FooTest", output
8484
assert_match "BarHelperTest", output
8585
assert_match "BazUnitTest", output
86-
assert_match "3 tests, 3 assertions, 0 failures", output
86+
assert_match "3 runs, 3 assertions, 0 failures", output
8787
end
8888
end
8989

@@ -94,7 +94,7 @@ def test_run_controllers
9494
run_test_controllers_command.tap do |output|
9595
assert_match "FooControllerTest", output
9696
assert_match "BarControllerTest", output
97-
assert_match "2 tests, 2 assertions, 0 failures", output
97+
assert_match "2 runs, 2 assertions, 0 failures", output
9898
end
9999
end
100100

@@ -105,7 +105,7 @@ def test_run_mailers
105105
run_test_mailers_command.tap do |output|
106106
assert_match "FooMailerTest", output
107107
assert_match "BarMailerTest", output
108-
assert_match "2 tests, 2 assertions, 0 failures", output
108+
assert_match "2 runs, 2 assertions, 0 failures", output
109109
end
110110
end
111111

@@ -118,7 +118,7 @@ def test_run_functionals
118118
assert_match "FooMailerTest", output
119119
assert_match "BarControllerTest", output
120120
assert_match "BazFunctionalTest", output
121-
assert_match "3 tests, 3 assertions, 0 failures", output
121+
assert_match "3 runs, 3 assertions, 0 failures", output
122122
end
123123
end
124124

@@ -127,7 +127,7 @@ def test_run_integration
127127
create_test_file :models, 'foo'
128128
run_test_integration_command.tap do |output|
129129
assert_match "FooIntegration", output
130-
assert_match "1 tests, 1 assertions, 0 failures", output
130+
assert_match "1 runs, 1 assertions, 0 failures", output
131131
end
132132
end
133133

@@ -136,7 +136,7 @@ def test_run_all_suites
136136
suites.each { |suite| create_test_file suite, "foo_#{suite}" }
137137
run_test_command('') .tap do |output|
138138
suites.each { |suite| assert_match "Foo#{suite.to_s.camelize}Test", output }
139-
assert_match "7 tests, 7 assertions, 0 failures", output
139+
assert_match "7 runs, 7 assertions, 0 failures", output
140140
end
141141
end
142142

Diff for: railties/test/generators/plugin_new_generator_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ def test_ensure_that_tests_work
168168
run_generator
169169
FileUtils.cd destination_root
170170
quietly { system 'bundle install' }
171-
assert_match(/1 tests, 1 assertions, 0 failures, 0 errors/, `bundle exec rake test`)
171+
assert_match(/1 runs, 1 assertions, 0 failures, 0 errors/, `bundle exec rake test`)
172172
end
173173

174174
def test_ensure_that_tests_works_in_full_mode
175175
run_generator [destination_root, "--full", "--skip_active_record"]
176176
FileUtils.cd destination_root
177177
quietly { system 'bundle install' }
178-
assert_match(/1 tests, 1 assertions, 0 failures, 0 errors/, `bundle exec rake test`)
178+
assert_match(/1 runs, 1 assertions, 0 failures, 0 errors/, `bundle exec rake test`)
179179
end
180180

181181
def test_ensure_that_migration_tasks_work_with_mountable_option

0 commit comments

Comments
 (0)