diff options
author | Jeremy Evans <[email protected]> | 2020-09-25 13:29:20 -0700 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2020-09-28 08:34:04 -0700 |
commit | 5d7953f86b7ae164017e2292dfb3c108e0e02527 (patch) | |
tree | 48704c5ec68cb37b0df17eca58c3660d826d765c /test/ruby | |
parent | 0164ac70a14c3cc17989d76959cf791ec22e8695 (diff) |
Switch conflicting chdir warning to RuntimeError
The documentation already stated this was an error in one case
(when it was previously a warning). Describe the other case,
where chdir without block is called inside block passed to chdir.
Fixes [Bug #15661]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3591
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_dir.rb | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index 13b9c1ddf2..cf18af134c 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -99,8 +99,12 @@ class TestDir < Test::Unit::TestCase ENV["HOME"] = @pwd Dir.chdir do assert_equal(@pwd, Dir.pwd) - Dir.chdir(@root) - assert_equal(@root, Dir.pwd) + assert_raise(RuntimeError) { Dir.chdir(@root) } + assert_equal(@pwd, Dir.pwd) + Dir.chdir(@root) do + assert_equal(@root, Dir.pwd) + end + assert_equal(@pwd, Dir.pwd) end ensure @@ -121,6 +125,28 @@ class TestDir < Test::Unit::TestCase end end + def test_chdir_conflict + @pwd = Dir.pwd + q = Queue.new + t = Thread.new do + q.pop + Dir.chdir(@pwd) rescue $! + end + Dir.chdir(@pwd) do + q.push nil + assert_instance_of(RuntimeError, t.value) + end + + t = Thread.new do + q.pop + Dir.chdir(@pwd){} rescue $! + end + Dir.chdir(@pwd) do + q.push nil + assert_instance_of(RuntimeError, t.value) + end + end + def test_chroot_nodir skip if RUBY_PLATFORM =~ /android/ assert_raise(NotImplementedError, Errno::ENOENT, Errno::EPERM |