Add predicates for platforms
This commit is contained in:
parent
a3ba723ef0
commit
2d12fbc4db
Notes:
git
2024-09-10 07:50:38 +00:00
@ -1874,7 +1874,7 @@ class TestProcess < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_daemon_noclose
|
def test_daemon_noclose
|
||||||
pend "macOS 15 beta is not working with this test" if /darwin/ =~ RUBY_PLATFORM && /15/ =~ `sw_vers -productVersion`
|
pend "macOS 15 beta is not working with this test" if macos?(15)
|
||||||
|
|
||||||
data = IO.popen("-", "r+") do |f|
|
data = IO.popen("-", "r+") do |f|
|
||||||
break f.read if f
|
break f.read if f
|
||||||
|
@ -876,7 +876,7 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assert_segv(args, message=nil, list: SEGVTest::ExpectedStderrList, **opt, &block)
|
def assert_segv(args, message=nil, list: SEGVTest::ExpectedStderrList, **opt, &block)
|
||||||
pend "macOS 15 beta is not working with this assertion" if /darwin/ =~ RUBY_PLATFORM && /15/ =~ `sw_vers -productVersion`
|
pend "macOS 15 beta is not working with this assertion" if macos?(15)
|
||||||
|
|
||||||
# We want YJIT to be enabled in the subprocess if it's enabled for us
|
# We want YJIT to be enabled in the subprocess if it's enabled for us
|
||||||
# so that the Ruby description matches.
|
# so that the Ruby description matches.
|
||||||
@ -921,7 +921,7 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assert_crash_report(path, cmd = nil, &block)
|
def assert_crash_report(path, cmd = nil, &block)
|
||||||
pend "macOS 15 beta is not working with this assertion" if /darwin/ =~ RUBY_PLATFORM && /15/ =~ `sw_vers -productVersion`
|
pend "macOS 15 beta is not working with this assertion" if macos?(15)
|
||||||
|
|
||||||
Dir.mktmpdir("ruby_crash_report") do |dir|
|
Dir.mktmpdir("ruby_crash_report") do |dir|
|
||||||
list = SEGVTest::ExpectedStderrList
|
list = SEGVTest::ExpectedStderrList
|
||||||
|
@ -5,7 +5,7 @@ return unless /darwin/ =~ RUBY_PLATFORM
|
|||||||
|
|
||||||
class TestVMDump < Test::Unit::TestCase
|
class TestVMDump < Test::Unit::TestCase
|
||||||
def assert_darwin_vm_dump_works(args, timeout=nil)
|
def assert_darwin_vm_dump_works(args, timeout=nil)
|
||||||
pend "macOS 15 beta is not working with this assertion" if /darwin/ =~ RUBY_PLATFORM && /15/ =~ `sw_vers -productVersion`
|
pend "macOS 15 beta is not working with this assertion" if macos?(15)
|
||||||
|
|
||||||
assert_in_out_err(args, "", [], /^\[IMPORTANT\]/, timeout: timeout || 300)
|
assert_in_out_err(args, "", [], /^\[IMPORTANT\]/, timeout: timeout || 300)
|
||||||
end
|
end
|
||||||
|
@ -861,6 +861,65 @@ eom
|
|||||||
token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m"
|
token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m"
|
||||||
return token.dump, Regexp.quote(token)
|
return token.dump, Regexp.quote(token)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Platform predicates
|
||||||
|
|
||||||
|
def self.mswin?
|
||||||
|
defined?(@mswin) ? @mswin : @mswin = RUBY_PLATFORM.include?('mswin')
|
||||||
|
end
|
||||||
|
private def mswin?
|
||||||
|
CoreAssertions.mswin?
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.mingw?
|
||||||
|
defined?(@mingw) ? @mingw : @mingw = RUBY_PLATFORM.include?('mingw')
|
||||||
|
end
|
||||||
|
private def mingw?
|
||||||
|
CoreAssertions.mingw?
|
||||||
|
end
|
||||||
|
|
||||||
|
module_function def windows?
|
||||||
|
mswin? or mingw?
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.compare_version(a, b)
|
||||||
|
b.empty? ? true && a : a && (a <=> b) >= 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.linux?(*ver)
|
||||||
|
unless defined?(@linux)
|
||||||
|
@linux = RUBY_PLATFORM.include?('linux') && `uname -r`.scan(/\d+/).map(&:to_i)
|
||||||
|
end
|
||||||
|
compare_version @linux, ver
|
||||||
|
end
|
||||||
|
private def linux?(*ver)
|
||||||
|
CoreAssertions.linux?(*ver)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.glibc?(*ver)
|
||||||
|
unless defined?(@glibc)
|
||||||
|
libc = `/usr/bin/ldd /bin/sh`[/^\s*libc.*=> *\K\S*/]
|
||||||
|
if libc and /version (\d+)\.(\d+)\.$/ =~ IO.popen([libc], &:read)[]
|
||||||
|
@glibc = [$1.to_i, $2.to_i]
|
||||||
|
else
|
||||||
|
@glibc = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
compare_version @glibc, ver
|
||||||
|
end
|
||||||
|
private def glibc?(*ver)
|
||||||
|
CoreAssertions.glibc?(*ver)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.macos?(*ver)
|
||||||
|
unless defined?(@macos)
|
||||||
|
@macos = RUBY_PLATFORM.include?('darwin') && `sw_vers -productVersion`.scan(/\d+/).map(&:to_i)
|
||||||
|
end
|
||||||
|
compare_version @macos, ver
|
||||||
|
end
|
||||||
|
private def macos?(*ver)
|
||||||
|
CoreAssertions.macos?(*ver)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1893,6 +1893,7 @@ module Test
|
|||||||
@backtrace = ex.backtrace
|
@backtrace = ex.backtrace
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
attr_accessor :message, :backtrace
|
attr_accessor :message, :backtrace
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user