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 2016/12/09 17:14:15 UTC

svn commit: r1773439 - in /subversion/trunk/subversion/tests/cmdline: autoprop_tests.py basic_tests.py import_tests.py prop_tests.py stat_tests.py svntest/sandbox.py

Author: julianfoad
Date: Fri Dec  9 17:14:15 2016
New Revision: 1773439

URL: http://svn.apache.org/viewvc?rev=1773439&view=rev
Log:
In the test suite, provide and use a sandbox-specific method when we need to
create a local config directory.

This makes the path and name of the config directory more consistent, and
enforces segregation of directories used by different tests. Not that any of
the existing tests did use clashing directory paths, but some of them were a
bit "too close for comfort". Using this will ensure they can't in future. It
also simplifies the call site.

This is just something I found that could be improved -- there was no bug
report or issue related to it.

* subversion/tests/cmdline/autoprop_tests.py
  (create_config,
   create_inherited_autoprops_config): Use sbox.create_config_dir().
  (autoprops_test,
   inheritable_autoprops_test,
   svn_prop_inheritable_autoprops_add_versioned_target): Adjust their callers.

* subversion/tests/cmdline/basic_tests.py
  (basic_auth_test): Use sbox.create_config_dir().

* subversion/tests/cmdline/import_tests.py
  (import_inherited_ignores): Adjust call to create_inherited_ignores_config().

* subversion/tests/cmdline/prop_tests.py
  (create_inherited_ignores_config): Use sbox.create_config_dir().
  (inheritable_ignores): Adjust its caller.

* subversion/tests/cmdline/stat_tests.py
  (timestamp_behaviour): Use sbox.create_config_dir().

* subversion/tests/cmdline/svntest/sandbox.py
  (Sandbox.create_config_dir): New method.

Modified:
    subversion/trunk/subversion/tests/cmdline/autoprop_tests.py
    subversion/trunk/subversion/tests/cmdline/basic_tests.py
    subversion/trunk/subversion/tests/cmdline/import_tests.py
    subversion/trunk/subversion/tests/cmdline/prop_tests.py
    subversion/trunk/subversion/tests/cmdline/stat_tests.py
    subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py

Modified: subversion/trunk/subversion/tests/cmdline/autoprop_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/autoprop_tests.py?rev=1773439&r1=1773438&r2=1773439&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/autoprop_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/autoprop_tests.py Fri Dec  9 17:14:15 2016
@@ -60,7 +60,7 @@ def check_proplist(path, exp_out):
 
 #----------------------------------------------------------------------
 
-def create_config(config_dir, enable_flag):
+def create_config(sbox, enable_flag):
   "create config directories and files"
 
   # contents of the file 'config'
@@ -82,7 +82,7 @@ quotetest = svn:keywords="Author Date Id
 * = auto=oui
 ''' % (enable_flag and 'yes' or 'no')
 
-  svntest.main.create_config_dir(config_dir, config_contents)
+  return sbox.create_config_dir(config_contents)
 
 #----------------------------------------------------------------------
 
@@ -103,9 +103,11 @@ def autoprops_test(sbox, cmd, cfgenable,
   # some directories
   wc_dir = sbox.wc_dir
   tmp_dir = os.path.abspath(sbox.add_wc_path('autoprops'))
-  config_dir = os.path.join(tmp_dir, 'autoprops_config_' + sbox.name)
+  os.makedirs(tmp_dir)
   repos_url = sbox.repo_url
 
+  config_dir = create_config(sbox, cfgenable)
+
   # initialize parameters
   if cmd == 'import':
     parameters = ['import', '-m', 'bla']
@@ -116,8 +118,6 @@ def autoprops_test(sbox, cmd, cfgenable,
 
   parameters = parameters + ['--config-dir', config_dir]
 
-  create_config(config_dir, cfgenable)
-
   # add comandline flags
   if clienable == 1:
     parameters = parameters + ['--auto-props']
@@ -327,7 +327,7 @@ def fail_add_mixed_eol_style(sbox):
 
 #----------------------------------------------------------------------
 
-def create_inherited_autoprops_config(config_dir, enable_flag):
+def create_inherited_autoprops_config(sbox, enable_flag):
   "create config stuffs for inherited autoprops tests"
 
   # contents of the file 'config'
@@ -342,7 +342,7 @@ enable-auto-props = %s
 *.c = svn:keywords=Author Date Id Rev URL;svn:eol-style=native;
 ''' % (enable_flag and 'yes' or 'no')
 
