2013-10-16 21:10:35 -04:00
|
|
|
require 'test/unit'
|
2013-11-26 19:32:37 -05:00
|
|
|
require 'tmpdir'
|
2013-10-16 21:10:35 -04:00
|
|
|
require_relative "../../ruby/envutil"
|
|
|
|
|
|
|
|
class TestBugReporter < Test::Unit::TestCase
|
|
|
|
def test_bug_reporter_add
|
2014-10-15 04:59:46 -04:00
|
|
|
expected_stderr = [
|
|
|
|
:*,
|
|
|
|
/\[BUG\]\sSegmentation\sfault.*\n/,
|
|
|
|
/#{ Regexp.quote(RUBY_DESCRIPTION) }\n\n/,
|
|
|
|
:*,
|
|
|
|
/Sample bug reporter: 12345/,
|
|
|
|
:*
|
|
|
|
]
|
2013-11-26 19:32:37 -05:00
|
|
|
tmpdir = Dir.mktmpdir
|
2014-10-15 04:59:46 -04:00
|
|
|
|
|
|
|
args = ["--disable-gems", "-r-test-/bug_reporter/bug_reporter",
|
|
|
|
"-C", tmpdir]
|
2014-10-15 22:01:51 -04:00
|
|
|
stdin = "register_sample_bug_reporter(12345); Process.kill :SEGV, $$; sleep"
|
2014-10-15 04:59:46 -04:00
|
|
|
_, stderr, status = EnvUtil.invoke_ruby(args, stdin, false, true)
|
2014-10-16 08:27:43 -04:00
|
|
|
stderr.force_encoding("ASCII-8BIT")
|
2014-10-15 04:59:46 -04:00
|
|
|
assert_pattern_list(expected_stderr, stderr)
|
2013-11-26 19:32:37 -05:00
|
|
|
ensure
|
|
|
|
FileUtils.rm_rf(tmpdir) if tmpdir
|
2013-10-16 21:10:35 -04:00
|
|
|
end
|
|
|
|
end
|