summaryrefslogtreecommitdiff
path: root/test/minitest/test_minitest_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/minitest/test_minitest_spec.rb')
-rw-r--r--test/minitest/test_minitest_spec.rb68
1 files changed, 40 insertions, 28 deletions
diff --git a/test/minitest/test_minitest_spec.rb b/test/minitest/test_minitest_spec.rb
index 56aa78d620..85cb95f42b 100644
--- a/test/minitest/test_minitest_spec.rb
+++ b/test/minitest/test_minitest_spec.rb
@@ -15,6 +15,8 @@ class ExampleA; end
class ExampleB < ExampleA; end
describe MiniTest::Spec do
+ # do not parallelize this suite... it just can't handle it.
+
def assert_triggered expected = "blah", klass = MiniTest::Assertion
@assertion_count += 2
@@ -567,11 +569,28 @@ describe MiniTest::Spec, :subject do
end
end
-class TestMeta < MiniTest::Unit::TestCase
- def test_setup
- srand 42
- MiniTest::Unit::TestCase.reset
+class TestMetaStatic < MiniTest::Unit::TestCase
+ def test_children
+ MiniTest::Spec.children.clear # prevents parallel run
+
+ x = y = z = nil
+ x = describe "top-level thingy" do
+ y = describe "first thingy" do end
+
+ it "top-level-it" do end
+
+ z = describe "second thingy" do end
+ end
+
+ assert_equal [x], MiniTest::Spec.children
+ assert_equal [y, z], x.children
+ assert_equal [], y.children
+ assert_equal [], z.children
end
+end
+
+class TestMeta < MiniTest::Unit::TestCase
+ parallelize_me! if ENV["PARALLEL"]
def util_structure
x = y = z = nil
@@ -659,35 +678,15 @@ class TestMeta < MiniTest::Unit::TestCase
_, _, z, before_list, after_list = util_structure
@tu = MiniTest::Unit.new
- @output = StringIO.new("")
MiniTest::Unit.runner = nil # protect the outer runner from the inner tests
- MiniTest::Unit.output = @output
- tc = z.new :test_0002_anonymous
- tc.run @tu
+ with_output do
+ tc = z.new :test_0002_anonymous
+ tc.run @tu
+ end
assert_equal [1, 2, 3], before_list
assert_equal [3, 2, 1], after_list
- ensure
- MiniTest::Unit.output = $stdout
- end
-
- def test_children
- MiniTest::Spec.children.clear
-
- x = y = z = nil
- x = describe "top-level thingy" do
- y = describe "first thingy" do end
-
- it "top-level-it" do end
-
- z = describe "second thingy" do end
- end
-
- assert_equal [x], MiniTest::Spec.children
- assert_equal [y, z], x.children
- assert_equal [], y.children
- assert_equal [], z.children
end
def test_describe_first_structure
@@ -723,4 +722,17 @@ class TestMeta < MiniTest::Unit::TestCase
assert_respond_to y.new(nil), "xyz"
assert_respond_to z.new(nil), "xyz"
end
+
+ def with_output # REFACTOR: dupe from metametameta
+ synchronize do
+ begin
+ @output = StringIO.new("")
+ MiniTest::Unit.output = @output
+
+ yield
+ ensure
+ MiniTest::Unit.output = STDOUT
+ end
+ end
+ end
end