-  svntest.main.create_config_dir(config_dir, config_contents)
+  return sbox.create_config_dir(config_contents)
 
 #----------------------------------------------------------------------
 def check_inheritable_autoprops(sbox, auto_props_cfg_enabled,
@@ -416,9 +416,11 @@ def inheritable_autoprops_test(sbox, cmd
   # some directories
   wc_dir = sbox.wc_dir
   tmp_dir = os.path.abspath(sbox.add_wc_path('iautoprops'))
-  config_dir = os.path.join(tmp_dir, 'autoprops_config_' + sbox.name)
+  os.makedirs(tmp_dir)
   repos_url = sbox.repo_url
 
+  config_dir = create_inherited_autoprops_config(sbox, cfgenable)
+
   # initialize parameters
   if cmd == 'import':
     parameters = ['import', '-m', 'importing']
@@ -429,8 +431,6 @@ def inheritable_autoprops_test(sbox, cmd
 
   parameters = parameters + ['--config-dir', config_dir]
 
-  create_inherited_autoprops_config(config_dir, cfgenable)
-
   # add comandline flags
   inheritable_auto_props_enabled = 1
   if clienable == 1:
@@ -647,10 +647,7 @@ def svn_prop_inheritable_autoprops_add_v
   #
   # Then revert the previous additions and add again, only the
   # svn:auto-props should be applied.
-  tmp_dir = os.path.abspath(sbox.add_wc_path('temp'))
-  config_dir = os.path.join(tmp_dir,
-                            'autoprops_config_disabled_' + sbox.name)
-  create_inherited_autoprops_config(config_dir, False)
+  config_dir = create_inherited_autoprops_config(sbox, False)
 
   svntest.main.run_svn(None, 'revert', '-R', sbox.wc_dir)
   os.chdir(sbox.wc_dir)

Modified: subversion/trunk/subversion/tests/cmdline/basic_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/basic_tests.py?rev=1773439&r1=1773438&r2=1773439&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/basic_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/basic_tests.py Fri Dec  9 17:14:15 2016
@@ -2539,9 +2539,7 @@ def basic_auth_test(sbox):
   wc_dir = sbox.wc_dir
 
   # Set up a custom config directory
-  tmp_dir = os.path.abspath(svntest.main.temp_dir)
-  config_dir = os.path.join(tmp_dir, 'auth-test-config')
-  svntest.main.create_config_dir(config_dir, None)
+  config_dir = sbox.create_config_dir()
 
   # Checkout with jrandom
   exit_code, output, errput = svntest.main.run_command(

Modified: subversion/trunk/subversion/tests/cmdline/import_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/import_tests.py?rev=1773439&r1=1773438&r2=1773439&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/import_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/import_tests.py Fri Dec  9 17:14:15 2016
@@ -316,9 +316,7 @@ enable-auto-props = yes
 *.dsp = svn:eol-style=CRLF
 *.txt = svn:eol-style=native
 '''
-  tmp_dir = os.path.abspath(svntest.main.temp_dir)
-  config_dir = os.path.join(tmp_dir, 'autoprops_config')
-  svntest.main.create_config_dir(config_dir, config_contents)
+  config_dir = sbox.create_config_dir(config_contents)
 
   # create a new file and import it
   file_name = "test.dsp"
@@ -418,9 +416,7 @@ def import_inherited_ignores(sbox):
   #
   #   [miscellany]
   #   global-ignores = *.boo *.goo
-  tmp_dir = os.path.abspath(svntest.main.temp_dir)
-  config_dir = os.path.join(tmp_dir, 'autoprops_config_' + sbox.name)
-  create_inherited_ignores_config(config_dir)
+  config_dir = create_inherited_ignores_config(sbox)
 
   # Set some ignore properties.
   sbox.simple_propset(SVN_PROP_INHERITABLE_IGNORES, '*.voo *.noo *.loo', '.')
@@ -446,6 +442,7 @@ def import_inherited_ignores(sbox):
   #   DIR7
   #     file7.foo
   #     DIR8.noo
+  tmp_dir = os.path.abspath(svntest.main.temp_dir)
   import_tree_dir = os.path.join(tmp_dir, 'import_tree_' + sbox.name)
 
   # Relative WC paths of the imported tree.

Modified: subversion/trunk/subversion/tests/cmdline/prop_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/prop_tests.py?rev=1773439&r1=1773438&r2=1773439&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/prop_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/prop_tests.py Fri Dec  9 17:14:15 2016
@@ -2374,7 +2374,7 @@ def pristine_props_listed(sbox):
   svntest.actions.run_and_verify_svn(expected_output, [],
                                      'proplist', '-R', wc_dir, '-r', 'BASE')
 
-def create_inherited_ignores_config(config_dir):
+def create_inherited_ignores_config(sbox):
   "create config stuffs for inherited ignores tests"
 
   # contents of the file 'config'
@@ -2383,7 +2383,7 @@ def create_inherited_ignores_config(conf
 global-ignores = *.boo *.goo
 '''
 
-  svntest.main.create_config_dir(config_dir, config_contents)
+  return sbox.create_config_dir(config_contents)
 
 def inheritable_ignores(sbox):
   "inheritable ignores with svn:ignores and config"
@@ -2391,9 +2391,7 @@ def inheritable_ignores(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
-  tmp_dir = os.path.abspath(svntest.main.temp_dir)
-  config_dir = os.path.join(tmp_dir, 'autoprops_config_' + sbox.name)
-  create_inherited_ignores_config(config_dir)
+  config_dir = create_inherited_ignores_config(sbox)
 
   sbox.simple_propset(SVN_PROP_INHERITABLE_IGNORES, '*.doo', 'A/B')
   sbox.simple_propset(SVN_PROP_INHERITABLE_IGNORES, '*.moo', 'A/D')

Modified: subversion/trunk/subversion/tests/cmdline/stat_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/stat_tests.py?rev=1773439&r1=1773438&r2=1773439&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/stat_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/stat_tests.py Fri Dec  9 17:14:15 2016
@@ -702,8 +702,6 @@ def timestamp_behaviour(sbox):
   text_time_behaviour(wc_dir, iota_path, 'iota', expected_status, 'cleanup')
 
   # Create a config to enable use-commit-times
-  config_dir = os.path.join(os.path.abspath(svntest.main.temp_dir),
-                            'use_commit_config')
   config_contents = '''\
 [auth]
 password-stores =
@@ -711,7 +709,7 @@ password-stores =
 [miscellany]
 use-commit-times = yes
 '''
-  svntest.main.create_config_dir(config_dir, config_contents)
+  config_dir = sbox.create_config_dir(config_contents)
 
   other_wc = sbox.add_wc_path('other')
   svntest.actions.run_and_verify_svn(None, [],

Modified: subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py?rev=1773439&r1=1773438&r2=1773439&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py Fri Dec  9 17:14:15 2016
@@ -226,6 +226,20 @@ class Sandbox:
 
     return os.path.join(self.tmp_dir, '%s-%s' % (prefix, self.tempname_offs))
 
+  def create_config_dir(self, config_contents=None, server_contents=None,
+                        ssl_cert=None, ssl_url=None, http_proxy=None,
+                        exclusive_wc_locks=None):
+    """Create a config directory with specified or default files.
+       Return its path.
+    """
+
+    tmp_dir = os.path.abspath(svntest.main.temp_dir)
+    config_dir = os.path.join(tmp_dir, 'config_' + self.name)
+    svntest.main.create_config_dir(config_dir, config_contents, server_contents,
+                                   ssl_cert, ssl_url, http_proxy,
+                                   exclusive_wc_locks)
+    return config_dir
+
   def cleanup_test_paths(self):
     "Clean up detritus from this sandbox, and any dependents."
     if self.dependents: