diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-02-15 10:56:29 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2024-03-14 18:33:28 +0900 |
commit | 5326337d4f15ccf33128b3cf5a8896ba7f91fcc4 (patch) | |
tree | 3ad7ae3a09b634a82be39e42fda926df3ed5035a /test/ruby/test_dir.rb | |
parent | 67fe047821d08781f783476c4060f017cd27541f (diff) |
[Feature #20244] Issue a single `Warning.warn` call
Make the entire series of message lines a multiline string so that the
`Warning.warn` hook can receive them in a single call.
Diffstat (limited to 'test/ruby/test_dir.rb')
-rw-r--r-- | test/ruby/test_dir.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index 7468d3fc76..2cc1c3ef4a 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -171,6 +171,26 @@ class TestDir < Test::Unit::TestCase 42 end + assert_separately(["-", @root], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + root = ARGV.shift + + $dir_warnings = [] + + def Warning.warn(message) + $dir_warnings << message + end + + line2 = line1 = __LINE__; Dir.chdir(root) do + line2 = __LINE__; Dir.chdir + end + + message = $dir_warnings.shift + assert_include(message, "#{__FILE__}:#{line2}:") + assert_include(message, "#{__FILE__}:#{line1}:") + assert_empty($dir_warnings) + end; + assert_equal(42, ret) ensure begin |