subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1657773 - in /subversion/trunk/subversion/tests/cmdline: log_tests.py move_tests.py svnadmin_tests.py svnrdump_tests.py svnsync_tests.py svntest/actions.py svntest/sandbox.py
Date Fri, 06 Feb 2015 10:17:03 GMT
Author: julianfoad
Date: Fri Feb  6 10:17:02 2015
New Revision: 1657773

URL: http://svn.apache.org/r1657773
Log:
In the Python test suite, allow building a sandbox with an empty repository
as an alternative to the default 'Greek tree' repository.

Use it in tests where we want an empty repository and were previously using
more than one line of code or in some cases were even redundantly creating
and deleting the default repository before creating an empty repository.

* subversion/tests/cmdline/svntest/actions.py
  (guarantee_empty_repository): Add a 'minor_version' argument.
  (make_repo_and_wc): Add an 'empty' optional argument.

* subversion/tests/cmdline/svntest/sandbox.py
  (Sandbox._set_name,
   Sandbox.build): Add an 'empty' optional argument.

Use it in tests where we were doing it the hard way:

* subversion/tests/cmdline/log_tests.py
  (merge_history_repos): Use sbox.build() to create an empty repo and WC.
  (log_with_empty_repos): Use sbox.build() to create an empty repo.

* subversion/tests/cmdline/move_tests.py
  (nested_replaces): Use sbox.build() to create an empty repo.

* subversion/tests/cmdline/svnadmin_tests.py
  (test_create): Use sbox.build() to create an empty repo.
  (create_in_repo_subdir,
   verify_with_invalid_revprops,
   hotcopy_symlink,
   recover_old_empty): Use sbox.build() to create an empty repo.
  (verify_denormalized_names,
   load_ignore_dates,
   fsfs_hotcopy_progress,
   fsfs_hotcopy_progress_with_revprop_changes,
   fsfs_hotcopy_progress_old): Use 'empty=True' to avoid creating, deleting
    and then recreating a repository.

* subversion/tests/cmdline/svnrdump_tests.py
  (build_repos): Delete.
  (compare_repos_dumps): Use sbox.build() to create an empty repo.
  (run_dump_test,
   run_load_test,
   reflect_dropped_renumbered_revs,
   load_prop_change_in_non_deltas_dump):
    Use sbox.build() instead of build_repos().

* subversion/tests/cmdline/svnsync_tests.py
  (build_repos): Delete.
  (setup_and_sync,
   detect_meddling,
   info_synchronized):
    Use sbox.build() instead of build_repos().

Modified:
    subversion/trunk/subversion/tests/cmdline/log_tests.py
    subversion/trunk/subversion/tests/cmdline/move_tests.py
    subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
    subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py
    subversion/trunk/subversion/tests/cmdline/svnsync_tests.py
    subversion/trunk/subversion/tests/cmdline/svntest/actions.py
    subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py

Modified: subversion/trunk/subversion/tests/cmdline/log_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/log_tests.py?rev=1657773&r1=1657772&r2=1657773&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/log_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/log_tests.py Fri Feb  6 10:17:02 2015
@@ -227,12 +227,7 @@ def merge_history_repos(sbox):
   branch_c = os.path.join('branches', 'c')
 
   # Create an empty repository - r0
-  svntest.main.safe_rmtree(sbox.repo_dir, 1)
-  svntest.main.safe_rmtree(sbox.wc_dir, 1)
-  svntest.main.create_repos(sbox.repo_dir)
-
-  svntest.actions.run_and_verify_svn(None, None, [], "co", sbox.repo_url,
-                                     sbox.wc_dir)
+  sbox.build(empty=True)
   was_cwd = os.getcwd()
   os.chdir(sbox.wc_dir)
 
@@ -751,8 +746,7 @@ def log_with_empty_repos(sbox):
   "'svn log' on an empty repository"
 
   # Create virgin repos
