Author: joeswatosh
Date: Wed Dec 9 06:08:21 2009
New Revision: 888708
URL: http://svn.apache.org/viewvc?rev=888708&view=rev
Log:
Take particular care managing the files created during tests. While the pool
clean up will delete the files as it should, there can be timing problems on
Windows.
Also on Windows, if the file is open, it cannot be deleted. So wait and try
again a few times to give garbage collection (or the svnserve process) more
chances to let it go.
Finally, Svn::Repos.delete was failing intermittently, so replace the call
to it when cleaning up tests with just removing the directory.
* subversion/bindings/swig/ruby/test/util.rb
(SvnTestUtil#setup_tmp, SvnTestUtil#teardown_tmp,
SvnTestUtil#setup_repository, SvnTestUtil#teardown_wc,
SvnTestUtil#teardown_config): Replace call to File.rm_rf with
remove_recursively_with_retry
(SvnTestUtil#teardown_repository): Replace call to Svn::Repos.delete with
remove_recursively_with_retry(path)
(SvnTestUtil#remove_recursively_with_retry): New method
* subversion/bindings/swig/ruby/test/test_client.rb
(SvnClientTest#test_checkout): Replace call to File.rm_rf with
remove_recursively_with_retry
* subversion/bindings/swig/ruby/test/test_fs.rb
(SvnFsTest#assert_recover): Pass an empty Proc to the yield that creates
the file system. There is currently no way to clean up the pool that is
used if there is no block passed to Svn::Fs.create.
* subversion/bindings/swig/ruby/test/test_wc.rb
(SvnWcTest#test_translated_file2_eol): Make sure a file passed to the block
for assert_translated_eol is closed.
(SvnWcTest#test_translated_stream_keyword): Make sure a stream passed to
the block for assert_translated_keyword is closed.
Modified:
subversion/trunk/subversion/bindings/swig/ruby/test/test_client.rb
subversion/trunk/subversion/bindings/swig/ruby/test/test_fs.rb
subversion/trunk/subversion/bindings/swig/ruby/test/test_wc.rb
subversion/trunk/subversion/bindings/swig/ruby/test/util.rb
Modified: subversion/trunk/subversion/bindings/swig/ruby/test/test_client.rb
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/ruby/test/test_client.rb?rev=888708&r1=888707&r2=888708&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/ruby/test/test_client.rb
(original)
+++ subversion/trunk/subversion/bindings/swig/ruby/test/test_client.rb Wed Dec
9 06:08:21 2009
@@ -537,8 +537,8 @@
assert(!File.exist?(path3))
end
ensure
- FileUtils.rm_rf(wc_path3)
- FileUtils.rm_rf(wc_path2)
+ remove_recursively_with_retry(wc_path3)
+ remove_recursively_with_retry(wc_path2)
end
def test_update
Modified: subversion/trunk/subversion/bindings/swig/ruby/test/test_fs.rb
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/ruby/test/test_fs.rb?rev=888708&r1=888707&r2=888708&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/ruby/test/test_fs.rb (original)
+++ subversion/trunk/subversion/bindings/swig/ruby/test/test_fs.rb Wed Dec 9
06:08:21 2009
@@ -443,7 +443,7 @@
fs_type = Svn::Fs::TYPE_FSFS
config = {Svn::Fs::CONFIG_FS_TYPE => fs_type}
- yield(:create, [path, config])
+ yield(:create, [path, config], Proc.new{})
assert_nothing_raised do
yield(:recover, [path], Proc.new{})
Modified: subversion/trunk/subversion/bindings/swig/ruby/test/test_wc.rb
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/ruby/test/test_wc.rb?rev=888708&r1=888707&r2=888708&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/ruby/test/test_wc.rb (original)
+++ subversion/trunk/subversion/bindings/swig/ruby/test/test_wc.rb Wed Dec 9
06:08:21 2009
@@ -570,7 +570,9 @@
def test_translated_file2_eol
assert_translated_eol(:translated_file2) do |file, source|
- file.read
+ result = file.read
+ file.close
+ result
end
end
@@ -636,7 +638,9 @@
stream.close
nil
else
- stream.read
+ result = stream.read
+ stream.close
+ result
end
end
end
Modified: subversion/trunk/subversion/bindings/swig/ruby/test/util.rb
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/ruby/test/util.rb?rev=888708&r1=888707&r2=888708&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/ruby/test/util.rb (original)
+++ subversion/trunk/subversion/bindings/swig/ruby/test/util.rb Wed Dec 9
06:08:21 2009
@@ -110,17 +110,17 @@
end
def setup_tmp(pa...@tmp_path)
- FileUtils.rm_rf(path)
+ remove_recursively_with_retry(path)
FileUtils.mkdir_p(path)
end
def teardown_tmp(pa...@tmp_path)
- FileUtils.rm_rf(path)
+ remove_recursively_with_retry(path)
end
def setup_repository(pa...@repos_path, config={}, fs_config={})
require "svn/repos"
- FileUtils.rm_rf(path)
+ remove_recursively_with_retry(path)
FileUtils.mkdir_p(File.dirname(path))
@repos = Svn::Repos.create(path, config, fs_config)
@fs = @repos.fs
@@ -129,7 +129,7 @@
def teardown_repository(pa...@repos_path)
@fs.close unless @fs.nil?
@repos.close unless @repos.nil?
- Svn::Repos.delete(path) if File.exists?(path)
+ remove_recursively_with_retry(path)
@repos = nil
@fs = nil
end
@@ -140,7 +140,7 @@
end
def teardown_wc
- FileUtils.rm_rf(@wc_base_dir)
+ remove_recursively_with_retry(@wc_base_dir)
end
def setup_config
@@ -149,7 +149,7 @@
end
def teardown_config
- FileUtils.rm_rf(@config_path)
+ remove_recursively_with_retry(@config_path)
end
def add_authentication
@@ -222,6 +222,18 @@
make_context("setup greek tree") { |ctx| @greek.setup(ctx) }
end
+ def remove_recursively_with_retry(path)
+ retries = 0
+ while (retries+=1) < 100 && File.exist?(path)
+ begin
+ FileUtils.rm_r(path, :secure=>true)
+ rescue
+ sleep 0.1
+ end
+ end
+ assert(!File.exist?(path), "#{Dir.glob(path+'/**/*').join("\n")} should
not exist after #{retries} attempts to delete")
+ end
+
module Svnserve
def setup_svnserve
@svnserve_port = nil