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 2010/10/19 18:22:08 UTC

svn commit: r1024311 - in /subversion/trunk: build.conf subversion/tests/libsvn_wc/pristine-store-test.c subversion/tests/svn_test_utils.c subversion/tests/svn_test_utils.h

Author: julianfoad
Date: Tue Oct 19 16:22:08 2010
New Revision: 1024311

URL: http://svn.apache.org/viewvc?rev=1024311&view=rev
Log:
Share a utility function in the C tests.

* subversion/tests/svn_test_utils.c,
  subversion/tests/svn_test_utils.h
    New files, containing svn_test__create_repos_and_wc().

* subversion/tests/libsvn_wc/pristine-store-test.c
  (create_repos_and_wc): Re-write as a simple wrapper around
    svn_test__create_repos_and_wc().

* build.conf
  (libsvn_test): Add libsvn_client as a dependency.

Added:
    subversion/trunk/subversion/tests/svn_test_utils.c
    subversion/trunk/subversion/tests/svn_test_utils.h
Modified:
    subversion/trunk/build.conf
    subversion/trunk/subversion/tests/libsvn_wc/pristine-store-test.c

Modified: subversion/trunk/build.conf
URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1024311&r1=1024310&r2=1024311&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Tue Oct 19 16:22:08 2010
@@ -614,7 +614,7 @@ link-cmd = $(LINK_JAVAHL_CXX)
 type = lib
 path = subversion/tests
 install = test
-libs = libsvn_repos libsvn_fs libsvn_delta libsvn_subr aprutil apriconv apr
+libs = libsvn_client libsvn_repos libsvn_fs libsvn_delta libsvn_subr aprutil apriconv apr
 msvc-static = yes
 undefined-lib-symbols = yes
 

Modified: subversion/trunk/subversion/tests/libsvn_wc/pristine-store-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/pristine-store-test.c?rev=1024311&r1=1024310&r2=1024311&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/pristine-store-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/pristine-store-test.c Tue Oct 19 16:22:08 2010
@@ -48,18 +48,10 @@
 #include "private/svn_wc_private.h"
 
 #include "../svn_test.h"
