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 2013/12/18 21:18:33 UTC

svn commit: r1552079 - /subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py

Author: rhuijben
Date: Wed Dec 18 20:18:33 2013
New Revision: 1552079

URL: http://svn.apache.org/r1552079
Log:
Following up on r1552065, resolve an old todo by moving the creation of the
authz file to the build operation of the sandbox. This avoids writing the
file twice for every sandbox.

Also read the file before replacing it. This makes the parallel behavior more
stable on Windows while I'm trying to find out why
svntest.main.options.parallel is 0 on Windows even when running tests
in parallel.

* subversion/tests/cmdline/svntest/sandbox.py
  (_set_name): Move some code from here to...
  (build): ... here.

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

Modified: subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py?rev=1552079&r1=1552078&r2=1552079&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py Wed Dec 18 20:18:33 2013
@@ -63,26 +63,9 @@ class Sandbox:
       self.repo_dir = svntest.main.pristine_greek_repos_dir
       self.repo_url = svntest.main.pristine_greek_repos_url
 
-    ### TODO: Move this into to the build() method
-    # For dav tests we need a single authz file which must be present,
-    # so we recreate it each time a sandbox is created with some default
-    # contents, making sure that an empty file is never present
     if self.repo_url.startswith("http"):
-      # this dir doesn't exist out of the box, so we may have to make it
-      if not os.path.exists(svntest.main.work_dir):
-        os.makedirs(svntest.main.work_dir)
       self.authz_file = os.path.join(svntest.main.work_dir, "authz")
       self.groups_file = os.path.join(svntest.main.work_dir, "groups")
-
-      if svntest.main.options.parallel == 0:
-        # Never, ever do this when running the tests in parallel.
-        tmp_authz_file = os.path.join(svntest.main.work_dir, "authz-" + self.name)
-        open(tmp_authz_file, 'w').write("[/]\n* = rw\n")
-        shutil.move(tmp_authz_file, self.authz_file)
-
-    # For svnserve tests we have a per-repository authz file, and it
-    # doesn't need to be there in order for things to work, so we don't
-    # have any default contents.
     elif self.repo_url.startswith("svn"):
       self.authz_file = os.path.join(self.repo_dir, "conf", "authz")
       self.groups_file = os.path.join(self.repo_dir, "conf", "groups")
@@ -114,6 +97,20 @@ class Sandbox:
     svntest.actions.make_repo_and_wc(self, create_wc, read_only, minor_version)
     self._is_built = True
 
+    if not os.path.exists(svntest.main.work_dir):
+      os.makedirs(svntest.main.work_dir)
+
+    if self.repo_url.startswith("http"):
+      default_authz = "[/]\n* = rw\n"
+
+      if (svntest.main.options.parallel == 0
+          and (not os.path.isfile(self.authz_file)
+               or open(self.authz_file,'r').read() != default_authz)):
+
+        tmp_authz_file = os.path.join(svntest.main.work_dir, "authz-" + self.name)
+        open(tmp_authz_file, 'w').write(default_authz)
+        shutil.move(tmp_authz_file, self.authz_file)
+
   def authz_name(self, repo_dir=None):
     "return this sandbox's name for use in an authz file"
     repo_dir = repo_dir or self.repo_dir