From: Kazuhiro NISHIYAMA Date: 2009-08-21T22:13:12+09:00 Subject: [ruby-dev:39150] [Bug #1976] Errors in test/fileutils/test_fileutils.rb Bug #1976: Errors in test/fileutils/test_fileutils.rb http://redmine.ruby-lang.org/issues/show/1976 起票者: Kazuhiro NISHIYAMA ステータス: Open, 優先度: Normal ruby -v: ruby 1.9.2dev (2009-08-21 trunk 24613) [i686-linux] 環境によっては test_fileutils.rb でエラーになることがあるようです。 5) Error: test_rm_f(TestFileUtils): TypeError: can't convert Array into String /home/kazu/wc/ruby/trunk/test/fileutils/test_fileutils.rb:420:in `test_rm_f' 6) Error: test_rm_f(TestFileUtilsNoWrite): TypeError: can't convert Hash into String /home/kazu/wc/ruby/trunk/test/fileutils/test_nowrite.rb:78:in `test_rm_f' 7) Error: test_rm_rf(TestFileUtilsNoWrite): TypeError: can't convert Hash into String /home/kazu/wc/ruby/trunk/test/fileutils/test_nowrite.rb:84:in `test_rm_rf' 状況を調べてみると FileUtils::NoWrite の rm_rf の super で mkmf.rb の rm_rf が呼ばれていました。 そのときの self.class.ancestors は [TestFileUtilsNoWrite, FileUtils::NoWrite, Test::Unit::TestCase, Test::Unit::Ass ertions, MiniTest::Unit::TestCase, MiniTest::Assertions, Object, JSON::Ext::Gene rator::GeneratorMethods::Object, RakeFileUtils, FileUtils, FileUtils::StreamUtil s_, PP::ObjectMixin, Kernel, BasicObject] となっていて、 FileUtils::NoWrite と FileUtils の間に Object が入っている (ここに mkmf.rb で rm_rf が定義されている) のが原因のようです。 以下のようにすると再現できます。 % ruby-trunk -r mkmf -r fileutils -e ' include FileUtils class C include FileUtils::NoWrite def hoge p self.class.ancestors rm_rf("hoge") end end C.new.hoge' [C, FileUtils::NoWrite, Object, FileUtils, FileUtils::StreamUtils_, Kernel, BasicObject] /home/kazu/opt/ruby-trunk/lib/ruby/1.9.1/mkmf.rb:201:in `[]': can't convert Hash into String (TypeError) from /home/kazu/opt/ruby-trunk/lib/ruby/1.9.1/mkmf.rb:201:in `rm_rf' from /home/kazu/opt/ruby-trunk/lib/ruby/1.9.1/fileutils.rb:1556:in `rm_rf' from -e:7:in `hoge' from -e:10:in `
' % ---------------------------------------- http://redmine.ruby-lang.org