diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-22 16:05:04 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-22 16:05:04 +0000 |
commit | baf952792f9da0f7e1548e8e4e437bc85241cce2 (patch) | |
tree | 12a39bfde62b885a098d10a0c98cf5b617cc0b7a /test/ruby | |
parent | 0531762efa4804a2f0e38393f1dceb60a1ff375a (diff) | |
download | ruby-baf952792f9da0f7e1548e8e4e437bc85241cce2.tar.gz |
test_exception.rb: assertions with Exception.to_tty?
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_exception.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 45dbcca22f..574ffbc537 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1277,19 +1277,35 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| bt = ["test:100", "test:99", "test:98", "test:1"] e = assert_raise(RuntimeError) {raise RuntimeError, "testerror", bt} + bottom = "test:100: testerror (RuntimeError)\n" + top = "test:1\n" + remark = "Traceback (most recent call last):" + message = e.full_message(highlight: false, order: :top) assert_not_match(/\e/, message) assert_operator(message.count("\n"), :>, 2) - assert_operator(message, :start_with?, "test:100: testerror (RuntimeError)\n") - assert_operator(message, :end_with?, "test:1\n") + assert_operator(message, :start_with?, bottom) + assert_operator(message, :end_with?, top) message = e.full_message(highlight: false, order: :bottom) assert_not_match(/\e/, message) assert_operator(message.count("\n"), :>, 2) - assert_operator(message, :start_with?, "Traceback (most recent call last):") - assert_operator(message, :end_with?, "test:100: testerror (RuntimeError)\n") + assert_operator(message, :start_with?, remark) + assert_operator(message, :end_with?, bottom) message = e.full_message(highlight: true) assert_match(/\e/, message) + + message = e.full_message + if Exception.to_tty? + assert_match(/\e/, message) + message = message.gsub(/\e\[[\d;]*m/, '') + assert_operator(message, :start_with?, remark) + assert_operator(message, :end_with?, bottom) + else + assert_not_match(/\e/, message) + assert_operator(message, :start_with?, bottom) + assert_operator(message, :end_with?, top) + end end end |