subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pbu...@apache.org
Subject svn commit: r1341279 - in /subversion/branches/inheritable-props/subversion/tests/cmdline: iprop_tests.py svntest/actions.py
Date Tue, 22 May 2012 00:05:53 GMT
Author: pburba
Date: Tue May 22 00:05:52 2012
New Revision: 1341279

URL: http://svn.apache.org/viewvc?rev=1341279&view=rev
Log:
On the inheritable-props branch: Add some tests.

* subversion/tests/cmdline/iprop_tests.py: New.

* subversion/tests/cmdline/svntest/actions.py
  (run_and_verify_inherited_prop_xml): New.

Added:
    subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py   (with
props)
Modified:
    subversion/branches/inheritable-props/subversion/tests/cmdline/svntest/actions.py

Added: subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py?rev=1341279&view=auto
==============================================================================
--- subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py (added)
+++ subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py Tue May
22 00:05:52 2012
@@ -0,0 +1,312 @@
+#!/usr/bin/env python
+#
+#  iprop_tests.py:  testing versioned inherited properties
+#
+#  Subversion is a tool for revision control.
+#  See http://subversion.apache.org for more information.
+#
+# ====================================================================
+#    Licensed to the Apache Software Foundation (ASF) under one
+#    or more contributor license agreements.  See the NOTICE file
+#    distributed with this work for additional information
+#    regarding copyright ownership.  The ASF licenses this file
+#    to you under the Apache License, Version 2.0 (the
+#    "License"); you may not use this file except in compliance
+#    with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing,
+#    software distributed under the License is distributed on an
+#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#    KIND, either express or implied.  See the License for the
+#    specific language governing permissions and limitations
+#    under the License.
+######################################################################
+
+# General modules
+import os
+
+# Our testing module
+import svntest
+
+# (abbreviation)
+Skip = svntest.testcase.Skip_deco
+SkipUnless = svntest.testcase.SkipUnless_deco
+XFail = svntest.testcase.XFail_deco
+Issues = svntest.testcase.Issues_deco
+Issue = svntest.testcase.Issue_deco
+Wimp = svntest.testcase.Wimp_deco
+Item = svntest.wc.StateItem
+
+######################################################################
+# Tests
+
+#----------------------------------------------------------------------
+# Working property inheritance, uniform revision WC.
+def iprops_basic_working(sbox):
+  "basic inherited working properties"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  # Paths of note.
+  mu_path = os.path.join(wc_dir, 'A', 'mu')
+  D_path = os.path.join(wc_dir, 'A', 'D')
+  psi_path = os.path.join(wc_dir, 'A', 'D', 'H', 'psi')
+  iota_path = os.path.join(wc_dir, 'iota')
+  alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha')
+  G_path = os.path.join(wc_dir, 'A', 'D', 'G')
+  rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')
+
+  sbox.simple_propset('RootProp1', 'Root-Prop-Val1', '.')
+  sbox.simple_propset('RootProp2', 'Root-Prop-Val2', '.')
+  sbox.simple_propset('DirProp2', 'Dir-Prop-Val-Root', '.')
+  sbox.simple_propset('FileProp1', 'File-Prop-Val1', 'iota')
+  sbox.simple_propset('FileProp2', 'File-Prop-Val2', 'A/D/H/psi')
+  sbox.simple_propset('DirProp1', 'Dir-Prop-Val1', 'A/D')
+  sbox.simple_propset('DirProp2', 'Dir-Prop-Val2', 'A/D')
+  sbox.simple_propset('DirProp3', 'Dir-Prop-Val3', 'A/D')
+  sbox.simple_propset('SomeProp', 'Some-Prop-Val1', 'A/D/G')
+  sbox.simple_propset('SomeProp', 'Some-Prop-Val2', 'A/D/G/rho')
+
+  ### Proplist Directory Targets
+
+  # Proplist directory target with only explicit props.
+  expected_iprops = {}
+  expected_explicit_props = {'DirProp2' : 'Dir-Prop-Val-Root',
+                             'RootProp1' : 'Root-Prop-Val1',
+                             'RootProp2' : 'Root-Prop-Val2'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    wc_dir, expected_iprops, expected_explicit_props)
+
+  # Proplist directory target with only inherited props.
+  expected_iprops = {wc_dir : {'DirProp2' : 'Dir-Prop-Val-Root',
+                               'RootProp1' : 'Root-Prop-Val1',
+                               'RootProp2' : 'Root-Prop-Val2'}}
+  expected_explicit_props = {}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    alpha_path, expected_iprops, expected_explicit_props)
+
+  # Proplist directory target with inherited and explicit props.
+  expected_iprops = {wc_dir : {'RootProp1' : 'Root-Prop-Val1',
+                               'RootProp2' : 'Root-Prop-Val2',
+                               'DirProp2' : 'Dir-Prop-Val-Root'}}
+  expected_explicit_props = {'DirProp1' : 'Dir-Prop-Val1',
+                             'DirProp2' : 'Dir-Prop-Val2',
+                             'DirProp3' : 'Dir-Prop-Val3'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    D_path, expected_iprops, expected_explicit_props)
+
+  ### Propget Directory Targets
+  
+  # Propget directory target with only explicit props.
+  expected_iprops = {}
+  expected_explicit_props = {'RootProp2' : 'Root-Prop-Val2'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    wc_dir, expected_iprops, expected_explicit_props, 'RootProp2')
+
+  # Propget directory target with only inherited props.
+  expected_iprops = {wc_dir : {'RootProp2': 'Root-Prop-Val2'}}
+  expected_explicit_props = {}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    alpha_path, expected_iprops, expected_explicit_props, 'RootProp2')
+
+  # Propget directory target with inherited and explicit props.
+  expected_iprops = {wc_dir : {'DirProp2' : 'Dir-Prop-Val-Root',}}
+  expected_explicit_props = {'DirProp2' : 'Dir-Prop-Val2'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    D_path, expected_iprops, expected_explicit_props, 'DirProp2')
+
+  ### Propget File Targets
+
+  # Propget file target with only explicit props.
+  expected_iprops = {}
+  expected_explicit_props = {'FileProp1' : 'File-Prop-Val1'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    iota_path, expected_iprops, expected_explicit_props, 'FileProp1')
+
+  # Propget file target with only inherited props.
+  expected_iprops = {wc_dir : {'RootProp2': 'Root-Prop-Val2'}}
+  expected_explicit_props = {}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    alpha_path, expected_iprops, expected_explicit_props, 'RootProp2')
+
+  # Propget file target with inherited and explicit props.
+  expected_iprops = {G_path : {'SomeProp' : 'Some-Prop-Val1',}}
+  expected_explicit_props = {'SomeProp' : 'Some-Prop-Val2'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    rho_path, expected_iprops, expected_explicit_props, 'SomeProp')
+
+  ### Proplist File Targets
+
+  # Proplist file target with only inherited props.
+  expected_iprops = {wc_dir : {'DirProp2' : 'Dir-Prop-Val-Root',
+                               'RootProp1' : 'Root-Prop-Val1',
+                               'RootProp2' : 'Root-Prop-Val2'}}
+  expected_explicit_props = {}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    mu_path, expected_iprops, expected_explicit_props)
+
+  # Proplist file target with inherited and explicit props.
+  expected_iprops = {wc_dir   : {'RootProp1' : 'Root-Prop-Val1',
+                                 'RootProp2' : 'Root-Prop-Val2',
+                                 'DirProp2' : 'Dir-Prop-Val-Root'},
+                     D_path   : {'DirProp1' : 'Dir-Prop-Val1',
+                                 'DirProp2' : 'Dir-Prop-Val2',
+                                 'DirProp3' : 'Dir-Prop-Val3'}}
+  expected_explicit_props = {'FileProp2' : 'File-Prop-Val2'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    psi_path, expected_iprops, expected_explicit_props)
+
+  # Proplist file target with only explicit props.
+  svntest.actions.run_and_verify_svn(None, None, [], 'revert', wc_dir)
+  expected_iprops = {}
+  expected_explicit_props = {'FileProp1' : 'File-Prop-Val1'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    iota_path, expected_iprops, expected_explicit_props)
+
+#----------------------------------------------------------------------
+# Property inheritance with repository targets.
+def iprops_basic_repos(sbox):
+  "basic inherited repository properties"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  # Paths of note.
+  D_path = os.path.join(wc_dir, 'A', 'D')
+  alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha')
+
+  sbox.simple_propset('FileProp1', 'File-Prop-Val1', 'iota')
+  sbox.simple_propset('FileProp2', 'File-Prop-Val2', 'A/D/H/psi')
+  sbox.simple_propset('SomeProp', 'Some-Prop-Val2', 'A/D/G/rho')
+  svntest.main.run_svn(None, 'commit', '-m', 'Add some file properties',
+                       wc_dir)
+
+  svntest.actions.run_and_verify_svn(None, None, [], 'up', wc_dir)
+  sbox.simple_propset('RootProp1', 'Root-Prop-Val1', '.')
+  sbox.simple_propset('RootProp2', 'Root-Prop-Val2', '.')
+  sbox.simple_propset('DirProp2', 'Dir-Prop-Val-Root', '.')
+  sbox.simple_propset('DirProp1', 'Dir-Prop-Val1', 'A/D')
+  sbox.simple_propset('DirProp2', 'Dir-Prop-Val2', 'A/D')
+  sbox.simple_propset('DirProp3', 'Dir-Prop-Val3', 'A/D')
+  sbox.simple_propset('SomeProp', 'Some-Prop-Val1', 'A/D/G')
+  svntest.main.run_svn(None, 'commit', '-m', 'Add some dir properties',
+                       wc_dir)
+
+  ### Proplist Directory Targets
+
+  # Proplist directory target with only explicit props.
+  expected_iprops = {}
+  expected_explicit_props = {'DirProp2' : 'Dir-Prop-Val-Root',
+                             'RootProp1' : 'Root-Prop-Val1',
+                             'RootProp2' : 'Root-Prop-Val2'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url, expected_iprops, expected_explicit_props)
+
+  # Proplist directory target with only inherited props.
+  expected_iprops = {sbox.repo_url : {'DirProp2' : 'Dir-Prop-Val-Root',
+                                      'RootProp1' : 'Root-Prop-Val1',
+                                      'RootProp2' : 'Root-Prop-Val2'}}
+  expected_explicit_props = {}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url + '/A/B/E/alpha', expected_iprops, expected_explicit_props)
+
+  # Proplist directory target with inherited and explicit props.
+  expected_iprops = {sbox.repo_url : {'RootProp1' : 'Root-Prop-Val1',
+                                      'RootProp2' : 'Root-Prop-Val2',
+                                      'DirProp2' : 'Dir-Prop-Val-Root'}}
+  expected_explicit_props = {'DirProp1' : 'Dir-Prop-Val1',
+                             'DirProp2' : 'Dir-Prop-Val2',
+                             'DirProp3' : 'Dir-Prop-Val3'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url + '/A/D', expected_iprops, expected_explicit_props)
+
+  ### Propget Directory Targets
+
+  # Propget directory target with only explicit props.
+  expected_iprops = {}
+  expected_explicit_props = {'RootProp2' : 'Root-Prop-Val2'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url, expected_iprops, expected_explicit_props, 'RootProp2')
+
+  # Propget directory target with only inherited props.
+  expected_iprops = {sbox.repo_url : {'RootProp2': 'Root-Prop-Val2'}}
+  expected_explicit_props = {}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url + '/A/B/E/alpha', expected_iprops, expected_explicit_props,
+    'RootProp2')
+
+  # Propget directory target with inherited and explicit props.
+  expected_iprops = {sbox.repo_url : {'DirProp2' : 'Dir-Prop-Val-Root',}}
+  expected_explicit_props = {'DirProp2' : 'Dir-Prop-Val2'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url + '/A/D', expected_iprops, expected_explicit_props,
+    'DirProp2')
+
+  ### Proplist File Targets
+
+  # Proplist file target with only explicit props.
+  expected_iprops = {}
+  expected_explicit_props = {'FileProp1' : 'File-Prop-Val1'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url + '/iota', expected_iprops, expected_explicit_props,
+    'FileProp1', 2)
+
+  # Proplist file target with only inherited props.
+  expected_iprops = {sbox.repo_url : {'RootProp1' : 'Root-Prop-Val1'}}
+  expected_explicit_props = {}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url + '/A/mu', expected_iprops, expected_explicit_props,
+    'RootProp1')
+
+  # Proplist file target with inherited and explicit props.
+  expected_iprops = {sbox.repo_url : {'RootProp1' : 'Root-Prop-Val1',
+                                      'RootProp2' : 'Root-Prop-Val2',
+                                      'DirProp2' : 'Dir-Prop-Val-Root'},
+                     sbox.repo_url + '/A/D' : {'DirProp1' : 'Dir-Prop-Val1',
+                                               'DirProp2' : 'Dir-Prop-Val2',
+                                               'DirProp3' : 'Dir-Prop-Val3'}}
+  expected_explicit_props = {'FileProp2' : 'File-Prop-Val2'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url + '/A/D/H/psi', expected_iprops, expected_explicit_props)
+
+  ### Propget File Targets
+
+  # Propget file target with only explicit props.
+  expected_iprops = {}
+  expected_explicit_props = {'FileProp1' : 'File-Prop-Val1'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url + '/iota', expected_iprops, expected_explicit_props,
+    'FileProp1', 2)
+
+  # Propget file target with only inherited props.
+  expected_iprops = {sbox.repo_url : {'RootProp2': 'Root-Prop-Val2'}}
+  expected_explicit_props = {}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url + '/A/B/E/alpha', expected_iprops, expected_explicit_props,
+    'RootProp2')
+
+  # Propget file target with inherited and explicit props.
+  expected_iprops = {sbox.repo_url + '/A/D/G' : {
+    'SomeProp' : 'Some-Prop-Val1',}}
+  expected_explicit_props = {'SomeProp' : 'Some-Prop-Val2'}
+  svntest.actions.run_and_verify_inherited_prop_xml(
+    sbox.repo_url + '/A/D/G/rho', expected_iprops, expected_explicit_props,
+    'SomeProp')
+
+########################################################################
+# Run the tests
+
+# list all tests here, starting with None:
+test_list = [ None,
+              iprops_basic_working,
+              iprops_basic_repos,
+            ]
+
+if __name__ == '__main__':
+  svntest.main.run_tests(test_list)
+  # NOTREACHED
+
+### End of file.

