Project

General

Profile

Actions

Bug #2111

closed

Error:test_rm_f(TestFileUtils)

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

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-09-17 trunk 24982) [i686-linux]
Backport:
[ruby-dev:39345]

Description

=begin
rm_f の引数の意味が FileUtils.rm_f と mkmf.rb の rm_f で違うため、
mkmf と rake が require されていると test_rm_f が mkmf.rb の
rm_f で Dir[*files] の files が配列の配列になっていてエラーになります。

rm_f の違いとしては FileUtils.rm_f は
rm_f(list, options = {})
で複数ファイルは配列でしか指定できないのに対して、
mkmf.rb の方の rm_f は
rm_f(*files)
となっていて、複数引数でも指定できるようになっています。

さらに mkmf.rb の方は Dir.[] も通すので、グロブの
ワイルドカードなどになる文字が含まれているときの
挙動が変わると思います。

% ruby-trunk -r rake -r mkmf -v test/fileutils/test_fileutils.rb -n test_rm_f
ruby 1.9.2dev (2009-09-17 trunk 24982) [i686-linux]
Loaded suite test/fileutils/test_fileutils
Started
cp data/a tmp/rmsrc
cp data/all tmp/rmsrc
cp data/random tmp/rmsrc
cp data/zero tmp/rmsrc
E
Finished in 0.013124 seconds.

  1. Error:
    test_rm_f(TestFileUtils):
    TypeError: can't convert Array into String
    test/fileutils/test_fileutils.rb:425:in `test_rm_f'

1 tests, 7 assertions, 0 failures, 1 errors, 0 skips
%
=end

Actions #1

Updated by nobu (Nobuyoshi Nakada) over 14 years ago

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

=begin
Applied in changeset r24984.
=end

Actions #2

Updated by znz (Kazuhiro NISHIYAMA) over 14 years ago

  • Status changed from Closed to Open

=begin
後半の件についてテストを追加したので reopen します。

% ruby-trunk test/fileutils/test_fileutils.rb -n test_rm_f
Loaded suite test/fileutils/test_fileutils
Started
.
Finished in 0.014927 seconds.

1 tests, 15 assertions, 0 failures, 0 errors, 0 skips
% ruby-trunk -r rake -r mkmf test/fileutils/test_fileutils.rb -n test_rm_f
Loaded suite test/fileutils/test_fileutils
Started
cp data/a tmp/rmsrc
cp data/all tmp/rmsrc
cp data/random tmp/rmsrc
cp data/zero tmp/rmsrc
touch tmp/rmtmp1
touch tmp/rmtmp2
touch tmp/rmtmp3
touch tmp/rmtmp4
touch tmp/[rmtmp]
F
Finished in 0.018555 seconds.

  1. Failure:
    test_rm_f(TestFileUtils) [test/fileutils/test_fileutils.rb:447]:
    file not exist: tmp/[rmtmp].
    Expected block to return true value.

1 tests, 15 assertions, 1 failures, 0 errors, 0 skips

=end

Actions #3

Updated by Anonymous over 14 years ago

  • Status changed from Open to Closed

=begin
Applied in changeset r24987.
=end

Actions #4

Updated by znz (Kazuhiro NISHIYAMA) over 14 years ago

  • Status changed from Closed to Open

=begin
タイミングが悪かったのでもう一度reopen。

include する順番によって include したクラスと Object の間に FileUtils が入ったり入らなかったりするのも問題の原因の一つだと思うのですが、どうでしょうか。

% ruby-trunk -r fileutils -e '
class C1
p ancestors
include FileUtils
p ancestors
require "rake"
p ancestors
end
class C2
p ancestors
include FileUtils
p ancestors
end'
[C1, Object, Kernel, BasicObject]
[C1, FileUtils, FileUtils::StreamUtils_, Object, Kernel, BasicObject]
[C1, FileUtils, FileUtils::StreamUtils_, Object, RakeFileUtils, FileUtils, FileUtils::StreamUtils_, Kernel, BasicObject]
[C2, Object, RakeFileUtils, FileUtils, FileUtils::StreamUtils_, Kernel, BasicObject]
[C2, Object, RakeFileUtils, FileUtils, FileUtils::StreamUtils_, Kernel, BasicObject]
%
=end

Actions #5

Updated by naruse (Yui NARUSE) over 14 years ago

  • Status changed from Open to Feedback

=begin
なおってますよね?
=end

Actions #6

Updated by znz (Kazuhiro NISHIYAMA) over 14 years ago

  • Status changed from Feedback to Open

=begin
直っていないように見えます。

% ruby-trunk -v
ruby 1.9.2dev (2009-10-22 trunk 25429) [i686-linux]
% ruby-trunk -r rake -r mkmf test/fileutils/test_fileutils.rb
(略)

  1. Failure:
    test_rm_pathname(TestFileUtils) [test/fileutils/test_fileutils.rb:456]:
    file not exist: tmp/[rmtmp].
    Expected block to return true value.

72 tests, 371 assertions, 1 failures, 0 errors, 0 skips
%
=end

Actions #7

Updated by naruse (Yui NARUSE) over 14 years ago

  • Status changed from Open to Closed

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

=end

Actions #8

Updated by znz (Kazuhiro NISHIYAMA) over 14 years ago

=begin
include FileUtils をした時の rm_f の挙動を確認するテストのはずなのに
FileUtils.rm_f を使うように変更しても良いのでしょうか?
=end

Actions #9

Updated by naruse (Yui NARUSE) over 14 years ago

=begin

include FileUtils をした時の rm_f の挙動を確認するテストのはずなのに

む、あの行はこのチケット用ですか。
ならばあの行が存在すること自体が誤りでしょう。
include の順番のテストが欲しいならば 別に用意するべきで、FileUtils でやるべきではありません。
=end

Actions #10

Updated by znz (Kazuhiro NISHIYAMA) over 14 years ago

=begin

include の順番のテストが欲しいならば 別に用意するべきで、FileUtils でやるべきではありません。

include の順番のテストではなく、 include FileUtils した FileUtils のメソッドのテストかと思っていました。

確実に FileUtils のメソッドをテストしたいのなら include の順番の影響を受けないように、 include FileUtils をやめて、他もすべて FileUtils.rm_f などにした方が良いのではないでしょうか?
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0