You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2010/08/05 15:13:26 UTC

svn commit: r982603 - in /subversion/trunk/subversion/tests/cmdline: export_tests.py svntest/sandbox.py

Author: rhuijben
Date: Thu Aug  5 13:13:26 2010
New Revision: 982603

URL: http://svn.apache.org/viewvc?rev=982603&view=rev
Log:
Add a simple sandbox helper to create a stable temporary filename and
use this to fix the new export test on Windows. (This failed because
the handle returned from mkstemp was kept open during cleanup).

* subversion/tests/cmdline/export_tests.py
  (export_externals_with_native_eol): Use sbox.get_tempname() to create
    a name for a tempfile.

* subversion/tests/cmdline/svntest/sandbox.py
  (tempname_offs): New instance variable
  (get_tempname): New function.

Modified:
    subversion/trunk/subversion/tests/cmdline/export_tests.py
    subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py

Modified: subversion/trunk/subversion/tests/cmdline/export_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/export_tests.py?rev=982603&r1=982602&r2=982603&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/export_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/export_tests.py Thu Aug  5 13:13:26 2010
@@ -570,7 +570,7 @@ def export_externals_with_native_eol(sbo
   externals_prop = """^/A/B/E/alpha exfile_alpha 
   ^/A/B/E exdir_E"""
   
-  (fd, tmp_f) = tempfile.mkstemp(dir=svntest.main.temp_dir)
+  tmp_f = sbox.get_tempname('props')
   svntest.main.file_append(tmp_f, externals_prop)
   svntest.main.run_svn(None, 'ps', '-F', tmp_f, 'svn:externals', C_path)
   svntest.main.run_svn(None,'ci', '-m', 'log msg', '--quiet', C_path)

Modified: subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py?rev=982603&r1=982602&r2=982603&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py Thu Aug  5 13:13:26 2010
@@ -133,6 +133,20 @@ class Sandbox:
     self.add_test_path(path, remove)
     return path
 
+  tempname_offs = 0 # Counter for get_tempname
+
+  def get_tempname(self, prefix='tmp'):
+    """Get a stable name for a temporary file that will be removed after
+       running the test"""
+
+    dir = self.add_wc_path('tmp')
+    if not os.path.exists(dir):
+      os.mkdir(dir)
+
+    self.tempname_offs = self.tempname_offs + 1
+
+    return os.path.join(dir, '%s-%s' % (prefix, self.tempname_offs))
+
   def cleanup_test_paths(self):
     "Clean up detritus from this sandbox, and any dependents."
     if self.dependents: