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/04/06 02:44:34 UTC

svn commit: r930990 - /subversion/trunk/subversion/tests/cmdline/patch_tests.py

Author: rhuijben
Date: Tue Apr  6 00:44:34 2010
New Revision: 930990

URL: http://svn.apache.org/viewvc?rev=930990&view=rev
Log:
Properly close temporary file handles to allow the delete of the
temporary files to succeed on Windows. This resolves the

Running tests in patch_tests.py [25/43].............FAILURE

error reported by not parallel Windows buildbot.

* subversion/tests/cmdline/patch_tests.py
  (patch, patch_absolute_paths, patch_offset,
   patch_chopped_leading_spaces, patch_strip1,
   patch_add_new_dir, patch_reject, patch_keywords,
   patch_with_fuzz, patch_reverse, patch_no_svn_eol_style,
   patch_with_svn_eol_style, patch_with_svn_eol_style_uncommitted
   patch_with_include_patterns, patch_with_exclude_patterns,
   patch_with_include_exclude_patterns): Close files opened by mkstemp.

Modified:
    subversion/trunk/subversion/tests/cmdline/patch_tests.py

Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=930990&r1=930989&r2=930990&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Tue Apr  6 00:44:34 2010
@@ -55,7 +55,8 @@ def patch(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -226,7 +227,8 @@ def patch_absolute_paths(sbox):
   wc_dir = sbox.wc_dir
 
   dir = os.path.abspath(svntest.main.temp_dir)
-  patch_file_path = tempfile.mkstemp(dir=dir)[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=dir)
+  os.close(fd)
 
   os.chdir(wc_dir)
 
@@ -289,7 +291,8 @@ def patch_offset(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
   iota_path = os.path.join(wc_dir, 'iota')
 
@@ -502,7 +505,8 @@ def patch_chopped_leading_spaces(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -672,7 +676,8 @@ def patch_strip1(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -842,7 +847,8 @@ def patch_add_new_dir(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
 
   # The first diff is adding 'new' with two missing dirs. The second is
   # adding 'new' with one missing dir to a 'A' that is locally deleted
@@ -930,7 +936,8 @@ def patch_reject(sbox):
   svntest.actions.run_and_verify_commit(wc_dir, expected_output,
                                         expected_status, None, wc_dir)
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
 
   # Apply patch
 
@@ -1003,7 +1010,8 @@ def patch_keywords(sbox):
   svntest.actions.run_and_verify_commit(wc_dir, expected_output,
                                         expected_status, None, wc_dir)
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
 
   # Apply patch
 
@@ -1048,7 +1056,8 @@ def patch_with_fuzz(sbox):
 
   sbox.build()
   wc_dir = sbox.wc_dir
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
 
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
@@ -1188,7 +1197,8 @@ def patch_reverse(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -1358,7 +1368,8 @@ def patch_no_svn_eol_style(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   if os.name == 'nt':
@@ -1461,7 +1472,8 @@ def patch_with_svn_eol_style(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
 
@@ -1575,7 +1587,8 @@ def patch_with_svn_eol_style_uncommitted
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
 
@@ -1683,7 +1696,8 @@ def patch_with_include_patterns(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -1841,7 +1855,8 @@ def patch_with_exclude_patterns(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -2001,7 +2016,8 @@ def patch_with_include_exclude_patterns(
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
+  os.close(fd)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [



Re: svn commit: r930990 - /subversion/trunk/subversion/tests/cmdline/patch_tests.py

Posted by Stefan Sperling <st...@elego.de>.
On Tue, Apr 06, 2010 at 12:44:34AM -0000, rhuijben@apache.org wrote:
> Author: rhuijben
> Date: Tue Apr  6 00:44:34 2010
> New Revision: 930990
> 
> URL: http://svn.apache.org/viewvc?rev=930990&view=rev
> Log:
> Properly close temporary file handles to allow the delete of the
> temporary files to succeed on Windows. This resolves the
> 
> Running tests in patch_tests.py [25/43].............FAILURE
> 
> error reported by not parallel Windows buildbot.
> 
> * subversion/tests/cmdline/patch_tests.py
>   (patch, patch_absolute_paths, patch_offset,
>    patch_chopped_leading_spaces, patch_strip1,
>    patch_add_new_dir, patch_reject, patch_keywords,
>    patch_with_fuzz, patch_reverse, patch_no_svn_eol_style,
>    patch_with_svn_eol_style, patch_with_svn_eol_style_uncommitted
>    patch_with_include_patterns, patch_with_exclude_patterns,
>    patch_with_include_exclude_patterns): Close files opened by mkstemp.

Before I apply a similar fix to patch_no_index_line(), I wanted to
ask if is there a special reason why you are closing the fd right after
creating the temporary file? Can't we delay closing it until we're ready
to remove the file, after patching? So that closing the patch file
is the very last thing each test is doing?

Stefan