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

svn commit: r903228 - in /subversion/trunk/subversion/tests/cmdline: obliterate_tests.py svntest/objects.py

Author: julianfoad
Date: Tue Jan 26 14:07:14 2010
New Revision: 903228

URL: http://svn.apache.org/viewvc?rev=903228&view=rev
Log:
A few enhancements to the test harness used for "obliterate".

* subversion/tests/cmdline/svntest/objects.py
  (SvnRepository): Remember its own head revision. Add a "svn_mkdirs"
    method. In the "obliterate_node_rev" method, add optional parameters to
    check its stdin, stdout and exit code.
  (SvnWC): Remember its associated SvnRepository object. Don't remember its
    own head revision - let the repo do that. In the "svn_delete" method,
    add an optional "even_if_modified" parameter. Add an "svn_update"
    method.

* subversion/tests/cmdline/obliterate_tests.py
  (create_dd1_scenarios): Speed up the committing of revs 2 to 8 by using
    the "SvnRepository.svn_mkdirs" method above.
    Adjust to get the head rev from the repo object.
  (obliterate_1): Adjust to get the head from the repo object.

Modified:
    subversion/trunk/subversion/tests/cmdline/obliterate_tests.py
    subversion/trunk/subversion/tests/cmdline/svntest/objects.py

Modified: subversion/trunk/subversion/tests/cmdline/obliterate_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/obliterate_tests.py?rev=903228&r1=903227&r2=903228&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/obliterate_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/obliterate_tests.py Tue Jan 26 14:07:14 2010
@@ -44,7 +44,7 @@
 
 obliteration_dirs = ['f-mod', 'f-add', 'f-del', 'f-rpl', 'f-mov']
 
-def create_dd1_scenarios(wc):
+def create_dd1_scenarios(wc, repo):
   """Create, in the initially empty repository of the SvnWC WC, the
      obliteration test scenarios depicted in each "Example 1" in
      <notes/obliterate/fspec-dd1/dd1-file-ops.svg>."""
@@ -52,13 +52,13 @@
   # r1: base directories
   for dir in obliteration_dirs:
     wc.svn_mkdir(dir)
-  rev = wc.svn_commit()
+  wc.svn_commit()
 
   # r2 to r8 inclusive, just so that the obliteration rev is a round and
   # consistent number (10), no matter what complexity of history we have.
-  while rev < 8:
-    wc.svn_set_props('', { 'this-is-rev': str(rev + 1) })
-    rev = wc.svn_commit()
+  while repo.head_rev < 8:
+    repo.svn_mkdirs('tmp/' + str(repo.head_rev + 1))
+  wc.svn_update()
 
   # r9: add the files used in the scenarios
   wc.svn_file_create_add('f-mod/F', "Pear\n")
@@ -75,7 +75,7 @@
   wc.svn_file_create_add('f-rpl/F', 'Apple\n')
   wc.svn_move('f-mov/E', 'f-mov/F')
   wc.file_modify('f-mov/F', 'Apple\n')
-  rev = wc.svn_commit(log='Rev to be obliterated')
+  wc.svn_commit(log='Rev to be obliterated')
 
   # r11: some more recent history that refers to the revision we changed
   # (We are not ready to test this yet.)
@@ -83,7 +83,7 @@
   #  wc.file_modify(dir + '/F', 'Orange\n')
   #wc.svn_commit()
 
-  return rev
+  return 10
 
 ######################################################################
 # Tests
@@ -103,13 +103,13 @@
                                   expected_disk)
 
   # Create test utility objects
-  wc = objects.SvnWC(sbox.wc_dir)
   repo = objects.SvnRepository(sbox.repo_url, sbox.repo_dir)
+  wc = objects.SvnWC(sbox.wc_dir, repo)
 
   os.chdir(sbox.wc_dir)
 
   # Create scenarios ready for obliteration
-  apple_rev = create_dd1_scenarios(wc)
+  apple_rev = create_dd1_scenarios(wc, repo)
 
   # Dump the repository state, if possible, for debugging
   try:

Modified: subversion/trunk/subversion/tests/cmdline/svntest/objects.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/objects.py?rev=903228&r1=903227&r2=903228&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/objects.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/objects.py Tue Jan 26 14:07:14 2010
@@ -142,6 +142,8 @@
     self.repo_url = repo_url
     self.repo_absdir = os.path.abspath(repo_dir)
     self.db_dump_name = locate_db_dump()