-  svntest.main.safe_rmtree(sbox.repo_dir, 1)
-  svntest.main.create_repos(sbox.repo_dir)
+  sbox.build(create_wc=False, empty=True)
 
   svntest.actions.run_and_verify_svn(None, None, [],
                                      'log',

Modified: subversion/trunk/subversion/tests/cmdline/move_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/move_tests.py?rev=1657773&r1=1657772&r2=1657773&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/move_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/move_tests.py Fri Feb  6 10:17:02 2015
@@ -1241,10 +1241,10 @@ def move_missing(sbox):
 def nested_replaces(sbox):
   "nested replaces"
 
-  repo_dir, repo_url = sbox.add_repo_path('blank')
-  wc_dir = sbox.add_wc_path('blank')
-  svntest.main.create_repos(repo_dir)
-  ospath = lambda dirent: sbox.ospath(dirent, wc_dir)
+  sbox.build(create_wc=False, empty=True)
+  repo_url = sbox.repo_url
+  wc_dir = sbox.wc_dir
+  ospath = sbox.ospath
 
   ## r1: setup
   svntest.actions.run_and_verify_svnmucc(None, None, [],

Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1657773&r1=1657772&r2=1657773&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Fri Feb  6 10:17:02 2015
@@ -427,21 +427,9 @@ def set_changed_path_list(sbox, revision
 def test_create(sbox, minor_version=None):
   "'svnadmin create'"
 
-
-  repo_dir = sbox.repo_dir
+  sbox.build(empty=True, minor_version=minor_version)
   wc_dir = sbox.wc_dir
 
-  svntest.main.safe_rmtree(repo_dir, 1)
-  svntest.main.safe_rmtree(wc_dir)
-
-  svntest.main.create_repos(repo_dir, minor_version)
-
-  svntest.actions.run_and_verify_svn("Creating rev 0 checkout",
-                                     ["Checked out revision 0.\n"], [],
-                                     "checkout",
-                                     sbox.repo_url, wc_dir)
-
-
   svntest.actions.run_and_verify_svn(
     "Running status",
     [], [],
@@ -1249,14 +1237,8 @@ def fsfs_recover_handle_missing_revs_or_
 def create_in_repo_subdir(sbox):
   "'svnadmin create /path/to/repo/subdir'"
 
+  sbox.build(create_wc=False, empty=True)
   repo_dir = sbox.repo_dir
-  wc_dir = sbox.wc_dir
-
-  svntest.main.safe_rmtree(repo_dir, 1)
-  svntest.main.safe_rmtree(wc_dir)
-
-  # This should succeed
-  svntest.main.create_repos(repo_dir)
 
   success = False
   try:
@@ -1287,13 +1269,9 @@ def create_in_repo_subdir(sbox):
 def verify_with_invalid_revprops(sbox):
   "svnadmin verify detects invalid revprops file"
 
+  sbox.build(create_wc=False, empty=True)
   repo_dir = sbox.repo_dir
 
-  svntest.main.safe_rmtree(repo_dir, 1)
-
-  # This should succeed
-  svntest.main.create_repos(repo_dir)
-
   # Run a test verify
   exit_code, output, errput = svntest.main.run_svnadmin("verify",
                                                         sbox.repo_dir)
@@ -1531,14 +1509,12 @@ def hotcopy_symlink(sbox):
 
   ## See http://subversion.tigris.org/issues/show_bug.cgi?id=2591. ##
 
+  # Create a repository.
+  sbox.build(create_wc=False, empty=True)
   original_repo = sbox.repo_dir
 
   hotcopy_repo, hotcopy_url = sbox.add_repo_path('hotcopy')
 
-  # Create a repository.
-  svntest.main.safe_rmtree(original_repo, 1)
-  svntest.main.create_repos(original_repo)
-
   # Create a file, a dir and a missing path outside the repoitory.
   svntest.main.safe_rmtree(sbox.wc_dir, 1)
   os.mkdir(sbox.wc_dir)
@@ -2078,8 +2054,7 @@ def mergeinfo_race(sbox):
 @Skip(svntest.main.is_fs_type_fsx)
 def recover_old_empty(sbox):
   "recover empty --compatible-version=1.3"
-  svntest.main.safe_rmtree(sbox.repo_dir, 1)
-  svntest.main.create_repos(sbox.repo_dir, minor_version=3)
+  sbox.build(create_wc=False, empty=True, minor_version=3)
   svntest.actions.run_and_verify_svnadmin(None, None, [],
                                           "recover", sbox.repo_dir)
 
@@ -2304,9 +2279,7 @@ def verify_invalid_path_changes(sbox):
 def verify_denormalized_names(sbox):
   "detect denormalized names and name collisions"
 
-  sbox.build(create_wc = False)
-  svntest.main.safe_rmtree(sbox.repo_dir, True)
-  svntest.main.create_repos(sbox.repo_dir)
+  sbox.build(create_wc=False, empty=True)
 
   dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
                                    'svnadmin_tests_data',
@@ -2382,10 +2355,8 @@ def load_ignore_dates(sbox):
   # All revisions in the loaded repository should come after this time.
   start_time = time.localtime()
   time.sleep(1)
-  
-  sbox.build(create_wc=False)
-  svntest.main.safe_rmtree(sbox.repo_dir, True)
-  svntest.main.create_repos(sbox.repo_dir)
+
+  sbox.build(create_wc=False, empty=True)
 
   dumpfile_skeleton = open(os.path.join(os.path.dirname(sys.argv[0]),
                                         'svnadmin_tests_data',
@@ -2695,9 +2666,7 @@ def fsfs_hotcopy_progress(sbox):
     raise svntest.Skip
 
   # Create an empty repository, configure three files per shard.
-  sbox.build(create_wc=False)
-  svntest.main.safe_rmtree(sbox.repo_dir, True)
-  svntest.main.create_repos(sbox.repo_dir)
+  sbox.build(create_wc=False, empty=True)
   patch_format(sbox.repo_dir, shard_size=3)
 
   inc_backup_dir, inc_backup_url = sbox.add_repo_path('incremental-backup')
@@ -2811,9 +2780,7 @@ def fsfs_hotcopy_progress_with_revprop_c
     raise svntest.Skip
 
   # Create an empty repository, commit several revisions and hotcopy it.
-  sbox.build(create_wc=False)
-  svntest.main.safe_rmtree(sbox.repo_dir, True)
-  svntest.main.create_repos(sbox.repo_dir)
+  sbox.build(create_wc=False, empty=True)
 
   for i in range(6):
     svntest.actions.run_and_verify_svn(None, None, [], 'mkdir',
@@ -2858,9 +2825,7 @@ def fsfs_hotcopy_progress_with_revprop_c
 def fsfs_hotcopy_progress_old(sbox):
   "hotcopy --compatible-version=1.3 progress"
 
-  sbox.build(create_wc=False)
-  svntest.main.safe_rmtree(sbox.repo_dir, True)
-  svntest.main.create_repos(sbox.repo_dir, minor_version=3)
+  sbox.build(create_wc=False, empty=True, minor_version=3)
 
   inc_backup_dir, inc_backup_url = sbox.add_repo_path('incremental-backup')
 

Modified: subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py?rev=1657773&r1=1657772&r2=1657773&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py Fri Feb  6 10:17:02 2015
@@ -61,15 +61,6 @@ mismatched_headers_re = re.compile(
 ######################################################################
 # Helper routines
 
-def build_repos(sbox):
-  """Build an empty sandbox repository"""
-
-  # Cleanup after the last run by removing any left-over repository.
-  svntest.main.safe_rmtree(sbox.repo_dir)
-
-  # Create an empty repository.
-  svntest.main.create_repos(sbox.repo_dir)
-
 def compare_repos_dumps(sbox, other_dumpfile,
                         bypass_prop_validation=False):
   """Compare two dumpfiles, one created from SBOX, and other given
@@ -83,8 +74,7 @@ def compare_repos_dumps(sbox, other_dump
 
   # Load and dump the other dumpfile (using svnadmin)
   other_sbox = sbox.clone_dependent()
-  svntest.main.safe_rmtree(other_sbox.repo_dir)
-  svntest.main.create_repos(other_sbox.repo_dir)
+  other_sbox.build(create_wc=False, empty=True)
   svntest.actions.run_and_verify_load(other_sbox.repo_dir, other_dumpfile,
                                       bypass_prop_validation)
   other_dumpfile = svntest.actions.run_and_verify_dump(other_sbox.repo_dir)
@@ -104,7 +94,7 @@ def run_dump_test(sbox, dumpfile_name, e
   array of optional additional options to pass to 'svnrdump dump'."""
 
   # Create an empty sandbox repository
-  build_repos(sbox)
+  sbox.build(create_wc=False, empty=True)
 
   # This directory contains all the dump files
   svnrdump_tests_dir = os.path.join(os.path.dirname(sys.argv[0]),
@@ -159,7 +149,7 @@ def run_load_test(sbox, dumpfile_name, e
   dump' and check that the same dumpfile is produced"""
 
   # Create an empty sandbox repository
-  build_repos(sbox)
+  sbox.build(create_wc=False, empty=True)
 
   # Create the revprop-change hook for this test
   svntest.actions.enable_revprop_changes(sbox.repo_dir)
@@ -412,7 +402,7 @@ def reflect_dropped_renumbered_revs(sbox
   "svnrdump renumbers dropped revs in mergeinfo"
 
   # Create an empty sandbox repository
-  build_repos(sbox)
+  sbox.build(create_wc=False, empty=True)
 
   # Create the revprop-change hook for this test
   svntest.actions.enable_revprop_changes(sbox.repo_dir)
@@ -723,7 +713,7 @@ def svnrdump_load_partial_incremental_du
   "svnrdump load partial incremental dump"
 
   # Create an empty sandbox repository
-  build_repos(sbox)
+  sbox.build(create_wc=False, empty=True)
 
   # Create the revprop-change hook for this test
   svntest.actions.enable_revprop_changes(sbox.repo_dir)
@@ -795,7 +785,7 @@ def load_prop_change_in_non_deltas_dump(
   dump = svntest.actions.run_and_verify_dump(sbox.repo_dir, deltas=False)
 
   # Try to load that dump.
-  build_repos(sbox)
+  sbox.build(create_wc=False, empty=True)
   svntest.actions.enable_revprop_changes(sbox.repo_dir)
   svntest.actions.run_and_verify_svnrdump(dump,
                                           [], [], 0,

Modified: subversion/trunk/subversion/tests/cmdline/svnsync_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnsync_tests.py?rev=1657773&r1=1657772&r2=1657773&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnsync_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnsync_tests.py Fri Feb  6 10:17:02 2015
@@ -49,16 +49,6 @@ Item = svntest.wc.StateItem
 # Helper routines
 
 
-def build_repos(sbox):
-  """Avoid the use sbox.build() because we're working with a repos
-  other than the Greek tree."""
-  # Cleanup after the last run by removing any left-over repository.
-  svntest.main.safe_rmtree(sbox.repo_dir)
-
-  # Create an empty repository.
-  svntest.main.create_repos(sbox.repo_dir)
-
-
 def run_sync(url, source_url=None, expected_error=None,
              source_prop_encoding=None):
   "Synchronize the mirror repository with the master"
@@ -158,7 +148,7 @@ def setup_and_sync(sbox, dump_file_conte
   """Create a repository for SBOX, load it with DUMP_FILE_CONTENTS, then create a mirror
repository and sync it with SBOX. If is_src_ra_local or is_dest_ra_local is True, then run_init,
run_sync, and run_copy_revprops will use the file:// scheme for the source and destination
URLs.  Return the mirror sandbox."""
 
   # Create the empty master repository.
-  build_repos(sbox)
+  sbox.build(create_wc=False, empty=True)
 
   # Load the repository from DUMP_FILE_PATH.
   svntest.actions.run_and_verify_load(sbox.repo_dir, dump_file_contents,
@@ -166,7 +156,7 @@ def setup_and_sync(sbox, dump_file_conte
 
   # Create the empty destination repository.
   dest_sbox = sbox.clone_dependent()
-  build_repos(dest_sbox)
+  dest_sbox.build(create_wc=False, empty=True)
 
   # Setup the mirror repository.  Feed it the UUID of the source repository.
   exit_code, output, errput = svntest.main.run_svnlook("uuid", sbox.repo_dir)
@@ -336,7 +326,7 @@ def detect_meddling(sbox):
   sbox.build("svnsync-meddling")
 
   dest_sbox = sbox.clone_dependent()
-  build_repos(dest_sbox)
+  dest_sbox.build(create_wc=False, empty=True)
 
   # Make our own destination checkout (have to do it ourself because
   # it is not greek).
@@ -417,7 +407,7 @@ def info_synchronized(sbox):
   src_uuid = output[0].strip()
 
   dest_sbox = sbox.clone_dependent()
-  build_repos(dest_sbox)
+  dest_sbox.build(create_wc=False, empty=True)
 
   svntest.actions.enable_revprop_changes(dest_sbox.repo_dir)
   run_init(dest_sbox.repo_url, sbox.repo_url)

Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=1657773&r1=1657772&r2=1657773&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Fri Feb  6 10:17:02 2015
@@ -129,7 +129,7 @@ def setup_pristine_greek_repository():
 
 ######################################################################
 
-def guarantee_empty_repository(path):
+def guarantee_empty_repository(path, minor_version):
   """Guarantee that a local svn repository exists at PATH, containing
   nothing."""
 
@@ -139,7 +139,7 @@ def guarantee_empty_repository(path):
 
   # create an empty repository at PATH.
   main.safe_rmtree(path)
-  main.create_repos(path)
+  main.create_repos(path, minor_version)
 
 # Used by every test, so that they can run independently of  one
 # another. Every time this routine is called, it recursively copies
@@ -1882,32 +1882,44 @@ def run_and_verify_revert(expected_paths
 
 
 # This allows a test to *quickly* bootstrap itself.
-def make_repo_and_wc(sbox, create_wc = True, read_only = False,
-                     minor_version = None):
-  """Create a fresh 'Greek Tree' repository and check out a WC from it.
+def make_repo_and_wc(sbox, create_wc=True, read_only=False, empty=False,
+                     minor_version=None):
+  """Create a fresh repository and check out a WC from it.  If EMPTY is
+  True, the repository and WC will be empty and at revision 0,
+  otherwise they will contain the 'Greek Tree' at revision 1.
 
   If READ_ONLY is False, a dedicated repository will be created, at the path
-  SBOX.repo_dir.  If READ_ONLY is True, the pristine repository will be used.
+  SBOX.repo_dir.  If READ_ONLY is True, a shared pristine repository may be
+  used or a dedicated repository may be created.  (Currently we use a shared
+  pristine 'Greek tree' repo but we create a dedicated empty repo.)
   In either case, SBOX.repo_url is assumed to point to the repository that
   will be used.
 
-  If create_wc is True, a dedicated working copy will be checked out from
+  If CREATE_WC is True, a dedicated working copy will be checked out from
   the repository, at the path SBOX.wc_dir.
 
   Returns on success, raises on failure."""
 
-  # Create (or copy afresh) a new repos with a greek tree in it.
-  if not read_only:
-    guarantee_greek_repository(sbox.repo_dir, minor_version)
+  # Create or copy or reference the appropriate kind of repository:
+  # if we want a non-empty, Greek repo, refer to the shared one; else
+  # if we want an empty repo or a writable Greek repo, create one.
+  # (We could have a shared empty repo for read-only use, but we don't.)
+  if empty:
+    guarantee_empty_repository(sbox.repo_dir, minor_version)
+    expected_state = svntest.wc.State('', {})
+  else:
+    if not read_only:
+      guarantee_greek_repository(sbox.repo_dir, minor_version)
+    expected_state = main.greek_state
 
   if create_wc:
     # Generate the expected output tree.
-    expected_output = main.greek_state.copy()
+    expected_output = expected_state.copy()
     expected_output.wc_dir = sbox.wc_dir
     expected_output.tweak(status='A ', contents=None)
 
     # Generate an expected wc tree.
-    expected_wc = main.greek_state
+    expected_wc = expected_state
 
     # Do a checkout, and verify the resulting output and disk contents.
     run_and_verify_checkout(sbox.repo_url,

Modified: subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py?rev=1657773&r1=1657772&r2=1657773&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py Fri Feb  6 10:17:02 2015
@@ -49,7 +49,7 @@ class Sandbox:
 
     self.was_cwd = os.getcwd()
 
-  def _set_name(self, name, read_only=False):
+  def _set_name(self, name, read_only=False, empty=False):
     """A convenience method for renaming a sandbox, useful when
     working with multiple repositories in the same unit test."""
     if not name is None:
@@ -57,7 +57,7 @@ class Sandbox:
     self.read_only = read_only
     self.wc_dir = os.path.join(svntest.main.general_wc_dir, self.name)
     self.add_test_path(self.wc_dir)
-    if not read_only:
+    if empty or not read_only:  # use a local repo
       self.repo_dir = os.path.join(svntest.main.general_repo_dir, self.name)
       self.repo_url = (svntest.main.options.test_area_url + '/'
                        + urllib.pathname2url(self.repo_dir))
@@ -91,14 +91,16 @@ class Sandbox:
       shutil.copytree(self.wc_dir, clone.wc_dir, symlinks=True)
     return clone
 
-  def build(self, name=None, create_wc=True, read_only=False,
+  def build(self, name=None, create_wc=True, read_only=False, empty=False,
             minor_version=None):
     """Make a 'Greek Tree' repo (or refer to the central one if READ_ONLY),
+       or make an empty repo if EMPTY is true,
        and check out a WC from it (unless CREATE_WC is false). Change the
        sandbox's name to NAME. See actions.make_repo_and_wc() for details."""
-    self._set_name(name, read_only)
+    self._set_name(name, read_only, empty)
     self._ensure_authz()
-    svntest.actions.make_repo_and_wc(self, create_wc, read_only, minor_version)
+    svntest.actions.make_repo_and_wc(self, create_wc, read_only, empty,
+                                     minor_version)
     self._is_built = True
 
   def _ensure_authz(self):



Mime
View raw message