Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Trouble with FileUtils.rm_rf / .rmdir
James Byrne
2/21/2006 6:11:00 PM
I am trying to dynamically setup and teardown a directory structure for
testing. The code that I am using employs .rm_rf but I get the same
results if I use
rmdir instead.
#-------------------------------------------------------------------------
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'test/unit'
require 'fileutils'
require 'mv2dir'
class Test_Mv2Dir < Test::Unit::TestCase
# What are we going to test for?
#1. Test that instances test for valid directories and return
# TRUE or FALSE as expected.
def test_dir
#-- a. define test directories
dir_test =
["~/tmp/mv2dir/test/source/","~/tmp/mv2dir/test/target/"]
#-- b. clear them out:
dir_test.each do |dt|
puts dt
FileUtils.rm_rf(dt, :verbose => TRUE, :secure => TRUE)
# FileUtils.rmdir(dt, :verbose => TRUE) rescue Errno::ENOENT
end
...
#---------------------------------------------------------------------------
These are the results. ~/tmp/mv2dir/test/target exists before the run.
It is my intention that it be gone at the end of the run. It is not.
Can
anyone point out to me what I am doing wrong?
ll ~/tmp/mv2dir/test/
total 8
drwxrwxr-x 2 byrnejb byrnejb 4096 Feb 21 12:11 target
[byrnejb@inet05 test]$ ruby mv2dir_tc.rb
Loaded suite mv2dir_tc
Started
~/tmp/mv2dir/test/source/
rm -rf ~/tmp/mv2dir/test/source/
~/tmp/mv2dir/test/target/
rm -rf ~/tmp/mv2dir/test/target/
...
Finished in 0.002761 seconds.
3 tests, 0 assertions, 0 failures, 0 errors
[byrnejb@inet05 test]$ ll ~/tmp/mv2dir/test/
total 8
drwxrwxr-x 2 byrnejb byrnejb 4096 Feb 21 12:11 target
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Trouble with FileUtils.rm_rf / .rmdir
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password