Project

General

Profile

Actions

Backport #1976

closed

Errors in test/fileutils/test_fileutils.rb

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

Status:
Closed
[ruby-dev:39150]

Description

=begin
環境によっては test_fileutils.rb でエラーになることがあるようです。

  1. 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'

  2. 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'

  3. 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

Actions #1

Updated by znz (Kazuhiro NISHIYAMA) over 14 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

Actions #2

Updated by yugui (Yuki Sonoda) over 14 years ago

  • Target version set to 1.9.2

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

Actions #3

Updated by nobu (Nobuyoshi Nakada) over 14 years ago

  • Status changed from Open to Closed

=begin
Applied in changeset r24620.
=end

Actions #4

Updated by nobu (Nobuyoshi Nakada) over 14 years ago

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

=begin

=end

Actions #5

Updated by yugui (Yuki Sonoda) over 14 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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0