diff options
author | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-14 10:00:52 +0000 |
---|---|---|
committer | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-14 10:00:52 +0000 |
commit | 470e98a1275cb5e44f391eea4424bd87fdf83c19 (patch) | |
tree | f71a631434a04f00dda47d63764cdda5b71f88fd /test/fileutils | |
parent | 176e8f6b22a59659424a3d76dc7595411fba6bea (diff) | |
download | ruby-470e98a1275cb5e44f391eea4424bd87fdf83c19.tar.gz ruby-470e98a1275cb5e44f391eea4424bd87fdf83c19.tar.xz ruby-470e98a1275cb5e44f391eea4424bd87fdf83c19.zip |
* lib/fileutils.rb (remove_file): ignore exceptions caused by chmod.
* lib/fileutils.rb (remove_dir): try to get rights to rmdir. [ruby-Bugs:1502]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@8330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/fileutils')
-rw-r--r-- | test/fileutils/test_fileutils.rb | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index 6ecd25c0f..b959f0426 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -89,7 +89,6 @@ class TestFileUtils my_rm_rf 'data'; mymkdir 'data' my_rm_rf 'tmp'; mymkdir 'tmp' prepare_data_file - prepare_time_data end def teardown @@ -146,9 +145,9 @@ class TestFileUtils File.utime t-4, t-4, 'data/newer' end - def each_sample_file - TARGETS.each do |srcpath| - yield srcpath, "tmp/#{File.basename(srcpath)}" + def each_srcdest + TARGETS.each do |path| + yield path, "tmp/#{File.basename(path)}" end end @@ -191,7 +190,7 @@ end end def test_cp - each_sample_file do |srcpath, destpath| + each_srcdest do |srcpath, destpath| cp srcpath, destpath assert_same_file srcpath, destpath @@ -753,7 +752,7 @@ end end def test_copy_entry - each_sample_file do |srcpath, destpath| + each_srcdest do |srcpath, destpath| copy_entry srcpath, destpath assert_same_file srcpath, destpath assert_equal File.stat(srcpath).ftype, File.stat(destpath).ftype @@ -766,7 +765,7 @@ end end def test_copy_file - each_sample_file do |srcpath, destpath| + each_srcdest do |srcpath, destpath| copy_file srcpath, destpath assert_same_file srcpath, destpath end @@ -774,7 +773,7 @@ end def test_copy_stream # IO - each_sample_file do |srcpath, destpath| + each_srcdest do |srcpath, destpath| File.open(srcpath) {|src| File.open(destpath, 'w') {|dest| copy_stream src, dest @@ -786,7 +785,7 @@ end # duck typing test [ruby-dev:25369] rm_rf 'tmp' Dir.mkdir 'tmp' - each_sample_file do |srcpath, destpath| + each_srcdest do |srcpath, destpath| File.open(srcpath) {|src| File.open(destpath, 'w') {|dest| copy_stream Stream.new(src), Stream.new(dest) @@ -797,11 +796,28 @@ end end def test_remove_file - # FIXME + File.open('data/tmp', 'w') {|f| f.puts 'dummy' } + remove_file 'data/tmp' + assert_file_not_exist 'data/tmp' +if have_file_perm? + File.open('data/tmp', 'w') {|f| f.puts 'dummy' } + File.chmod 0, 'data/tmp' + remove_file 'data/tmp' + assert_file_not_exist 'data/tmp' +end end def test_remove_dir - # FIXME + Dir.mkdir 'data/tmpdir' + File.open('data/tmpdir/a', 'w') {|f| f.puts 'dummy' } + remove_dir 'data/tmpdir' + assert_file_not_exist 'data/tmpdir' +if have_file_perm? + Dir.mkdir 'data/tmpdir' + File.chmod 0555, 'data/tmpdir' + remove_dir 'data/tmpdir' + assert_file_not_exist 'data/tmpdir' +end end def test_compare_file @@ -827,6 +843,7 @@ end end def test_uptodate? + prepare_time_data Dir.chdir('data') { assert( uptodate?('newest', %w(old newer notexist)) ) assert( ! uptodate?('newer', %w(old newest notexist)) ) |