Project

General

Profile

Backport #1976

Errors in test/fileutils/test_fileutils.rb

Added by znz (Kazuhiro NISHIYAMA) almost 10 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
[ruby-dev:39150]

Description

=begin
環境によっては 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 `'
%
=end

Associated revisions

Revision 636840b3
Added by yugui (Yuki Sonoda) over 9 years ago

merges r24620 from trunk into ruby_1_9_1. fixes the backport task #1976.

  • lib/mkmf.rb (rm_f, rm_rf): pass the last hash through if exists. [ruby-dev:39153]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@26009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

#1

Updated by znz (Kazuhiro NISHIYAMA) almost 10 years ago

=begin
ancestors でわかるように rake が include FileUtils 相当になっていて、
rake と mkmf の両方が require 済みの時にエラーになるようです。

% ruby-trunk -r rake -r mkmf -I test/fileutils test/fileutils/test_nowrite.rb
Loaded suite test/fileutils/test_nowrite
Started
cp data/src tmp/cp
.mkdir dir
.mkdir dir/dir/dir
.mv data/src tmp/mv
.rm data/src
.EE.
Finished in 0.042309 seconds.

1) Error:
test_rm_f(TestFileUtilsNoWrite):
TypeError: can't convert Hash into String
test/fileutils/test_nowrite.rb:78:in `test_rm_f'

2) Error:
test_rm_rf(TestFileUtilsNoWrite):
TypeError: can't convert Hash into String
test/fileutils/test_nowrite.rb:84:in `test_rm_rf'

8 tests, 186 assertions, 0 failures, 2 errors, 0 skips
% ruby-trunk -r mkmf -r rake -I test/fileutils test/fileutils/test_nowrite.rb
Loaded suite test/fileutils/test_nowrite
Started
cp data/src tmp/cp
.mkdir dir
.mkdir dir/dir/dir
.mv data/src tmp/mv
.rm data/src
.EE.
Finished in 0.043323 seconds.

1) Error:
test_rm_f(TestFileUtilsNoWrite):
TypeError: can't convert Hash into String
test/fileutils/test_nowrite.rb:78:in `test_rm_f'

2) Error:
test_rm_rf(TestFileUtilsNoWrite):
TypeError: can't convert Hash into String
test/fileutils/test_nowrite.rb:84:in `test_rm_rf'

8 tests, 186 assertions, 0 failures, 2 errors, 0 skips
%
=end

#2

Updated by yugui (Yuki Sonoda) almost 10 years ago

  • Target version set to 1.9.2

=begin
Rakeがinclude FileUtilsすること自体は好きにすればよいとして、make testには成功してもらいたいですね。
make testでも失敗しますでしょうか。
=end

#3

Updated by nobu (Nobuyoshi Nakada) almost 10 years ago

  • Status changed from Open to Closed

=begin
Applied in changeset r24620.
=end

#4

Updated by nobu (Nobuyoshi Nakada) almost 10 years ago

  • Status changed from Closed to Assigned
  • Assignee set to yugui (Yuki Sonoda)

=begin

=end

#5

Updated by yugui (Yuki Sonoda) over 9 years ago

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

=begin
This issue was solved with changeset r26009.
Kazuhiro, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Also available in: Atom PDF