subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ne...@apache.org
Subject svn commit: r1409852 - in /subversion/trunk: build.conf subversion/libsvn_wc/externals.c subversion/tests/libsvn_wc/externals-test.c
Date Thu, 15 Nov 2012 15:57:06 GMT
Author: neels
Date: Thu Nov 15 15:57:05 2012
New Revision: 1409852

URL: http://svn.apache.org/viewvc?rev=1409852&view=rev
Log:
Make svn_wc_parse_externals_description3 behave as described.

* subversion/libsvn_wc/externals.c (svn_wc_parse_externals_description3):
   If DESC is invalid, really do not touch *EXTERNALS_P, as advertised in
   include/svn_wc.h.

* subversion/tests/libsvn_wc/externals-test.c,
* build.conf (externals-test, __ALL_TESTS__):
   Add new test for above.

Added:
    subversion/trunk/subversion/tests/libsvn_wc/externals-test.c
Modified:
    subversion/trunk/build.conf
    subversion/trunk/subversion/libsvn_wc/externals.c

Modified: subversion/trunk/build.conf
URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1409852&r1=1409851&r2=1409852&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Thu Nov 15 15:57:05 2012
@@ -1022,6 +1022,14 @@ sources = wc-queries-test.c
 install = test
 libs = libsvn_test libsvn_subr apriconv apr sqlite
 
+[externals-test]
+description = Test externals
+type = exe
+path = subversion/tests/libsvn_wc
+sources = externals-test.c utils.c
+install = test
+libs = libsvn_client libsvn_test libsvn_wc libsvn_subr apriconv apr
+
 # ----------------------------------------------------------------------------
 # These are not unit tests at all, they are small programs that exercise
 # parts of the libsvn_delta API from the command line.  They are stuck here
@@ -1183,7 +1191,7 @@ libs = __ALL__
        diff diff3 diff4 fsfs-reorg svn-bench
        client-test
        conflict-data-test db-test pristine-store-test entries-compat-test
-       op-depth-test dirent_uri-test wc-queries-test
+       op-depth-test dirent_uri-test wc-queries-test externals-test
        auth-test
        parse-diff-test
        svn-rep-sharing-stats svn-populate-node-origins-index

Modified: subversion/trunk/subversion/libsvn_wc/externals.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/externals.c?rev=1409852&r1=1409851&r2=1409852&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/externals.c (original)
+++ subversion/trunk/subversion/libsvn_wc/externals.c Thu Nov 15 15:57:05 2012
@@ -163,13 +163,16 @@ svn_wc_parse_externals_description3(apr_
                                     svn_boolean_t canonicalize_url,
                                     apr_pool_t *pool)
 {
-  apr_array_header_t *lines = svn_cstring_split(desc, "\n\r", TRUE, pool);
   int i;
+  apr_array_header_t *externals = NULL;
+  apr_array_header_t *lines = svn_cstring_split(desc, "\n\r", TRUE, pool);
   const char *parent_directory_display = svn_path_is_url(parent_directory) ?
     parent_directory : svn_dirent_local_style(parent_directory, pool);
 
+  /* If an error occurs halfway through parsing, *externals_p should stay
+   * untouched. So, store the list in a local var first. */
   if (externals_p)
-    *externals_p = apr_array_make(pool, 1, sizeof(svn_wc_external_item2_t *));
+    externals = apr_array_make(pool, 1, sizeof(svn_wc_external_item2_t *));
 
   for (i = 0; i < lines->nelts; i++)
     {
@@ -327,10 +330,13 @@ svn_wc_parse_externals_description3(apr_
             item->url = svn_dirent_canonicalize(item->url, pool);
         }
 
-      if (externals_p)
-        APR_ARRAY_PUSH(*externals_p, svn_wc_external_item2_t *) = item;
+      if (externals)
+        APR_ARRAY_PUSH(externals, svn_wc_external_item2_t *) = item;
     }
 
+  if (externals_p)
+    *externals_p = externals;
+
   return SVN_NO_ERROR;
 }
 

Added: subversion/trunk/subversion/tests/libsvn_wc/externals-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/externals-test.c?rev=1409852&view=auto
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/externals-test.c (added)
+++ subversion/trunk/subversion/tests/libsvn_wc/externals-test.c Thu Nov 15 15:57:05 2012
@@ -0,0 +1,93 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+/*
+ * externals-test.c -- test externals
+ */
+
+#include <stdio.h>
+#include <apr_tables.h>
+
+#include "svn_wc.h"
+#include "utils.h"
+
+/* A quick way to create error messages.  */
+static svn_error_t *
+fail(apr_pool_t *pool, const char *fmt, ...)
+{
+  va_list ap;
+  char *msg;
+
+  va_start(ap, fmt);
+  msg = apr_pvsprintf(pool, fmt, ap);
+  va_end(ap);
+
+  return svn_error_create(SVN_ERR_TEST_FAILED, 0, msg);
+}
+
+static svn_error_t *
+test_parse_erratic_externals_definition(apr_pool_t *pool)
+{
+  svn_error_t *err;
+  apr_array_header_t *list = NULL;
+
+  err = svn_wc_parse_externals_description3(
+          &list, "parent_dir",
+          "^/valid/but/should/not/be/on/record wc_target\n"
+           "because_this_is_an_error",
+          FALSE, pool);
+
+  if (err == NULL)
+    return fail(pool,
+            "expected error from svn_wc_parse_externals_description3().\n"
+            );
+  else
+    svn_error_clear(err);
+
+  if (list != NULL)
+    {
+      int i;
+      printf("LIST now has items:\n");
+      for (i = 0; i < list->nelts; i++)
+        {
+          svn_wc_external_item2_t *item = APR_ARRAY_IDX(list, i,
+                                                        svn_wc_external_item2_t*);
+          printf("- target_dir='%s' url='%s'\n", item->target_dir, item->url);
+        }
+
+      return fail(pool,
+                  "svn_wc_parse_externals_description3() should not "
+                  "touch LIST when DESC had an error.\n");
+    }
+
+  return SVN_NO_ERROR;
+}
+
+/* The test table.  */
+
+struct svn_test_descriptor_t test_funcs[] =
+  {
+    SVN_TEST_NULL,
+    SVN_TEST_PASS2(test_parse_erratic_externals_definition,
+                   "parse erratic externals definition"),
+    SVN_TEST_NULL
+  };
+



Mime
View raw message