Propchange: subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/branches/inheritable-props/subversion/tests/cmdline/iprop_tests.py
------------------------------------------------------------------------------
    svn:executable = *

Modified: subversion/branches/inheritable-props/subversion/tests/cmdline/svntest/actions.py
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/tests/cmdline/svntest/actions.py?rev=1341279&r1=1341278&r2=1341279&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/branches/inheritable-props/subversion/tests/cmdline/svntest/actions.py Tue
May 22 00:05:52 2012
@@ -35,7 +35,7 @@ else:
   from cStringIO import StringIO
 
 import svntest
-from svntest import main, verify, tree, wc
+from svntest import main, verify, tree, wc, sandbox
 from svntest import Failure
 
 logger = logging.getLogger()
@@ -1573,6 +1573,89 @@ def run_and_verify_status_xml(expected_e
           pprint.pformat(expected_entries).splitlines(),
           pprint.pformat(actual_entries).splitlines())))
 
+def run_and_verify_inherited_prop_xml(path_or_url,
+                                      expected_inherited_props,
+                                      expected_explicit_props,
+                                      propname=None,
+                                      revision=None):
+  """If PROPNAME is None, then call run_and_verify_svn with proplist -v --xml
+  --show-inherited-props on PATH_OR_URL, otherwise call run_and_verify_svn
+  with propget PROPNAME --xml --show-inherited-props.
+
+  PATH_OR_URL is pegged at REVISION if the latter is not None.  If REVISION
+  is none, then PATH_OR_URL is pegged at HEAD if a url.
+
+  EXPECTED_INHERITED_PROPS is a (possibly empty) dict mapping working copy
+  paths or URLs to dicts of inherited properties. EXPECTED_EXPLICIT_PROPS is
+  a (possibly empty) dict of the explicit properties expected on PATH_OR_URL.
+
+  Returns on success, raises on failure if EXPECTED_INHERITED_PROPS or
+  EXPECTED_EXPLICIT_PROPS don't match the results of proplist/propget.
+  """
+
+  if revision is None:
+    if sandbox.is_url(path_or_url):
+      path_or_url = path_or_url + '@HEAD'
+  else:
+    path_or_url = path_or_url + '@' + str(revision)
+
+  if (propname):
+    exit_code, output, errput = svntest.actions.run_and_verify_svn(
+      None, None, [], 'propget', propname, '--xml',
+      '--show-inherited-props', path_or_url)
+  else:
+    exit_code, output, errput = svntest.actions.run_and_verify_svn(
+      None, None, [], 'proplist', '-v', '--xml', '--show-inherited-props',
+      path_or_url)
+
+  if len(errput) > 0:
+    raise Failure
+
+  # Props inherited from within the WC are keyed on absolute paths.
+  expected_iprops = {}
+  for x in expected_inherited_props:
+    if sandbox.is_url(x):
+      expected_iprops[x] = expected_inherited_props[x]    
+    else:
+      expected_iprops[os.path.abspath(x)] = expected_inherited_props[x]
+
+  actual_iprops = {}
+  actual_explicit_props = {}
+
+  doc = parseString(''.join(output))
+  targets = doc.getElementsByTagName('target')
+  for t in targets:
+
+    # Create actual inherited props.
+    iprops = t.getElementsByTagName('inherited_property')
+
+    if len(iprops) > 0:
+      actual_iprops[t.getAttribute('path')]={}
+
+    for i in iprops:
+      actual_iprops[t.getAttribute('path')][i.getAttribute('name')] = \
+        i.firstChild.nodeValue
+
+    # Create actual explicit props.
+    xprops = t.getElementsByTagName('property')
+
+    for x in xprops:
+      actual_explicit_props[x.getAttribute('name')] = x.firstChild.nodeValue
+
+  if expected_explicit_props != actual_explicit_props:
+    raise svntest.Failure(
+      'Actual and expected explicit props do not match\n' +
+      '\n'.join(difflib.ndiff(
+      pprint.pformat(expected_explicit_props).splitlines(),
+      pprint.pformat(actual_explicit_props).splitlines())))
+
+  if expected_iprops != actual_iprops:
+    raise svntest.Failure(
+      'Actual and expected inherited props do not match\n' +
+      '\n'.join(difflib.ndiff(
+      pprint.pformat(expected_iprops).splitlines(),
+      pprint.pformat(actual_iprops).splitlines())))
+
 def run_and_verify_diff_summarize_xml(error_re_string = [],
                                       expected_prefix = None,
                                       expected_paths = [],



Mime
View raw message