-#include "../svn_test_fs.h"
+#include "../svn_test_utils.h"
 
 
-#define REPOSITORIES_WORK_DIR "svn-test-work/repositories"
-#define WCS_WORK_DIR "svn-test-work/working-copies"
-
-/* Create an empty repository and WC for the test TEST_NAME, and open a WC
- * DB context.  Set *REPOS_URL to the URL of the new repository, *WC_ABSPATH
- * to the root path of the new WC, and *DB to a new DB context.
- *
- * Create the repository and WC in subdirectories called repos/TEST_NAME and
- * wcs/TEST_NAME respectively, within the current working directory. */
+/* Create repos and WC, and also set *DB to a new DB context. */
 static svn_error_t *
 create_repos_and_wc(const char **repos_url,
                     const char **wc_abspath,
@@ -68,41 +60,8 @@ create_repos_and_wc(const char **repos_u
                     const svn_test_opts_t *opts,
                     apr_pool_t *pool)
 {
-  const char *repos_path = svn_relpath_join(REPOSITORIES_WORK_DIR, test_name,
-                                            pool);
-  const char *wc_path = svn_relpath_join(WCS_WORK_DIR, test_name, pool);
-
-  /* Remove the repo and WC dirs if they already exist, to ensure the test
-   * will run even if a previous failed attempt was not cleaned up. */
-  SVN_ERR(svn_io_remove_dir2(repos_path, TRUE, NULL, NULL, pool));
-  SVN_ERR(svn_io_remove_dir2(wc_path, TRUE, NULL, NULL, pool));
-
-  /* Create the parent dirs of the repo and WC if necessary. */
-  SVN_ERR(svn_io_make_dir_recursively(REPOSITORIES_WORK_DIR, pool));
-  SVN_ERR(svn_io_make_dir_recursively(WCS_WORK_DIR, pool));
-
-  /* Create a repos and set *REPOS_URL to its path. */
-  {
-    svn_repos_t *repos;
-
-    SVN_ERR(svn_test__create_repos(&repos, repos_path, opts, pool));
-    SVN_ERR(svn_uri_get_file_url_from_dirent(repos_url, repos_path, pool));
-  }
-
-  /* Create a WC */
-  {
-    svn_client_ctx_t *ctx;
-    svn_opt_revision_t head_rev = { svn_opt_revision_head, {0} };
-
-    SVN_ERR(svn_client_create_context(&ctx, pool));
-    /* SVN_ERR(svn_config_get_config(&ctx->config, config_dir, pool)); */
-    SVN_ERR(svn_dirent_get_absolute(wc_abspath, wc_path, pool));
-    SVN_ERR(svn_client_checkout3(NULL, *repos_url, *wc_abspath,
-                                 &head_rev, &head_rev, svn_depth_infinity,
-                                 FALSE /* ignore_externals */,
-                                 FALSE /* allow_unver_obstructions */,
-                                 ctx, pool));
-  }
+  SVN_ERR(svn_test__create_repos_and_wc(repos_url, wc_abspath, test_name,
+                                        opts, pool));
 
   /* Open a DB context */
   SVN_ERR(svn_wc__db_open(db, svn_wc__db_openmode_readonly, NULL,

Added: subversion/trunk/subversion/tests/svn_test_utils.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_utils.c?rev=1024311&view=auto
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_utils.c (added)
+++ subversion/trunk/subversion/tests/svn_test_utils.c Tue Oct 19 16:22:08 2010
@@ -0,0 +1,73 @@
+/* svn_test_utils.c --- test utilities
+ *
+ * ====================================================================
+ *    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.
+ * ====================================================================
+ */
+
+#include "svn_test_utils.h"
+#include "svn_test_fs.h"
+#include "svn_error.h"
+#include "svn_client.h"
+
+svn_error_t *
+svn_test__create_repos_and_wc(const char **repos_url,
+                              const char **wc_abspath,
+                              const char *test_name,
+                              const svn_test_opts_t *opts,
+                              apr_pool_t *pool)
+{
+  const char *repos_path = svn_relpath_join(REPOSITORIES_WORK_DIR, test_name,
+                                            pool);
+  const char *wc_path = svn_relpath_join(WCS_WORK_DIR, test_name, pool);
+
+  /* Remove the repo and WC dirs if they already exist, to ensure the test
+   * will run even if a previous failed attempt was not cleaned up. */
+  SVN_ERR(svn_io_remove_dir2(repos_path, TRUE, NULL, NULL, pool));
+  SVN_ERR(svn_io_remove_dir2(wc_path, TRUE, NULL, NULL, pool));
+
+  /* Create the parent dirs of the repo and WC if necessary. */
+  SVN_ERR(svn_io_make_dir_recursively(REPOSITORIES_WORK_DIR, pool));
+  SVN_ERR(svn_io_make_dir_recursively(WCS_WORK_DIR, pool));
+
+  /* Create a repos and set *REPOS_URL to its path. */
+  {
+    svn_repos_t *repos;
+
+    SVN_ERR(svn_test__create_repos(&repos, repos_path, opts, pool));
+    SVN_ERR(svn_uri_get_file_url_from_dirent(repos_url, repos_path, pool));
+  }
+
+  /* Create a WC */
+  {
+    svn_client_ctx_t *ctx;
+    svn_opt_revision_t head_rev = { svn_opt_revision_head, {0} };
+
+    SVN_ERR(svn_client_create_context(&ctx, pool));
+    /* SVN_ERR(svn_config_get_config(&ctx->config, config_dir, pool)); */
+    SVN_ERR(svn_dirent_get_absolute(wc_abspath, wc_path, pool));
+    SVN_ERR(svn_client_checkout3(NULL, *repos_url, *wc_abspath,
+                                 &head_rev, &head_rev, svn_depth_infinity,
+                                 FALSE /* ignore_externals */,
+                                 FALSE /* allow_unver_obstructions */,
+                                 ctx, pool));
+  }
+
+  return SVN_NO_ERROR;
+}
+

Added: subversion/trunk/subversion/tests/svn_test_utils.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_utils.h?rev=1024311&view=auto
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_utils.h (added)
+++ subversion/trunk/subversion/tests/svn_test_utils.h Tue Oct 19 16:22:08 2010
@@ -0,0 +1,62 @@
+/* svn_test_utils.h --- test utilities
+ *
+ * ====================================================================
+ *    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.
+ * ====================================================================
+ */
+
+#ifndef SVN_TEST_UTILS_H
+#define SVN_TEST_UTILS_H
+
+#include <apr_pools.h>
+#include "svn_error.h"
+#include "svn_test.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/*-------------------------------------------------------------------*/
+
+/** Helper routines for creating repositories and WCs. **/
+
+
+#define REPOSITORIES_WORK_DIR "svn-test-work/repositories"
+#define WCS_WORK_DIR "svn-test-work/working-copies"
+
+/* Create an empty repository and WC for the test TEST_NAME.  Set *REPOS_URL
+ * to the URL of the new repository and *WC_ABSPATH to the root path of the
+ * new WC.
+ *
+ * Create the repository and WC in subdirectories called
+ * REPOSITORIES_WORK_DIR/TEST_NAME and WCS_WORK_DIR/TEST_NAME respectively,
+ * within the current working directory. */
+svn_error_t *
+svn_test__create_repos_and_wc(const char **repos_url,
+                              const char **wc_abspath,
+                              const char *test_name,
+                              const svn_test_opts_t *opts,
+                              apr_pool_t *pool);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif  /* SVN_TEST_UTILS_H */