Author: danielsh
Date: Tue Sep 21 01:53:59 2010
New Revision: 999182

URL: http://svn.apache.org/viewvc?rev=999182&view=rev
Log:
On the atomic-revprop branch:

Extend the tests to explicitly enforce the correct error code.  To this end,
move some of the logic from the Python tests to the C helper.

Specifically, the helper is now always expected to exit(0), regardless of
whether the revpropchange should succeed; it if exits with a non-zero code, then
the test itself will fail.

Review by: Jon Foster

* subversion/tests/cmdline/atomic-ra-revprop-change.c
  (USAGE_MSG):  Document new argv argument.
  (change_rev_prop):  Take WANT_ERROR parameter and use it.
  (main):  Parse another argv argument and pass it to change_rev_prop().

* subversion/tests/cmdline/svntest/main.py
  (run_atomic_ra_revprop_change):
    Take WANT_ERROR parameter and pass it to atomic-ra-revprop-change.

* subversion/tests/cmdline/svntest/actions.py
  (run_and_verify_atomic_ra_revprop_change):
    Take WANT_ERROR parameter and pass it to run_atomic_ra_revprop_change().

* subversion/tests/cmdline/prop_tests.py
  (atomic_over_ra.FAILS_WITH_BPV, atomic_over_ra.PASSES_WITHOUT_BPV):
    Update calls for new parameter and changed semantics (return code
    is always zero now).

Modified:
    
subversion/branches/atomic-revprop/subversion/tests/cmdline/atomic-ra-revprop-change.c
    subversion/branches/atomic-revprop/subversion/tests/cmdline/prop_tests.py
    
subversion/branches/atomic-revprop/subversion/tests/cmdline/svntest/actions.py
    subversion/branches/atomic-revprop/subversion/tests/cmdline/svntest/main.py

Modified: 
subversion/branches/atomic-revprop/subversion/tests/cmdline/atomic-ra-revprop-change.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/atomic-revprop/subversion/tests/cmdline/atomic-ra-revprop-change.c?rev=999182&r1=999181&r2=999182&view=diff
==============================================================================
--- 
subversion/branches/atomic-revprop/subversion/tests/cmdline/atomic-ra-revprop-change.c
 (original)
+++ 
subversion/branches/atomic-revprop/subversion/tests/cmdline/atomic-ra-revprop-change.c
 Tue Sep 21 01:53:59 2010
@@ -41,11 +41,16 @@
 #define KEY_NEW_PROPVAL "value"
 
 #define USAGE_MSG \
-  "Usage: %s URL REVISION PROPNAME VALUES_SKEL HTTP_LIBRARY\n" \
+  "Usage: %s URL REVISION PROPNAME VALUES_SKEL HTTP_LIBRARY WANT_ERROR\n" \
   "\n" \
   "VALUES_SKEL is a proplist skel containing pseudo-properties '%s' \n" \
   "and '%s'.  A pseudo-property missing from the skel is interpreted \n" \
-  "as unset.\n"
+  "as unset.\n" \
+  "\n" \
+  "WANT_ERROR is 1 if the propchange is expected to fail due to the 
atomicity,"\
+  "and 0 if it is expected to succeed.  If the expectation matches reality," \
+  "the exit code shall be zero.\n"
+
 
 
 /* implements svn_auth_simple_prompt_func_t */
@@ -134,12 +139,14 @@ change_rev_prop(const char *url,
                 const svn_string_t *propval,
                 const svn_string_t *old_value,
                 const char *http_library,
+                svn_boolean_t want_error,
                 apr_pool_t *pool)
 {
   svn_ra_callbacks2_t *callbacks;
   svn_ra_session_t *sess;
   apr_hash_t *config;
   svn_boolean_t capable;
+  svn_error_t *err;
 
   SVN_ERR(svn_ra_create_callbacks(&callbacks, pool));
   SVN_ERR(construct_auth_baton(&callbacks->auth_baton, pool));
@@ -152,15 +159,32 @@ change_rev_prop(const char *url,
                                 SVN_RA_CAPABILITY_ATOMIC_REVPROPS,
                                 pool));
   if (capable)
-    SVN_ERR(svn_ra_change_rev_prop2(sess, revision, propname,
-                                    &old_value, propval, pool));
+    {
+      err = svn_ra_change_rev_prop2(sess, revision, propname,
+                                    &old_value, propval, pool);
+
+      if (want_error && err
+          && svn_error_has_cause(err, SVN_ERR_FS_PROP_BASEVALUE_MISMATCH))
+        {
+          /* Expectation was matched.  Get out. */
+          svn_error_clear(err);
+          return SVN_NO_ERROR;
+        }
+      else if (! want_error && ! err)
+        /* Expectation was matched.  Get out. */
+       return SVN_NO_ERROR;
+      else if (want_error && ! err)
+        return svn_error_create(SVN_ERR_TEST_FAILED, NULL,
+                                "An error was expected but not seen");
+      else
+       /* A real (non-SVN_ERR_FS_PROP_BASEVALUE_MISMATCH) error. */
+       return svn_error_return(err);
+    }
   else
     /* Running under --server-minor-version? */
     return svn_error_create(SVN_ERR_TEST_FAILED, NULL,
                             "Server doesn't advertise "
                             "SVN_RA_CAPABILITY_ATOMIC_REVPROPS");
-
-  return SVN_NO_ERROR;
 }
 
 /* Parse SKEL_CSTR according to the description in USAGE_MSG. */
@@ -194,8 +218,9 @@ main(int argc, const char *argv[])
   svn_string_t *old_propval;
   const char *http_library;
   char *digits_end = NULL;
+  svn_boolean_t want_error;
 
