Skip to content

Commit

Permalink
+ Deprecated Minitest::Guard#maglev?
Browse files Browse the repository at this point in the history
+ Deprecated Minitest::Guard#rubinius?
+ Added Minitest::Guard#osx?
Cleaned out the maglev and rubinius conditionals in the tests.

[git-p4: depot-paths = "//src/minitest/dev/": change = 12357]
  • Loading branch information
zenspider committed Oct 20, 2019
1 parent 87806c1 commit 381e965
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 21 deletions.
13 changes: 13 additions & 0 deletions lib/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,9 @@ def jruby? platform = RUBY_PLATFORM
# Is this running on maglev?

def maglev? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
where = Minitest.filter_backtrace(caller).first
where = where.split(/:in /, 2).first # clean up noise
warn "DEPRECATED: `maglev?` called from #{where}. This will fail in Minitest 6."
"maglev" == platform
end

Expand All @@ -970,10 +973,20 @@ def mri? platform = RUBY_DESCRIPTION
/^ruby/ =~ platform
end

##
# Is this running on macOS?

def osx? platform = RUBY_PLATFORM
/darwin/ =~ platform
end

##
# Is this running on rubinius?

def rubinius? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
where = Minitest.filter_backtrace(caller).first
where = where.split(/:in /, 2).first # clean up noise
warn "DEPRECATED: `rubinius?` called from #{where}. This will fail in Minitest 6."
"rbx" == platform
end

Expand Down
2 changes: 0 additions & 2 deletions lib/minitest/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def self.diff
@diff = if (RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ &&
system("diff.exe", __FILE__, __FILE__)) then
"diff.exe -u"
elsif Minitest::Test.maglev? then
"diff -u"
elsif system("gdiff", __FILE__, __FILE__)
"gdiff -u" # solaris and kin suck
elsif system("diff", __FILE__, __FILE__)
Expand Down
6 changes: 3 additions & 3 deletions test/minitest/test_minitest_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def test_assert_in_delta
end

def test_assert_in_delta_triggered
x = maglev? ? "9.999999xxxe-07" : "1.0e-06"
x = "1.0e-06"
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
@tc.assert_in_delta 0.0, 1.0 / 1000, 0.000001
end
Expand Down Expand Up @@ -428,7 +428,7 @@ def test_assert_in_epsilon_triggered

def test_assert_in_epsilon_triggered_negative_case
x = (RUBY18 and not maglev?) ? "0.1" : "0.100000xxx"
y = maglev? ? "0.100000xxx" : "0.1"
y = "0.1"
assert_triggered "Expected |-1.1 - -1| (#{x}) to be <= #{y}." do
@tc.assert_in_epsilon(-1.1, -1, 0.1)
end
Expand Down Expand Up @@ -1052,7 +1052,7 @@ def test_refute_in_delta
end

def test_refute_in_delta_triggered
x = maglev? ? "0.100000xxx" : "0.1"
x = "0.1"
assert_triggered "Expected |0.0 - 0.001| (0.001) to not be <= #{x}." do
@tc.refute_in_delta 0.0, 1.0 / 1000, 0.1
end
Expand Down
2 changes: 0 additions & 2 deletions test/minitest/test_minitest_mock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ def test_return_mock_does_not_raise
end

def test_mock_args_does_not_raise
skip "non-opaque use of ==" if maglev?

arg = Minitest::Mock.new
mock = Minitest::Mock.new
mock.expect(:foo, nil, [arg])
Expand Down
8 changes: 4 additions & 4 deletions test/minitest/test_minitest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def assert_triggered expected = "blah", klass = Minitest::Assertion
_(6 * 7.0).wont_be_close_to 42
end

x = maglev? ? "1.0000000000000001e-05" : "1.0e-05"
x = "1.0e-05"
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
_(6 * 7.0).wont_be_close_to 42, 0.00001
end
Expand All @@ -277,12 +277,12 @@ def assert_triggered expected = "blah", klass = Minitest::Assertion

_(_(24).wont_be_within_epsilon(42)).must_equal false

x = maglev? ? "0.042000000000000003" : "0.042"
x = "0.042"
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
_(6 * 7.0).wont_be_within_epsilon 42
end

x = maglev? ? "0.00042000000000000002" : "0.00042"
x = "0.00042"
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
_(6 * 7.0).wont_be_within_epsilon 42, 0.00001
end
Expand All @@ -301,7 +301,7 @@ def assert_triggered expected = "blah", klass = Minitest::Assertion
_(1.0 / 100).must_be_close_to 0.0
end

x = maglev? ? "9.9999999999999995e-07" : "1.0e-06"
x = "1.0e-06"
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
_(1.0 / 1000).must_be_close_to 0.0, 0.000001
end
Expand Down
31 changes: 21 additions & 10 deletions test/minitest/test_minitest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,6 @@ def await
end

def test_run_parallel
skip "I don't have ParallelEach debugged yet" if maglev?

test_count = 2
test_latch = Latch.new test_count
wait_latch = Latch.new test_count
Expand Down Expand Up @@ -857,12 +855,7 @@ def test_test3; assert "does not matter" end
end

srand 42
expected = case
when maglev? then
%w[test_test2 test_test3 test_test1]
else
%w[test_test2 test_test1 test_test3]
end
expected = %w[test_test2 test_test1 test_test3]
assert_equal expected, sample_test_case.runnable_methods
end

Expand Down Expand Up @@ -931,8 +924,26 @@ def test_jruby_eh
end

def test_rubinius_eh
assert self.class.rubinius? "rbx"
assert self.rubinius? "rbx"
assert_output "", /DEPRECATED/ do
assert self.class.rubinius? "rbx"
end
assert_output "", /DEPRECATED/ do
assert self.rubinius? "rbx"
end
end

def test_maglev_eh
assert_output "", /DEPRECATED/ do
assert self.class.maglev? "maglev"
end
assert_output "", /DEPRECATED/ do
assert self.maglev? "maglev"
end
end

def test_osx_eh
assert self.class.osx? "darwin"
assert self.osx? "darwin"
end

def test_windows_eh
Expand Down

0 comments on commit 381e965

Please sign in to comment.