2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
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
|
|
|
|
|
|
|
class TestBugReporter < Test::Unit::TestCase
|
|
|
|
def test_bug_reporter_add
|
2018-04-28 05:02:56 -04:00
|
|
|
description = RUBY_DESCRIPTION
|
|
|
|
description = description.sub(/\+JIT /, '') if RubyVM::MJIT.enabled?
|
2014-10-15 04:59:46 -04:00
|
|
|
expected_stderr = [
|
|
|
|
:*,
|
|
|
|
/\[BUG\]\sSegmentation\sfault.*\n/,
|
2018-04-28 05:02:56 -04:00
|
|
|
/#{ Regexp.quote(description) }\n\n/,
|
2014-10-15 04:59:46 -04:00
|
|
|
:*,
|
|
|
|
/Sample bug reporter: 12345/,
|
|
|
|
:*
|
|
|
|
]
|
2013-11-26 19:32:37 -05:00
|
|
|
tmpdir = Dir.mktmpdir
|
2014-10-15 04:59:46 -04:00
|
|
|
|
2016-01-10 04:43:47 -05:00
|
|
|
args = ["--disable-gems", "-r-test-/bug_reporter",
|
2014-10-15 04:59:46 -04:00
|
|
|
"-C", tmpdir]
|
2014-10-16 14:11:49 -04:00
|
|
|
stdin = "register_sample_bug_reporter(12345); Process.kill :SEGV, $$"
|
2015-03-03 03:19:43 -05:00
|
|
|
assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT")
|
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
|