-  if (argc != 6)
+  if (argc != 7)
     {
       fprintf(stderr, USAGE_MSG, argv[0], KEY_OLD_PROPVAL, KEY_NEW_PROPVAL);
       exit(1);
@@ -216,6 +241,7 @@ main(int argc, const char *argv[])
   propname = argv[3];
   SVN_INT_ERR(extract_values_from_skel(&old_propval, &propval, argv[4], pool));
   http_library = argv[5];
+  want_error = !strcmp(argv[6], "1");
 
   if ((! SVN_IS_VALID_REVNUM(revision)) || (! digits_end) || *digits_end)
     SVN_INT_ERR(svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
@@ -223,7 +249,7 @@ main(int argc, const char *argv[])
 
   /* Do something. */
   err = change_rev_prop(url, revision, propname, propval, old_propval,
-                        http_library, pool);
+                        http_library, want_error, pool);
   if (err)
     {
       svn_handle_error2(err, stderr, FALSE, "atomic-ra-revprop-change: ");

Modified: 
subversion/branches/atomic-revprop/subversion/tests/cmdline/prop_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/atomic-revprop/subversion/tests/cmdline/prop_tests.py?rev=999182&r1=999181&r2=999182&view=diff
==============================================================================
--- subversion/branches/atomic-revprop/subversion/tests/cmdline/prop_tests.py 
(original)
+++ subversion/branches/atomic-revprop/subversion/tests/cmdline/prop_tests.py 
Tue Sep 21 01:53:59 2010
@@ -2008,10 +2008,9 @@ def atomic_over_ra(sbox):
 
   def FAILS_WITH_BPV(not_the_old_value, proposed_value):
     if svntest.main.server_has_atomic_revprop():
-      expected_stderr = ".*revprop 'flower' has unexpected value.*"
       svntest.actions.run_and_verify_atomic_ra_revprop_change(
-         None, None, expected_stderr, 1, repo_url, 0, 'flower',
-         not_the_old_value, proposed_value)
+         None, None, [], 0, repo_url, 0, 'flower',
+         not_the_old_value, proposed_value, True)
     else:
       expect_old_server_fail(not_the_old_value, proposed_value)
 
@@ -2019,7 +2018,7 @@ def atomic_over_ra(sbox):
     if svntest.main.server_has_atomic_revprop():
       svntest.actions.run_and_verify_atomic_ra_revprop_change(
          None, None, [], 0, repo_url, 0, 'flower',
-         yes_the_old_value, proposed_value)
+         yes_the_old_value, proposed_value, False)
     else:
       expect_old_server_fail(yes_the_old_value, proposed_value)
 

Modified: 
subversion/branches/atomic-revprop/subversion/tests/cmdline/svntest/actions.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/atomic-revprop/subversion/tests/cmdline/svntest/actions.py?rev=999182&r1=999181&r2=999182&view=diff
==============================================================================
--- 
subversion/branches/atomic-revprop/subversion/tests/cmdline/svntest/actions.py 
(original)
+++ 
subversion/branches/atomic-revprop/subversion/tests/cmdline/svntest/actions.py 
Tue Sep 21 01:53:59 2010
@@ -152,7 +152,8 @@ def run_and_verify_atomic_ra_revprop_cha
                                             expected_stderr,
                                             expected_exit, 
                                             url, revision, propname,
-                                            old_propval, propval):
+                                            old_propval, propval,
+                                            want_error):
   """Run atomic-ra-revprop-change helper and check its output and exit code.
   Transforms OLD_PROPVAL and PROPVAL into a skel.
   For HTTP, the default HTTP library is used."""
@@ -173,7 +174,8 @@ def run_and_verify_atomic_ra_revprop_cha
                         make_proplist_skel_part(KEY_NEW_PROPVAL, propval))
 
   exit_code, out, err = main.run_atomic_ra_revprop_change(url, revision,
-                                                          propname, skel)
+                                                          propname, skel,
+                                                          want_error)
   verify.verify_outputs("Unexpected output", out, err,
                         expected_stdout, expected_stderr)
   verify.verify_exit_code(message, exit_code, expected_exit)

Modified: 
subversion/branches/atomic-revprop/subversion/tests/cmdline/svntest/main.py
URL: 
http://svn.apache.org/viewvc/subversion/branches/atomic-revprop/subversion/tests/cmdline/svntest/main.py?rev=999182&r1=999181&r2=999182&view=diff
==============================================================================
--- subversion/branches/atomic-revprop/subversion/tests/cmdline/svntest/main.py 
(original)
+++ subversion/branches/atomic-revprop/subversion/tests/cmdline/svntest/main.py 
Tue Sep 21 01:53:59 2010
@@ -641,7 +641,7 @@ def run_entriesdump_subdirs(path):
                                                         0, 0, None, 
'--subdirs', path)
   return [line.strip() for line in stdout_lines if not line.startswith("DBG:")]
 
-def run_atomic_ra_revprop_change(url, revision, propname, skel):
+def run_atomic_ra_revprop_change(url, revision, propname, skel, want_error):
   """Run the atomic-ra-revprop-change helper, returning its exit code, stdout, 
   and stderr.  For HTTP, default HTTP library is used."""
   # use spawn_process rather than run_command to avoid copying all the data
@@ -652,7 +652,7 @@ def run_atomic_ra_revprop_change(url, re
   # This passes HTTP_LIBRARY in addition to our params.
   return run_command(atomic_ra_revprop_change_binary, True, False, 
                      url, revision, propname, skel,
-                     options.http_library)
+                     options.http_library, want_error and 1 or 0)
 
 
 # Chmod recursively on a whole subtree


Reply via email to