Project

General

Profile

Actions

Bug #272

closed

test_chdir failed when Dir.tmpdir is symlink

Added by znz (Kazuhiro NISHIYAMA) almost 16 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-dev:35481]

Description

=begin
Dir.tmpdirが返すディレクトリがsymlinkのときにtest_chdirが失敗します。

% ln -s /tmp $HOME/symlink-tmpdir
% env TMPDIR=$HOME/symlink-tmpdir ruby-trunk -v test/ruby/test_dir.rb
ruby 1.9.0 (2008-07-14 revision 18060) [i686-linux]
Loaded suite test/ruby/test_dir
Started
.test/ruby/test_dir.rb:111: warning: conflicting chdir during another chdir block
F..........
Finished in 0.0631458779999999 seconds.

  1. Failure:
    test_chdir(TestDir)
    [test/ruby/test_dir.rb:112:in block in test_chdir' test/ruby/test_dir.rb:109:in chdir'
    test/ruby/test_dir.rb:109:in `test_chdir']:
    <"/home/kazu/symlink-tmpdir/__test_dir__20080714-13467-1l19gzu"> expected but was
    <"/tmp/__test_dir__20080714-13467-1l19gzu">.

12 tests, 78 assertions, 1 failures, 0 errors
=end

Actions #1

Updated by znz (Kazuhiro NISHIYAMA) almost 16 years ago

=begin
西山和広です。

At Mon, 14 Jul 2008 17:54:40 +0900,
Kazuhiro NISHIYAMA wrote:

Dir.tmpdirが返すディレクトリがsymlinkのときにtest_chdirが失敗します。

test_execopts_chdir(TestProcess)も同様に失敗します。

Pathname#realpathを使えば解決するようですが、
こういう解決方法で良いのでしょうか?

Index: test/ruby/test_dir.rb

--- test/ruby/test_dir.rb (revision 18104)
+++ test/ruby/test_dir.rb (working copy)
@@ -2,11 +2,12 @@ require 'test/unit'

require 'tmpdir'
require 'fileutils'
+require 'pathname'

class TestDir < Test::Unit::TestCase

def setup
  • @root (cui_root cui) = Pathname.new(Dir.mktmpdir('test_dir')).realpath.to_s
    @nodir = File.join(@root (cui_root cui), "dummy")
    for i in ?a..?z
    if i.ord % 2 == 0
    Index: test/ruby/test_process.rb
    ===================================================================
    --- test/ruby/test_process.rb (revision 18104)
    +++ test/ruby/test_process.rb (working copy)
    @@ -1,5 +1,6 @@
    require 'test/unit'
    require 'tmpdir'
    +require 'pathname'
    require_relative 'envutil'

class TestProcess < Test::Unit::TestCase
@@ -21,6 +22,7 @@ class TestProcess < Test::Unit::TestCase

def with_tmpchdir
  Dir.mktmpdir {|d|
  •  d = Pathname.new(d).realpath.to_s
     Dir.chdir(d) {
       yield d
     }
    

--
|ZnZ(ゼット エヌ ゼット)
|西山和広(Kazuhiro NISHIYAMA)

=end

Actions #2

Updated by Anonymous over 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r18153.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0