Here is the patch for the branch I added earlier on:

https://svn.apache.org/repos/asf/subversion/branches/gtest_addition/

Please let me know if there is anything I can do to improve upon this.

Thanks :)

Gabriela
Index: INSTALL
===================================================================
--- INSTALL	(revision 1452117)
+++ INSTALL	(working copy)
@@ -153,6 +153,12 @@ I.    INTRODUCTION
          configured via auto-props or the mime-types-file option
          take precedence.
 
+      * Googletest aka Gtest (OPTIONAL)
+  
+         This optional package is used by the tests for Subversions'
+         C++ bindings.
+
+
   C. Dependencies in Detail
 
       Subversion depends on a number of third party tools and libraries.
@@ -566,6 +572,13 @@ I.    INTRODUCTION
 
         --with-libmagic
 
+      22. Googletest (OPTIONAL)
+
+      Googletest can be installed and built in-tree by invoking 
+
+      $ ./get-dep.sh gtest
+      $ ./configure --with-gtest 
+
   D. Documentation
 
       The primary documentation for Subversion is the free book
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 1452117)
+++ Makefile.in	(working copy)
@@ -134,6 +134,8 @@ APACHE_INCLUDES = @APACHE_INCLUDES@
 APACHE_LIBEXECDIR = $(DESTDIR)@APACHE_LIBEXECDIR@
 APACHE_LDFLAGS = @APACHE_LDFLAGS@
 
+GTEST_INCLUDES = -Ilibgtest -Ilibgtest/include/ -Ilibgtest/include/gtest/internal -Ilibgtest/include/gtest
+
 SWIG = @SWIG@
 SWIG_PY_INCLUDES = @SWIG_PY_INCLUDES@ -I$(SWIG_SRC_DIR)/python/libsvn_swig_py
 SWIG_PY_COMPILE = @SWIG_PY_COMPILE@
@@ -182,9 +184,10 @@ SWIG_LDFLAGS = @SWIG_LDFLAGS@ $(EXTRA_SWIG_LDFLAGS
 
 COMPILE = $(CC) $(CMODEFLAGS) $(CPPFLAGS) $(CMAINTAINERFLAGS) $(CFLAGS) $(INCLUDES)
 COMPILE_CXX = $(CXX) $(CXXMODEFLAGS) $(CPPFLAGS) $(CXXMAINTAINERFLAGS) $(CXXFLAGS) $(INCLUDES)
+COMPILE_GTEST_CXX = $(COMPILE_CXX) $(GTEST_INCLUDES) -o $@ -c 
 LT_COMPILE = $(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE) $(LT_CFLAGS)
 LT_COMPILE_CXX = $(LIBTOOL) $(LTCXXFLAGS) --mode=compile $(COMPILE_CXX) $(LT_CFLAGS)
-
+LT_COMPILE_GTEST_CXX = $(LIBTOOL) $(LTCXXFLAGS) --mode=compile $(COMPILE_CXX) $(LT_FLAGS) $(GTEST_INCLUDES) -o $@ -c 
 # Execute a command that loads libraries from the build dir
 LT_EXECUTE = $(LIBTOOL) $(LTFLAGS) --mode=execute `for f in $(abs_builddir)/subversion/*/*.la; do echo -dlopen $$f; done`
 
@@ -208,6 +211,8 @@ LINK = $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) $(L
 LINK_LIB = $(LINK) $(LT_SO_VERSION)
 LINK_CXX = $(LIBTOOL) $(LTCXXFLAGS) --mode=link $(CXX) $(LT_LDFLAGS) $(CXXFLAGS) $(LDFLAGS) -rpath $(libdir)
 LINK_CXX_LIB = $(LINK_CXX) $(LT_SO_VERSION)
+## LINK_GTEST_CXX = ar -rv libgtest.a src/gtest-all.lo
+LINK_GTEST_CXX = $(LIBTOOL) $(LTCXXFLAGS) --mode=link $(CXX) $(LT_LDFLAGS) $(CXXFLAGS) $(LDFLAGS) -rpath $(libdir)
 
 # special link rule for mod_dav_svn
 LINK_APACHE_MOD = $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) $(LT_LDFLAGS) $(CFLAGS) $(LDFLAGS) -rpath $(APACHE_LIBEXECDIR) -avoid-version -module $(APACHE_LDFLAGS)
Index: build/generator/gen_base.py
===================================================================
--- build/generator/gen_base.py	(revision 1452117)
+++ build/generator/gen_base.py	(working copy)
@@ -431,6 +431,8 @@ class TargetLinked(Target):
         if glob.glob(src):
           if src[-2:] == '.c':
             objname = src[:-2] + self.objext
+          elif src[-3:] == '.cc':
+            objname = src[:-3] + self.objext
           elif src[-4:] == '.cpp':
             objname = src[:-4] + self.objext
           else:
Index: build.conf
===================================================================
--- build.conf	(revision 1452117)
+++ build.conf	(working copy)
@@ -409,7 +409,6 @@ type = sql-header
 path = subversion/libsvn_subr
 sources = internal_statements.sql
 
-
 # ----------------------------------------------------------------------------
 #
 # TARGETS FOR I18N SUPPORT
@@ -657,8 +656,26 @@ install = tests
 compile-cmd = $(COMPILE_CXXHL_CXX)
 link-cmd = $(LINK_CXX)
 
+
 # ----------------------------------------------------------------------------
 #
+# Gtest targets
+#
+
+# renamed from gtest to libgtest because libtool couldn't output 
+# a library that didn't have the prefix 'lib'
+[libgtest] 
+description = Gtest Test Suite
+type = lib
+path = libgtest
+headers = include/gtest
+sources = src/gtest-all.cc
+install = libgtest-install
+compile-cmd = $(LT_COMPILE_GTEST_CXX)
+link-cmd = $(LINK_CXX)
+
+# ----------------------------------------------------------------------------
+#
 # TESTING TARGETS
 #
 
Index: configure.ac
===================================================================
--- configure.ac	(revision 1452117)
+++ configure.ac	(working copy)
@@ -625,7 +625,23 @@ fi
 AC_SUBST(SVN_GNOME_KEYRING_INCLUDES)
 AC_SUBST(SVN_GNOME_KEYRING_LIBS)
 
+dnl gtest -----------------
+AC_ARG_ENABLE([gtest],
+  [AS_HELP_STRING([--enable-gtest],
+                  [Enable tests using the Google C++ Testing Framework.
+                  ])],
+  enable_gtest=yes,
+  [])
 
+if test "$enable_gtest" = "yes"; then
+  AC_MSG_RESULT([yes])
+  AC_DEFINE([HAVE_GTEST], [1], 
+            [Is gtest enabled?])
+else
+  AC_MSG_RESULT([no])
+fi
+AC_SUBST([HAVE_GTEST])
+
 dnl Ev2 experimental features ----------------------
 dnl Note: The Ev2 implementations will be built unconditionally, but by
 dnl providing this flag, users can choose to use the currently-shimmed Ev2
@@ -831,6 +847,12 @@ if test "$svn_lib_kwallet" = "yes"; then
   INSTALL_STATIC_RULES="$INSTALL_STATIC_RULES install-kwallet-lib"
 fi
 
+if test "$enable_gtest" = "yes"; then
+  BUILD_RULES="$BUILD_RULES libgtest"
+  INSTALL_RULES="`echo $INSTALL_RULES | $SED 's/install-lib/install-lib install-gtest/'`"
+  INSTALL_STATIC_RULES="$INSTALL_STATIC_RULES install-gtest"
+fi
+
 if test "$found_gnome_keyring" = "yes"; then
   BUILD_RULES="$BUILD_RULES gnome-keyring-lib"
   INSTALL_RULES="`echo $INSTALL_RULES | $SED 's/install-lib/install-lib install-gnome-keyring-lib/'`"
Index: doc/programmer/gtest-guide.txt
===================================================================
--- doc/programmer/gtest-guide.txt	(revision 0)
+++ doc/programmer/gtest-guide.txt	(working copy)
@@ -0,0 +1,53 @@
+Googletest Suite for Subversion
+---------------------------------
+
+0. Introduction
+1. Setting up 
+2. Literature 
+3. Example test case
+
+0. Introduction
+----------------
+Googletest is an external package that is downloaded and
+compiled on request, as part of a regular compilations.
+
+From the Googletest Project page:
+"Google's framework for writing C++ tests on a variety of platforms
+(Linux, Mac OS X, Windows, Cygwin, Windows CE, and Symbian). Based on
+the xUnit architecture. Supports automatic test discovery, a rich set
+of assertions, user-defined assertions, death tests, fatal and
+non-fatal failures, value- and type-parameterized tests, various
+options for running the tests, and XML test report generation."
+
+1. Setting up 
+--------------
+
+To configure Subversion to use Googletest, type
+
+./get-dep.sh gtest
+./autogen.sh
+./configure --enable-gtest <your other options here>
+
+this sets up gtest in the /trunk/libgtest directory.
+
+Note that currently autogen.sh issues header warnings and the
+configure script prints spurious errormessages of the form ""the
+option --enable-gtest is not recognised."
+
+Please ignore them, this does not interfere with the functionality of
+Googletest at all, and everything is being installed correctly.
+
+
+2. Literature 
+-------------
+
+Googletest homepage: 
+http://code.google.com/p/googletest/
+
+Short tutorial and cheatsheet: 
+http://www.ibm.com/developerworks/aix/library/au-googletestingframework.html
+
+3. Simple example test case
+----------------------------
+
+Please see subversion/bindings/cxxhl/gtests/* for a sample set up.
Index: gen-make.py
===================================================================
--- gen-make.py	(revision 1452117)
+++ gen-make.py	(working copy)
@@ -213,6 +213,8 @@ def _usage_exit(err=None):
   print("")
   print("  --with-apr_memcache=DIR")
   print("           the apr_memcache sources are in DIR")
+  print("  --with-gtest")
+  print("           enable Gtest")
   sys.exit(1)
 
 
@@ -261,7 +263,7 @@ if __name__ == '__main__':
                             'disable-shared',
                             'installed-libs=',
                             'vsnet-version=',
-
+                            'with-gtest',
                             # Keep distributions that help by adding a path
                             # working. On unix this would be filtered by
                             # configure, but on Windows gen-make.py is used
Index: get-deps.sh
===================================================================
--- get-deps.sh	(revision 1452117)
+++ get-deps.sh	(working copy)
@@ -116,7 +116,13 @@ get_gtest() {
 
     unzip -q $TEMPDIR/$GTEST.zip
 
-    mv $GTEST gtest
+    mv $GTEST libgtest
+    echo "Gtest has been installed, please note:"
+    echo "autogen.sh will issue spurious header warnings."
+    echo "./configure --enable-gtest will issue repeated spurious warnings that"
+    echo "the option --enable-gtest is not recognsed."
+    echo "The documentation for the usage of Gtest in Subversion is located in "
+    echo "doc/programmer/gtest-guide.txt"
 }
 
 # main()
Index: subversion/bindings/cxxhl/gtests/GtestAcceptance.cpp
===================================================================
--- subversion/bindings/cxxhl/gtests/GtestAcceptance.cpp	(revision 0)
+++ subversion/bindings/cxxhl/gtests/GtestAcceptance.cpp	(working copy)
@@ -0,0 +1,33 @@
+/*
+ * ====================================================================
+ *    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 <iostream>
+#include <gtest/gtest.h>
+
+TEST(GtestAcceptance, Pass) {
+  EXPECT_EQ(0, 0);
+}
+
+// Note that it appears that Googletest doesn't support an XFAIL
+// decorator, which would fit nicely for this second test.
+TEST(GtestAcceptance, Fail) {
+  EXPECT_EQ(0, 1);
+}
Index: subversion/bindings/cxxhl/gtests/Makefile
===================================================================
--- subversion/bindings/cxxhl/gtests/Makefile	(revision 0)
+++ subversion/bindings/cxxhl/gtests/Makefile	(working copy)
@@ -0,0 +1,34 @@
+#
+# subversion/bindings/cxxhl/gtests/Makefile:  test Makefile for Subversion
+# cxxhl bindings integration with Googletest
+#
+# ====================================================================
+#    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.
+# ====================================================================
+#
+## Proof of concept file, to show that GtestAcceptance.cpp is a valid 
+## Googletest test file.
+##
+## Not likely to ever be part of a final commit to TRUNK
+
+CPPFLAGS := -Wall -O2 -I../../../../libgtest/include -I../../../../libgtest 
+
+all: GtestAcceptance.cpp
+	g++ ${CPPFLAGS} GtestAcceptance.cpp \
+	../../../../libgtest/src/gtest_main.cc \
+	../../../../libgtest/.libs/libgtest-1.a -lpthread -o mytest
Add the optional dependency Googletest (aka Gtest) to be compiled by
the build system.
 
* trunk/get-deps.sh (gtest): change gtest dir to libgtest and
  add user information.

* trunk/build/generator/gen_base.py (TargetLinked.add_dependencies): 
  Add .cc extension.

* trunk/gen-make.py (_usage_exit): add gtest flag help info. 

* trunk/Makefile.in(): various entries for gtest flags
 
* trunk/build.conf (install): Add Gtest target.

* trunk/configure.ac (): Add AC_ARG_ENABLE command hook and test
  (build rules): add gtest build rules

* INSTALL (Dependency Overview): add entry for Gtest
  (Dependencies in Detail): add entry for Gtest

* doc/programmer/gtest-guide.txt(): Documentation for Subversion's
  installation of Gtest.

* subversion/bindings/cxxhl/gtests/GtestAcceptance.cpp(): Sample test
  for gtest.

* subversion/bindings/cxxhl/gtests/Makefile(): Makefile for sample
  test for gtest.
  

  

Reply via email to