subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r933481 - in /subversion/trunk/subversion/tests/cmdline: schedule_tests.py svntest/main.py svntest/sandbox.py
Date Tue, 13 Apr 2010 04:20:51 GMT
Author: gstein
Date: Tue Apr 13 04:20:50 2010
New Revision: 933481

URL: http://svn.apache.org/viewvc?rev=933481&view=rev
Log:
Add some new methods to the Sandbox class for performing simple,
unverified operations.

Also introduce deep magic with svntest.main.make_log_msg() to produce log
messages that show the source of the command invocation. These automated
log messages look like:

----
r2 | jrandom | 2010-04-12 23:57:10 -0400 (Mon, 12 Apr 2010) | 1 line

File './schedule_tests.py', line 543, in status_add_deleted_directory
----

* subversion/tests/cmdline/svntest/sandbox.py:
  (Sandbox.simple_commit, Sandbox.simple_rm, Sandbox.simple_mkdir): new
    methods to perform some basic operations. these first few support
    schedule_tests
  (is_url): helper function to detect URL targets, which need a commit
    message.

* subversion/tests/cmdline/svntest/main.py:
  (make_log_msg): voodoo that returns a helpful log message

* subversion/tests/cmdline/schedule_tests.py:
  (delete_missing, revert_inside_newly_added_dir,
      status_add_deleted_directory): use the new methods

Modified:
    subversion/trunk/subversion/tests/cmdline/schedule_tests.py
    subversion/trunk/subversion/tests/cmdline/svntest/main.py
    subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py

Modified: subversion/trunk/subversion/tests/cmdline/schedule_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/schedule_tests.py?rev=933481&r1=933480&r2=933481&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/schedule_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/schedule_tests.py Tue Apr 13 04:20:50 2010
@@ -476,7 +476,7 @@ def delete_missing(sbox):
   svntest.main.safe_rmtree(H_path)
 
   # Now schedule them for deletion anyway, and make sure no error is output.
-  svntest.actions.run_and_verify_svn(None, None, [], 'rm', mu_path, H_path)
+  sbox.simple_rm(mu_path, H_path)
 
   # Commit the deletions.
   expected_output = svntest.wc.State(wc_dir, {
@@ -515,8 +515,7 @@ def revert_inside_newly_added_dir(sbox):
   # Now change into the newly added directory, revert and make sure
   # no error is output.
   os.chdir('foo')
-  svntest.actions.run_and_verify_svn(None, None, [],
-                                     'revert', '.')
+  svntest.actions.run_and_verify_svn(None, None, [], 'revert', '.')
 
 #----------------------------------------------------------------------
 # Regression test for issue #1609:
@@ -539,11 +538,10 @@ def status_add_deleted_directory(sbox):
   # svn mkdir wc/foo
 
   A_path = os.path.join(wc_dir, 'A')
-  svntest.actions.run_and_verify_svn(None, None, [], 'rm', A_path)
+  sbox.simple_rm(A_path)
   svntest.main.safe_rmtree(A_path)
-  svntest.actions.run_and_verify_svn(None, None, [],
-                                     'ci', '-m', 'log msg', wc_dir)
-  svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', A_path)
+  sbox.simple_commit()
+  sbox.simple_mkdir(A_path)
 
   expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
   expected_status = svntest.wc.State(wc_dir,

Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=933481&r1=933480&r2=933481&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Tue Apr 13 04:20:50 2010
@@ -987,6 +987,34 @@ def merge_notify_line(revstart=None, rev
              % (from_foreign_phrase, revstart, revend)
 
 
+def make_log_msg():
+  "Conjure up a log message based on the calling test."
+
+  for idx in range(1, 100):
+    frame = sys._getframe(idx)
+
+    # If this frame isn't from a function in *_tests.py, then skip it.
+    filename = frame.f_code.co_filename
+    if not filename.endswith('_tests.py'):
+      continue
+
+    # There should be a test_list in this module.
+    test_list = frame.f_globals.get('test_list')
+    if test_list is None:
+      continue
+
+    # If the function is not in the test_list, then skip it.
+    func_name = frame.f_code.co_name
+    func_ob = frame.f_globals.get(func_name)
+    if func_ob not in test_list:
+      continue
+
+    # Make the log message look like a line from a traceback.
+    # Well...close. We use single quotes to avoid interfering with the
+    # double-quote quoting performed on Windows
+    return "File '%s', line %d, in %s" % (filename, frame.f_lineno, func_name)
+
+
 ######################################################################
 # Functions which check the test configuration
 # (useful for conditional XFails)

Modified: subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py?rev=933481&r1=933480&r2=933481&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/sandbox.py Tue Apr 13 04:20:50 2010
@@ -147,6 +147,33 @@ class Sandbox:
     "Returns True when build() has been called on this instance."
     return self._is_built
 
+  def simple_commit(self, target_dir=None):
+    if target_dir is None:
+      target_dir = self.wc_dir
+    svntest.actions.run_and_verify_svn(None, None, [],
+                                       'commit',
+                                       '-m', svntest.main.make_log_msg(),
+                                       target_dir)
+
+  def simple_rm(self, *targets):
+    if len(targets) == 1 and is_url(targets[0]):
+      targets = ('-m', svntests.main.make_log_msg(), targets[0])
+    svntest.actions.run_and_verify_svn(None, None, [], 'rm', *targets)
+
+  def simple_mkdir(self, *targets):
+    if len(targets) == 1 and is_url(targets[0]):
+      targets = ('-m', svntests.main.make_log_msg(), targets[0])
+    svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', *targets)
+
+
+def is_url(target):
+  return (target.startswith('^/')
+          or target.startswith('file://')
+          or target.startswith('http://')
+          or target.startswith('https://')
+          or target.startswith('svn://')
+          or target.startswith('svn+ssh://'))
+
 
 _deferred_test_paths = []
 



Mime
View raw message