зеркало из https://github.com/github/ruby.git
Extract assert_segv and split the big regexp.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5a601ec591
Коммит
7643c2b37d
|
@ -513,40 +513,67 @@ class TestRubyOptions < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
ExecOptions = opts.freeze
|
ExecOptions = opts.freeze
|
||||||
|
|
||||||
ExpectedStderr =
|
ExpectedStderrList = [
|
||||||
%r(\A
|
%r(
|
||||||
-e:(?:1:)?\s\[BUG\]\sSegmentation\sfault.*\n
|
-e:(?:1:)?\s\[BUG\]\sSegmentation\sfault.*\n
|
||||||
#{ Regexp.quote(RUBY_DESCRIPTION) }\n\n
|
)x,
|
||||||
(?:--\s(?:.+\n)*\n)?
|
%r(
|
||||||
--\sControl\sframe\sinformation\s-+\n
|
#{ Regexp.quote(RUBY_DESCRIPTION) }\n\n
|
||||||
(?:c:.*\n)*
|
)x,
|
||||||
(?:
|
%r(
|
||||||
--\sRuby\slevel\sbacktrace\sinformation\s----------------------------------------\n
|
(?:--\s(?:.+\n)*\n)?
|
||||||
-e:1:in\s\`<main>\'\n
|
--\sControl\sframe\sinformation\s-+\n
|
||||||
-e:1:in\s\`kill\'\n
|
(?:c:.*\n)*
|
||||||
)?
|
)x,
|
||||||
\n
|
%r(
|
||||||
(?:
|
(?:
|
||||||
--\sC\slevel\sbacktrace\sinformation\s-------------------------------------------\n
|
--\sRuby\slevel\sbacktrace\sinformation\s----------------------------------------\n
|
||||||
(?:(?:.*\s)?\[0x\h+\]\n)*\n
|
-e:1:in\s\`<main>\'\n
|
||||||
)?
|
-e:1:in\s\`kill\'\n
|
||||||
(?m:.*)
|
)?
|
||||||
\[NOTE\]\n
|
\n
|
||||||
You\smay\shave\sencountered\sa\sbug\sin\sthe\sRuby\sinterpreter\sor\sextension\slibraries.\n
|
(?:
|
||||||
Bug\sreports\sare\swelcome.\n
|
--\sC\slevel\sbacktrace\sinformation\s-------------------------------------------\n
|
||||||
(?:.*\n)?
|
(?:(?:.*\s)?\[0x\h+\]\n)*\n
|
||||||
For\sdetails:\shttp:\/\/.*\.ruby-lang\.org/.*\n
|
)?
|
||||||
\n
|
(?m:.*)
|
||||||
(?:#{additional})
|
\[NOTE\]\n
|
||||||
\z
|
You\smay\shave\sencountered\sa\sbug\sin\sthe\sRuby\sinterpreter\sor\sextension\slibraries.\n
|
||||||
|
Bug\sreports\sare\swelcome.\n
|
||||||
|
(?:.*\n)?
|
||||||
|
For\sdetails:\shttp:\/\/.*\.ruby-lang\.org/.*\n
|
||||||
|
\n
|
||||||
|
(?:#{additional})
|
||||||
)x
|
)x
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert_segv(args, message=nil)
|
||||||
|
test_stdin = ""
|
||||||
|
opt = SEGVTest::ExecOptions.dup
|
||||||
|
|
||||||
|
_, stderr, status = EnvUtil.invoke_ruby(args, test_stdin, false, true, **opt)
|
||||||
|
|
||||||
|
if signo = status.termsig
|
||||||
|
sleep 0.1
|
||||||
|
EnvUtil.diagnostic_reports(Signal.signame(signo), EnvUtil.rubybin, status.pid, Time.now)
|
||||||
|
end
|
||||||
|
|
||||||
|
str = stderr
|
||||||
|
SEGVTest::ExpectedStderrList.each {|regexp|
|
||||||
|
r = /\A#{regexp}/
|
||||||
|
unless r =~ str
|
||||||
|
assert_match(r, str, message)
|
||||||
|
end
|
||||||
|
str = $'
|
||||||
|
}
|
||||||
|
assert_equal('', str)
|
||||||
|
|
||||||
|
status
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_segv_test
|
def test_segv_test
|
||||||
opts = SEGVTest::ExecOptions.dup
|
assert_segv(["--disable-gems", "-e", "Process.kill :SEGV, $$"])
|
||||||
expected_stderr = SEGVTest::ExpectedStderr
|
|
||||||
|
|
||||||
assert_in_out_err(["--disable-gems", "-e", "Process.kill :SEGV, $$"], "", [], expected_stderr, nil, opts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_segv_loaded_features
|
def test_segv_loaded_features
|
||||||
|
@ -570,15 +597,11 @@ class TestRubyOptions < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_segv_setproctitle
|
def test_segv_setproctitle
|
||||||
opts = SEGVTest::ExecOptions.dup
|
|
||||||
expected_stderr = SEGVTest::ExpectedStderr
|
|
||||||
|
|
||||||
bug7597 = '[ruby-dev:46786]'
|
bug7597 = '[ruby-dev:46786]'
|
||||||
Tempfile.create(["test_ruby_test_bug7597", ".rb"]) {|t|
|
Tempfile.create(["test_ruby_test_bug7597", ".rb"]) {|t|
|
||||||
t.write "f" * 100
|
t.write "f" * 100
|
||||||
t.flush
|
t.flush
|
||||||
assert_in_out_err(["--disable-gems", "-e", "$0=ARGV[0]; Process.kill :SEGV, $$", t.path],
|
assert_segv(["--disable-gems", "-e", "$0=ARGV[0]; Process.kill :SEGV, $$", t.path], bug7597)
|
||||||
"", [], expected_stderr, bug7597, opts)
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче