diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2020-12-24 13:43:22 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2020-12-24 14:34:40 +0900 |
commit | 8e1c0b2f93abe23f42bd7eba0a3f0d3f3669e486 (patch) | |
tree | 03944274f80d3630a20dd8e3c98dc7d780c8084d /test/ruby/test_dir.rb | |
parent | e43b5aa52dcd1eaded1141ab85a30bc8c7c4a6e4 (diff) | |
download | ruby-8e1c0b2f93abe23f42bd7eba0a3f0d3f3669e486.tar.gz |
dir.c: chdir conflict should raise only when called in different thread
... and keep it as a warning (like 2.7) when it is called in the same
thread. [Bug #15661]
Diffstat (limited to 'test/ruby/test_dir.rb')
-rw-r--r-- | test/ruby/test_dir.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index fb8d009db4..e5bcbeac73 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -97,9 +97,22 @@ class TestDir < Test::Unit::TestCase assert_raise(ArgumentError) { Dir.chdir } ENV["HOME"] = pwd Dir.chdir do - assert_equal(pwd, Dir.pwd) - assert_raise(RuntimeError) { Dir.chdir(@root) } - assert_equal(pwd, Dir.pwd) + assert_warning(/conflicting chdir during another chdir block/) { Dir.chdir(pwd) } + + assert_warning(/conflicting chdir during another chdir block/) { Dir.chdir(@root) } + assert_equal(@root, Dir.pwd) + + assert_warning(/conflicting chdir during another chdir block/) { Dir.chdir(pwd) } + + assert_raise(RuntimeError) { Thread.new { Thread.current.report_on_exception = false; Dir.chdir(@root) }.join } + assert_raise(RuntimeError) { Thread.new { Thread.current.report_on_exception = false; Dir.chdir(@root) { } }.join } + + assert_warning(/conflicting chdir during another chdir block/) { Dir.chdir(pwd) } + + assert_warning(/conflicting chdir during another chdir block/) { Dir.chdir(@root) } + assert_equal(@root, Dir.pwd) + + assert_warning(/conflicting chdir during another chdir block/) { Dir.chdir(pwd) } Dir.chdir(@root) do assert_equal(@root, Dir.pwd) end |