+    # This repository object's idea of its own head revision.
+    self.head_rev = 0
 
   def dump(self, output_dir):
     """Dump the repository into the directory OUTPUT_DIR"""
@@ -162,11 +164,23 @@
     main.file_append(ldumpfile, ''.join(stdout))
 
 
-  def obliterate_node_rev(self, path, rev):
-    """Obliterate the single node-rev PATH in revision REV."""
+  def obliterate_node_rev(self, path, rev,
+                          exp_out=None, exp_err=[], exp_exit=0):
+    """Obliterate the single node-rev PATH in revision REV. Check the
+    expected stdout, stderr and exit code (EXP_OUT, EXP_ERR, EXP_EXIT)."""
+    arg = self.repo_url + '/' + path + '@' + str(rev)
+    actions.run_and_verify_svn2(None, exp_out, exp_err, exp_exit,
+                                'obliterate', arg)
+
+  def svn_mkdirs(self, *dirs):
+    """Run 'svn mkdir' on the repository. DIRS is a list of directories to
+    make, and each directory is a path relative to the repository root,
+    neither starting nor ending with a slash."""
+    urls = [self.repo_url + '/' + dir for dir in dirs]
     actions.run_and_verify_svn(None, None, [],
-                               'obliterate',
-                               self.repo_url + '/' + path + '@' + str(rev))
+                               'mkdir', '-m', 'svn_mkdirs()', '--parents',
+                               *urls)
+    self.head_rev += 1
 
 
 ######################################################################
@@ -182,9 +196,9 @@
      in Subversion canonical form ('/' separators).
      """
 
-  def __init__(self, wc_dir):
-    """Initialize the object to use the existing WC at path WC_DIR.
-    """
+  def __init__(self, wc_dir, repo):
+    """Initialize the object to use the existing WC at path WC_DIR and
+    the existing repository object REPO."""
     self.wc_absdir = os.path.abspath(wc_dir)
     # 'state' is, at all times, the 'wc.State' representation of the state
     # of the WC, with paths relative to 'wc_absdir'.
@@ -194,15 +208,10 @@
     self.state.add({
       '': wc.StateItem()
     })
-    # This WC's idea of the repository's head revision.
-    # ### Shouldn't be in this class: should ask the repository instead.
-    self.head_rev = 0
-
-    print "## new SvnWC:"
-    print self
+    self.repo = repo
 
   def __str__(self):
-    return "SvnWC(head_rev=" + str(self.head_rev) + ", state={" + \
+    return "SvnWC(head_rev=" + str(self.repo.head_rev) + ", state={" + \
       str(self.state.desc) + \
       "})"
 
@@ -298,10 +307,13 @@
       rpath2: self.state.desc[rpath1]
     })
 
-  def svn_delete(self, rpath):
+  def svn_delete(self, rpath, even_if_modified=False):
     "Delete a WC path locally."
     lpath = local_path(rpath)
-    actions.run_and_verify_svn(None, None, [], 'delete', lpath)
+    args = []
+    if even_if_modified:
+      args += ['--force']
+    actions.run_and_verify_svn(None, None, [], 'delete', lpath, *args)
 
   def svn_commit(self, rpath='', log=''):
     "Commit a WC path (recursively). Return the new revision number."
@@ -309,9 +321,14 @@
     actions.run_and_verify_svn(None, verify.AnyOutput, [],
                                'commit', '-m', log, lpath)
     actions.run_and_verify_update(lpath, None, None, None)
-    self.head_rev += 1
-    print "## head-rev == " + str(self.head_rev)
-    return self.head_rev
+    self.repo.head_rev += 1
+    print "## head-rev == " + str(self.repo.head_rev)
+    return self.repo.head_rev
+
+  def svn_update(self, rpath='', rev='HEAD'):
+    "Update the WC to the specified revision"
+    lpath = local_path(rpath)
+    actions.run_and_verify_update(lpath, None, None, None)
 
 #  def svn_merge(self, rev_spec, source, target, exp_out=None):
 #    """Merge a single change from path 'source' to path 'target'.