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/12 14:13:54 UTC

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

Author: rhuijben
Date: Mon Apr 12 12:13:53 2010
New Revision: 933211

URL: http://svn.apache.org/viewvc?rev=933211&view=rev
Log:
Add a helper function to create a patch file with a specific
name in a per test temporary directory and use that to avoid
mkstemp's use of file handles.

* subversion/tests/cmdline/patch_tests.py
  (make_patch_path): New function.
  (*): Use make_patch_path instead of calling msktemp and then
       closing the handle.

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=933211&r1=933210&r2=933211&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Mon Apr 12 12:13:53 2010
@@ -46,6 +46,11 @@ SkipUnless = svntest.testcase.SkipUnless
 Item = svntest.wc.StateItem
 XFail = svntest.testcase.XFail
 
+def make_patch_path(sbox, name='my.patch'):
+  dir = sbox.add_wc_path('patches')
+  os.mkdir(dir)
+  return os.path.abspath(os.path.join(dir, name))
+
 ########################################################################
 #Tests
 
@@ -55,8 +60,7 @@ def patch(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -226,9 +230,7 @@ def patch_absolute_paths(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  dir = os.path.abspath(svntest.main.temp_dir)
-  (fd, patch_file_path) = tempfile.mkstemp(dir=dir)
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
 
   os.chdir(wc_dir)
 
@@ -291,8 +293,7 @@ def patch_offset(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
   iota_path = os.path.join(wc_dir, 'iota')
 
@@ -505,8 +506,7 @@ def patch_chopped_leading_spaces(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -676,8 +676,7 @@ def patch_strip1(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -847,7 +846,7 @@ def patch_no_index_line(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  patch_file_path = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))[1]
+  patch_file_path = make_patch_path(sbox)
   gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')
   iota_path = os.path.join(wc_dir, 'iota')
 
@@ -933,8 +932,7 @@ def patch_add_new_dir(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
 
   # 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
@@ -1022,8 +1020,7 @@ def patch_reject(sbox):
   svntest.actions.run_and_verify_commit(wc_dir, expected_output,
                                         expected_status, None, wc_dir)
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
 
   # Apply patch
 
@@ -1096,8 +1093,7 @@ def patch_keywords(sbox):
   svntest.actions.run_and_verify_commit(wc_dir, expected_output,
                                         expected_status, None, wc_dir)
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
 
   # Apply patch
 
@@ -1142,8 +1138,7 @@ def patch_with_fuzz(sbox):
 
   sbox.build()
   wc_dir = sbox.wc_dir
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
 
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
@@ -1283,8 +1278,7 @@ def patch_reverse(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -1454,8 +1448,7 @@ def patch_no_svn_eol_style(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   if os.name == 'nt':
@@ -1558,8 +1551,7 @@ def patch_with_svn_eol_style(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
 
@@ -1673,8 +1665,7 @@ def patch_with_svn_eol_style_uncommitted
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
 
@@ -1782,8 +1773,7 @@ def patch_with_include_patterns(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -1941,8 +1931,7 @@ def patch_with_exclude_patterns(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [
@@ -2102,8 +2091,7 @@ def patch_with_include_exclude_patterns(
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  (fd, patch_file_path) = tempfile.mkstemp(dir=os.path.abspath(svntest.main.temp_dir))
-  os.close(fd)
+  patch_file_path = make_patch_path(sbox)
   mu_path = os.path.join(wc_dir, 'A', 'mu')
 
   mu_contents = [