[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Even more test code

From: Sam TH <sam_at_uchicago.edu>
Date: 2001-04-27 07:15:16 CEST

Ok, in additon to the changes mentioned in my last email, this has
even more new code.

- I created a couple basic tests in the basic_tests.py file. They're
pretty boring.

- I added support for the concept of expected failures in our test
suite. We now report one four possible results for a test.
 
 PASS - the test was expected to pass, and passed
 FAIL - the test was expected to pass, and failed
 XPASS - the test was expected to fail, and passed
 XFAIL - the test was expected to fail, and failed

Note that the naming doesn't quite make sense - unexpected passes are
flagged, and unexpected failures aren't. But this is the way
everybody else does it. If you have a better naming scheme, I'm all
ears.

To mark the expected behavior of a test, you put PASS or FAIL at the
beginning of it's docstring. I've done this for all existing tests.

- To test this out, I added two test for bugs 325 and 326. 325 is
fixed, and so is expected to pass. 326 is still broken, and so is
marked as expected to fail.

One other thing - while running the test for 326 repeatedly, I
occasionally got the following berkeley db error:

 svn_error: #21054 Berkeley DB error while closing `nodes' database for filesystem repository1:
 DB_INCOMPLETE: Cache flush was unable to complete

I thought this was quite wierd, and it appeared unpredicatably.

The code:

Index: svn_entry.py
===================================================================
RCS file: /cvs/subversion/subversion/tests/clients/cmdline/svn_entry.py,v
retrieving revision 1.4
diff -u -r1.4 svn_entry.py
--- svn_entry.py 2001/04/12 18:11:02 1.4
+++ svn_entry.py 2001/04/27 04:49:22
@@ -27,6 +27,8 @@
 # present, such as prop-time, text-time, add, delete, conflict.
 
 import xml.parsers.expat # you may need to install this package
+from svn_tree import *
+import os.path
 
 class svn_entry:
   "An object that represents an entry from an 'entries' file."
@@ -81,6 +83,53 @@
   entryparser.parser.ParseFile(fp)
   fp.close()
   return entryparser.entry_dict
+
+def handle_entries_file(path, current_parent):
+
+ # get a dictionary of all the entries in the entries file
+
+ if os.path.exists(os.path.join(path, "SVN/entries")):
+ entry_path = os.path.join(path, "SVN/entries")
+ else: # we screwed up
+ raise SVNTreeError
+
+ entry_dict = get_entries(entry_path)
+
+ files = []
+ dirs = []
+
+ # put dirs and files in their own lists
+
+ for k in entry_dict.keys():
+ if entry_dict[k].atts['kind'] == 'file':
+ files.append(k)
+ elif (entry_dict[k].atts['kind'] == 'dir') and (k != ""):
+ dirs.append(k)
+
+ # add each file as a child of CURRENT_PARENT
+
+ for f in files:
+ current_parent.add_child(SVNTreeNode(f))
+
+ # for each subdir, create a node, walk its tree, add it as a child
+
+ for d in dirs:
+ new_dir_node = SVNTreeNode(d)
+ handle_entries_file(os.path.join(path, d), new_dir_node)
+ current_parent.add_child(new_dir_node)
+
+def build_tree_from_entries(wc_path):
+
+ """Takes WC_PATH as the path to a working copy. Walks the tree below
+ that path, and creates the tree based on the actual found
+ files."""
+
+ root = SVNTreeNode(root_node_name, None)
+
+ # Walk the tree recursively
+ handle_entries_file(os.path.normpath(wc_path), root)
+
+ return root
 
 
 ### End of file.
Index: svn_test_main.py
===================================================================
RCS file: /cvs/subversion/subversion/tests/clients/cmdline/svn_test_main.py,v
retrieving revision 1.5
diff -u -r1.5 svn_test_main.py
--- svn_test_main.py 2001/04/25 21:23:15 1.5
+++ svn_test_main.py 2001/04/27 04:49:22
@@ -47,12 +47,29 @@
 svnadmin_binary = '../../../svnadmin/svnadmin'
 
 
-# The paths within our greek tree, used to assemble 'expected' trees.
-greek_paths = ['iota', 'A', 'A/mu', 'A/B', 'A/B/lambda', 'A/B/E',
- 'A/B/E/alpha', 'A/B/E/beta', 'A/B/F', 'A/C', 'A/D',
- 'A/D/gamma', 'A/D/G', 'A/D/G/pi', 'A/D/G/rho', 'A/D/G/tau',
- 'A/D/H', 'A/D/H/chi', 'A/D/H/psi', 'A/D/H/omega']
 
+greek_tree = [
+ ["iota", "This is the file 'iota'.", {}],
+ ["A", None, {}],
+ ["A/mu", "This is the file 'mu'.", {}],
+ ["A/B", None, {}],
+ ["A/B/lambda", "This is the file 'lambda'.", {}],
+ ["A/B/E", None, {}],
+ ["A/B/E/alpha", "This is the file 'alpha'.", {}],
+ ["A/B/E/beta", "This is the file 'beta'.", {}],
+ ["A/B/F", None, {}],
+ ["A/C", None, {}],
+ ["A/D", None, {}],
+ ["A/D/gamma", "This is the file 'gamma'.", {}],
+ ["A/D/G", None, {}],
+ ["A/D/G/pi", "This is the file 'pi'.", {}],
+ ["A/D/G/rho", "This is the file 'rho'.", {}],
+ ["A/D/G/tau", "This is the file 'tau'.", {}],
+ ["A/D/H", None, {}],
+ ["A/D/H/chi", "This is the file 'chi'.", {}],
+ ["A/D/H/psi", "This is the file 'psi'.", {}],
+ ["A/D/H/omega", "This is the file 'omega'.", {}]
+ ]
 
 
 ######################################################################
@@ -85,6 +102,8 @@
   if os.path.exists(dirname):
     shutil.rmtree(dirname)
 
+remove_dir = remove_wc
+
 # For making local mods to files
 def file_append(path, new_text):
   "Append NEW_TEXT to file at PATH"
@@ -102,10 +121,62 @@
     os.makedirs(path) # this creates all the intermediate dirs, if neccessary
   run_svnadmin("create", path)
 
-# -- put more shared routines here --
+def create_file(path, text):
+ """Create a new file at PATH, with contents TEXT. If the intermediate
+ directories to PATH do not yet exist, create them"""
+
+ if not(os.path.exists(os.path.dirname(path))):
+ os.makedirs(os.path.dirname(path))
+
+ fp = open(path, 'w')
+ fp.write(text)
+ fp.close
+
+def create_dir(path):
+ """Create the directory specified by PATH, and any intermediate
+ directories as neccessary."""
+ if not(os.path.exists(path)):
+ os.makedirs(path)
+
+def checkout_wc(repos_path, module, wc_name):
+ """Checout MODULE from the repository at REPOS_PATH, and place it in
+ WC_NAME."""
+
+ run_svn("checkout", "file://" +
+ os.path.join(os.path.abspath(repos_path), module),
+ "-d", wc_name)
+
+def write_tree_list(base_path, new_tree):
+ """Create a new directory structure rooted at BASE_PATH in the file
+ system, with the structure and contents as specified by NEW_TREE"""
+
+ for i in new_tree:
+ if i[1] is None:
+ create_dir(os.path.join(base_path, i[0]))
+ else:
+ create_file(os.path.join(base_path, i[0]), i[1])
+
+def import_dir(repos_path, dir_path, name):
+ """Import the directory tree at DIR_PATH into the repository at
+ REPOS_PATH. The tree will be named NAME in the repository."""
+
+ run_svn("import", "file://" + os.path.abspath(repos_path),
+ dir_path, name)
+
+def create_greek_repos(repos_path, name="greek-tree"):
+ """Create a repository at REPOS_PATH, and import the greek tree into
+ it. The Greek Tree will be named NAME in the repository."""
+
+ tmp_path = "tmp_greek_tree"
+
+ create_repos(repos_path)
+ write_tree_list(tmp_path, greek_tree)
+ import_dir(repos_path, tmp_path, name)
+ remove_dir(tmp_path)
 
-# Need a routine which creates a repository containing a greek tree
 
+# -- put more shared routines here --
+
 # Need a routine which creates a working copy of a certain name,
 # by copying a 'pristine' one. (And which creates the pristine one via
 # checkout if necessary.)
@@ -122,13 +193,21 @@
     print "There is no test", `n` + ".\n"
     return 1
   # Run the test.
+ if test_list[n].__doc__[:4] == 'FAIL':
+ xfail = 1
+ else:
+ xfail = 0
   error = test_list[n]()
- if error:
+ if error and xfail:
+ print "XFAIL:",
+ elif error:
     print "FAIL:",
+ elif xfail:
+ print "XPASS:",
   else:
     print "PASS:",
- print sys.argv[0], n, ":", test_list[n].__doc__
- return error
+ print sys.argv[0], n, ":", test_list[n].__doc__[5:]
+ return (error, xfail)
 
 
 # Main func
@@ -144,9 +223,25 @@
   # or run all the tests if no arg.
   else:
     got_error = 0
+ passed = 0
+ failed = 0
+ xpassed = 0
+ xfailed = 0
     for n in range(len(test_list)):
       if n:
- got_error = run_test(n, test_list)
+ got_error, xfail = run_test(n, test_list)
+ if got_error and xfail:
+ xfailed += 1
+ elif got_error:
+ failed += 1
+ elif xfail:
+ xpassed +=1
+ else:
+ passed += 1
+ print "%d Expected Passes" % passed
+ print "%d Expected Failures" % xfailed
+ print "%d Unexpected Passes" % xpassed
+ print "%d Unexpected Failures" % failed
     return got_error
 
 
Index: svn_tree.py
===================================================================
RCS file: /cvs/subversion/subversion/tests/clients/cmdline/svn_tree.py,v
retrieving revision 1.2
diff -u -r1.2 svn_tree.py
--- svn_tree.py 2001/04/27 01:14:15 1.2
+++ svn_tree.py 2001/04/27 04:49:22
@@ -125,9 +125,11 @@
 
   if a.name != b.name:
     return 1
- if a.contents != b.contents:
+ if (a.contents != b.contents) and not((a.contents is None) or
+ (b.contents is None)):
     return 1
- if a.props != b.props: ## is it legal to compare hashes like this?!?
+ if (a.props != b.props) and not((a.props is None) or
+ (b.props is None)): ## is it legal to compare hashes like this?!?
     return 1
   
   # We don't need to compare lists of children, since that's being
@@ -168,7 +170,7 @@
 # a regexp machine for matching the name of the administrative dir.
 rm = re.compile("^SVN/|/SVN/|/SVN$|^/SVN/|^SVN$")
 
-# helper for visitfunc(), which is a helper for build_tree_from_wc()
+# helper for handle_dir(), which is a helper for build_tree_from_wc()
 def get_props(path):
   "Return a hash of props for PATH, using the svn client."
 
@@ -189,7 +191,7 @@
   return props
 
 
-# helper for visitfunc(), which helps build_tree_from_wc()
+# helper for handle_dir(), which helps build_tree_from_wc()
 def get_text(path):
   "Return a string with the textual contents of a file at PATH."
 
@@ -203,40 +205,46 @@
   return contents
 
 
-# helper for build_tree_from_wc() -- callback for os.walk()
-def visitfunc(baton, dirpath, entrynames):
- "Callback for os.walk(). Builds a tree of SVNTreeNodes."
-
- # if any element of DIRPATH is 'SVN', go home.
- if rm.search(dirpath):
- return
-
- # unpack the baton
- root = baton[0]
- load_props = baton[1]
-
- # Create a linked list of nodes from DIRPATH, and deposit
- # DIRPATH's properties in the tip.
- if load_props:
- dirpath_props = get_props(dirpath)
- else:
- dirpath_props = {}
- new_branch = create_from_path(dirpath, None, dirpath_props)
- root.add_child(new_branch)
-
- # Repeat the process for each file entry.
- for entry in entrynames:
- entrypath = os.path.join(dirpath, entry)
- if os.path.isfile(entrypath):
- if load_props:
- file_props = get_props(entrypath)
- else:
- file_props = {}
- file_contents = get_text(entrypath)
- new_branch = create_from_path(entrypath,
- file_contents, file_props)
- root.add_child(new_branch)
+# helper for build_tree_from_wc()
+def handle_dir(path, current_parent, load_props):
+ "Add all the children of directory PATH as children of CURRENT_PARENT"
+ # get a list of all the files
+
+ all_files = os.listdir(path)
+ files = []
+ dirs = []
+
+ # put dirs and files in their own lists, and remove SVN dirs
 
+ for f in all_files:
+ f = os.path.join(path, f)
+ if os.path.isdir(f) and os.path.basename(f) != 'SVN':
+ dirs.append(f)
+ elif os.path.isfile(f):
+ files.append(f)
+
+ # add each file as a child of CURRENT_PARENT
+
+ for f in files:
+ if load_props:
+ file_props = get_props(f)
+ else:
+ file_props = {}
+ file_contents = get_text(f)
+ current_parent.add_child(SVNTreeNode(os.path.basename(f), None,
+ file_contents, file_props))
+
+ # for each subdir, create a node, walk its tree, add it as a child
+
+ for d in dirs:
+ if load_props:
+ dir_props = get_props(d)
+ else:
+ dir_props = {}
+ new_dir_node = SVNTreeNode(os.path.basename(d), None, None, dir_props)
+ handle_dir(d, new_dir_node, load_props)
+ current_parent.add_child(new_dir_node)
+
 
 ###########################################################################
 ###########################################################################
@@ -297,8 +305,7 @@
   indent = indent.replace("+"," ")
   for i in range(len(tmp_children)):
     c = tmp_children[i]
- if i == len(tmp_children
- )-1:
+ if i == len(tmp_children)-1:
       dump_tree(c,indent + " +-- ")
     else:
       dump_tree(c,indent + " |-- ")
@@ -362,8 +369,11 @@
 
   root = SVNTreeNode(root_node_name)
   rm = re.compile ('^(\w+)\s+(.+)')
-
+ ignore_re = re.compile('^Commit.+')
+
   for line in lines:
+ if not((ignore_re.match(line)) is None):
+ continue
     match = rm.search(line)
     if match and match.groups():
       new_branch = create_from_path(match.group(2), None,
@@ -405,22 +415,22 @@
 # creates a drastic slowdown -- we spawn a new 'svn proplist'
 # process for every file and dir in the working copy!
 
+
+
 def build_tree_from_wc(wc_path, load_props=0):
   """Walk a subversion working copy starting at WC_PATH and return a
   tree structure containing file contents. If LOAD_PROPS is true,
   then all file and dir properties will be read into the tree as well."""
-
- root = SVNTreeNode(root_node_name)
 
- baton = (root, load_props)
- os.path.walk(wc_path, visitfunc, baton)
+ root = SVNTreeNode(root_node_name, None)
+
+ # Walk the tree recursively
+ handle_dir(os.path.normpath(wc_path), root, load_props)
 
   return root
-
-
-dump_tree(build_tree_from_wc('wc-t1'))
-
 
+if __name__ == '__main__':
+ dump_tree(build_tree_from_wc('wc-t1'))
 
 
 ### End of file.
Index: xml_tests.py
===================================================================
RCS file: /cvs/subversion/subversion/tests/clients/cmdline/xml_tests.py,v
retrieving revision 1.3
diff -u -r1.3 xml_tests.py
--- xml_tests.py 2001/04/25 21:23:15 1.3
+++ xml_tests.py 2001/04/27 04:49:22
@@ -18,10 +18,10 @@
 
 import svn_test_main
 import svn_tree
-import svn_output
 
 import shutil # for copytree()
 import string # for strip()
+import os
 
 ##### Globals
 
@@ -44,17 +44,17 @@
   output = svn_test_main.run_svn ('co', '-d', wc_dir, \
                                   '--xml-file', xml_path, \
                                   '-r 1', ANCESTOR_PATH)
- output_tree = svn_output.tree_from_checkout (output)
+ output_tree = svn_tree.build_tree_from_checkout (output)
 
   # Make a tree out of the expected lines
   expected_tree = svn_tree.build_generic_tree (expected_lines)
 
+ # svn_tree.dump_tree(expected_tree)
+ # svn_tree.dump_tree(output_tree)
+
   # Verify actual output against expected output.
   return svn_tree.compare_trees (output_tree, expected_tree)
 
- # TODO: someday inspect the entries file too??
-
-
 
 # A commit to xml, with output verification.
 # Note: don't include the line 'Commit succeeded' in your expected
@@ -68,17 +68,14 @@
   output = svn_test_main.run_svn("ci", "--xml-file", xml_path,
                                  "-r", revision, wc_dir)
 
- # Remove the final output line, return error if it's not 'Commit succeeded'.
- lastline = string.strip(output.pop())
- if lastline != 'Commit succeeded.':
- return 1
-
- # Now verify the actual vs. expected output.
- return svn_output.compare_sets(expected_lines, output,
- svn_output.line_matches_regexp)
+ output_tree = svn_tree.build_tree_from_commit (output)
 
- # TODO: someday inspect the entries file too??
+ # Make a tree out of the expected lines
+ expected_tree = svn_tree.build_generic_tree (expected_lines)
 
+ # Verify actual output against expected output.
+ return svn_tree.compare_trees (output_tree, expected_tree)
+
 
 ######################################################################
 # Tests
@@ -88,14 +85,14 @@
 #----------------------------------------------------------------------
 
 def xml_test_1():
- "checkout a wc from co1-inline.xml"
+ "PASS checkout a wc from co1-inline.xml"
 
   wc_dir = 'wc-t1'
 
   # Generate the expected output lines from a checkout.
   expected_output = []
- for path in svn_test_main.greek_paths:
- item = [ wc_dir + '/' + path,
+ for elem in svn_test_main.greek_tree:
+ item = [ wc_dir + '/' + elem[0],
              None,
              {'status' : 'A '} ]
     expected_output.append(item)
@@ -105,16 +102,18 @@
 #----------------------------------------------------------------------
 
 def xml_test_2():
- "xml checkout, make many mods, xml commit, update."
+ "PASS xml checkout, make many mods, xml commit, update."
 
   wc_dir = 'wc-t2'
   wc_dir2 = 'wc-t2-copy'
 
- # Generate the expected output lines from a checkout (as regexps)
+ # Generate the expected output lines from a checkout
   expected_output = []
- for path in greek_paths:
- line = 'A\s+' + wc_dir + '/' + path
- expected_output.append(line)
+ for elem in svn_test_main.greek_tree:
+ item = [ wc_dir + '/' + elem[0],
+ None,
+ {'status' : 'A '} ]
+ expected_output.append(item)
 
   # Checkout from co1-inline.xml and verify the results.
   result = xml_checkout(wc_dir, XML_DIR + '/co1-inline.xml', expected_output)
@@ -149,10 +148,14 @@
            ### TODO: verify that the output was "" (nothing)
 
   # Commit to xml file (bumping wc to rev. 2), and verify the output.
- commit_expected_output = ['Deleting\s+' + wc_dir + '/A/D/H/omega',
- 'Adding\s+' + wc_dir + '/newfile1',
- 'Changing\s+' + wc_dir + '/A/mu',
- 'Changing\s+' + wc_dir + '/A/D/G/pi']
+ commit_expected_output = [[os.path.join(wc_dir, 'A/D/H/omega'),
+ None, {'verb': 'Deleting'}],
+ [os.path.join(wc_dir, 'newfile1'),
+ None, {'verb': 'Adding'}],
+ [os.path.join(wc_dir, 'A/mu'),
+ None, {'verb': 'Changing'}],
+ [os.path.join(wc_dir, 'A/D/G/pi'),
+ None, {'verb': 'Changing'}]]
 
   result = xml_commit(wc_dir, 'xmltest2-commit.xml', 2, commit_expected_output)
   if result:
@@ -163,7 +166,7 @@
 #-----------------------------------------------------------------------------
 
 def xml_test_3():
- """verify the actual wc from co1-inline.xml - 2"""
+ """PASS verify the actual wc from co1-inline.xml"""
 
   import svn_tree
 
@@ -175,18 +178,15 @@
                                   '-r 1', ANCESTOR_PATH)
 
 
- exp_tree = svn_tree.build_tree_from_paths(greek_paths)
+ exp_tree = svn_tree.build_generic_tree(svn_test_main.greek_tree)
   result_tree = svn_tree.build_tree_from_wc(wc_dir)
 
- if svn_tree.compare_trees(exp_tree, result_tree):
- return 0
- else:
- return 1
+ return svn_tree.compare_trees(exp_tree, result_tree)
 
 #----------------------------------------------------------------------------
 
 def xml_test_4():
- """verify that the entries files match the wc"""
+ """PASS verify that the entries files match the wc"""
 
   import svn_tree, svn_entry
 
@@ -198,12 +198,9 @@
                                   '-r 1', ANCESTOR_PATH)
 
   exp_tree = svn_tree.build_tree_from_wc(wc_dir)
- result_tree = svn_tree.build_tree_from_entries(wc_dir)
+ result_tree = svn_entry.build_tree_from_entries(wc_dir)
 
- if svn_tree.compare_trees(exp_tree, result_tree):
- return 0
- else:
- return 1
+ return svn_tree.compare_trees(exp_tree, result_tree)
   
 ########################################################################
 ## List all tests here, starting with None:

-------------------------------------

basic_tests.py

-------------------------------------
#!/usr/bin/env python
#
# basic_tests.py - Test basic Subversion functionality using ra_local
#
# Subversion is a tool for revision control.
# See http://subversion.tigris.org for more information.
#
# ====================================================================
# Copyright (c) 2001 Sam Tobin-Hochstadt
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
######################################################################

import svn_tree
import svn_test_main
import svn_entry

######################################################################
# Tests
#
# Each test must return 0 on success or non-zero on failure.

#----------------------------------------------------------------------

def checkout_compare():
  "PASS check out two copies of the greek tree, and compare the working copies"
  
  repo_name = "repository1"
  wc1 = "greek-wc-t1"
  wc2 = "greek-wc-t2"
  
  # make sure stuff isn't in the way
  svn_test_main.remove_dir(repo_name)
  svn_test_main.remove_wc(wc1)
  svn_test_main.remove_wc(wc2)
  
  # Create the repository with the appropriate contents
  svn_test_main.create_greek_repos(repo_name)
  
  # Check out two copies of the greek tree
  svn_test_main.checkout_wc(repo_name, "greek-tree", wc1)
  svn_test_main.checkout_wc(repo_name, "greek-tree", wc2)
  
  # Build trees from each working copy
  tree1 = svn_tree.build_tree_from_wc(wc1)
  tree2 = svn_tree.build_tree_from_wc(wc2)
  
  # Compare the trees, and return the results
  return svn_tree.compare_trees(tree1, tree2)

#----------------------------------------------------------------------

def checkout_compare_entries():
  "PASS check out two copies of the greek tree, and compare the entries files"
  
  repo_name = "repository1"
  wc1 = "greek-wc-t1"
  wc2 = "greek-wc-t2"
  
  # make sure stuff isn't in the way
  svn_test_main.remove_dir(repo_name)
  svn_test_main.remove_wc(wc1)
  svn_test_main.remove_wc(wc2)
  
  # Create the repository with the appropriate contents
  svn_test_main.create_greek_repos(repo_name)
  
  # Check out two copies of the greek tree
  svn_test_main.checkout_wc(repo_name, "greek-tree", wc1)
  svn_test_main.checkout_wc(repo_name, "greek-tree", wc2)
  
  # Build trees from each working copy
  tree1 = svn_entry.build_tree_from_entries(wc1)
  tree2 = svn_entry.build_tree_from_entries(wc2)
  
  # Compare the trees, and return the results
  return svn_tree.compare_trees(tree1, tree2)

#######################################################################
# List all tests here, starting with None
test_list = [ None,
              checkout_compare,
              checkout_compare_entries
              ]

if __name__ == '__main__':
  ## And run the main test routine on them:
  svn_test_main.client_test(test_list)
  
  
### End of file.
# local variables:
# eval: (load-file "../../../svn-dev.el")
# end:

-------------------------------

bug_tests.py

-----------------------------------------
#!/usr/bin/env python
#
# bug_tests.py - Tests to check the status of reported bugs
#
# Subversion is a tool for revision control.
# See http://subversion.tigris.org for more information.
#
# ====================================================================
# Copyright (c) 2001 Sam Tobin-Hochstadt
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
######################################################################

import svn_tree
import svn_test_main
import svn_entry
import os

######################################################################
# Tests
#
# Each test must return 0 on success or non-zero on failure.

#----------------------------------------------------------------------

def bug_325():
  "PASS Bug 325: check that 'svn status' shows just-added directories"
  
  repo_name = "../../greek-repos/"
  wc1 = "325-wc"
  
  # make sure stuff isn't in the way
  svn_test_main.remove_wc(wc1)

  # Check out a copy of the tree
  svn_test_main.checkout_wc(repo_name, "", wc1)

  # Add a new directory to the working copy
  svn_test_main.create_dir(os.path.join(wc1, "foo"))
  svn_test_main.run_svn("add", os.path.join(wc1, "foo"))

  output = svn_test_main.run_svn("status", os.path.join(wc1, "foo"))
  exp_output = "_ 0 ( 1) %s/foo\n" % wc1

  if output[0] == exp_output:
    return 0
  else:
    return 1

#----------------------------------------------------------------------

def bug_326():
  "FAIL Bug 326 `svn ci --xml-file' segfaults if no -r is given."

  repo_name = "repository1"
  wc1 = "326-wc-t1"
  
  # make sure stuff isn't in the way
  svn_test_main.remove_dir(repo_name)
  svn_test_main.remove_wc(wc1)
  
  # Create the repository with the appropriate contents
  svn_test_main.create_greek_repos(repo_name)
  
  # Check out two copies of the greek tree
  svn_test_main.checkout_wc(repo_name, "greek-tree", wc1)

  svn_test_main.file_append(os.path.join(wc1, "iota"), "This is new text.\n")

  output = svn_test_main.run_svn("ci", "--xml-file", "../326.xml")
  exp_output = [[os.path.join(wc1, 'iota'),
                 None, {'verb': 'Changing'}]]

  exp_tree = svn_tree.build_generic_tree(exp_output)
  output_tree = svn_tree.build_tree_from_commit(output)

  return svn_tree.compare_trees(exp_tree, output_tree)
  

#######################################################################
# List all tests here, starting with None
test_list = [ None,
              bug_325,
              bug_326
              ]

if __name__ == '__main__':
  ## And run the main test routine on them:
  svn_test_main.client_test(test_list)
  
  
### End of file.
# local variables:
# eval: (load-file "../../../svn-dev.el")
# end:

           
sam th --- sam_at_uchicago.edu --- http://www.abisource.com/~sam/
OpenPGP Key: CABD33FC --- http://samth.dyndns.org/key
DeCSS: http://samth.dynds.org/decss

  • application/pgp-signature attachment: stored
Received on Sat Oct 21 14:36:29 2006

This is an archived mail posted to the Subversion Dev mailing list.