From bcab7ca67f59adf6e5b2b3bdf682202947ce78f6 Mon Sep 17 00:00:00 2001 From: Mike Lundy Date: Sat, 4 Jul 2009 19:33:03 +0000 Subject: [PATCH] integrate gtest for a piecemeal conversion --- Makefile.am | 2 +- config/rules.mak | 18 +++--------------- config/tests.am | 15 +++++++++++++++ config/tests_old.am | 14 ++++++++++++++ src/vw/Camera/tests/Makefile.am | 1 + src/vw/Cartography/tests/Makefile.am | 1 + src/vw/Core/tests/Makefile.am | 1 + src/vw/FileIO/tests/Makefile.am | 1 + src/vw/GPU/tests/Makefile.am | 1 + src/vw/Geometry/tests/Makefile.am | 1 + src/vw/HDR/tests/Makefile.am | 1 + src/vw/Image/tests/Makefile.am | 1 + src/vw/InterestPoint/tests/Makefile.am | 1 + src/vw/Math/tests/Makefile.am | 1 + src/vw/Mosaic/tests/Makefile.am | 1 + src/vw/Stereo/tests/Makefile.am | 1 + src/vw/tests/Makefile.am | 1 + src/vw/tests/config_test.h | 18 ++++++++++++++++++ 18 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 config/tests.am create mode 100644 config/tests_old.am create mode 100644 src/vw/tests/config_test.h diff --git a/Makefile.am b/Makefile.am index 833b9bb72..9fff38145 100644 --- a/Makefile.am +++ b/Makefile.am @@ -101,7 +101,7 @@ all-headers: grep '^#.*vw/' | sed -e 's#.*src/\(vw/[^"]\+\)".*#\1#' | sort -u one-ctags-file: - ctags -R --languages=C,C++ --exclude='*thirdparty/*' --exclude='*tests/*' . --exclude='' thirdparty/cxxtest/cxxtest/TestSuite.h + ctags -R --languages=C,C++ --exclude='*thirdparty/*' --exclude='*tests/*' . --exclude='' thirdparty/cxxtest/cxxtest/TestSuite.h thirdparty/gtest .PHONY: coverage push-coverage instantiate-all instantiate-skipped all-headers one-ctags-file diff --git a/config/rules.mak b/config/rules.mak index d3f76642d..7cf991e78 100644 --- a/config/rules.mak +++ b/config/rules.mak @@ -5,24 +5,12 @@ # __END_LICENSE__ -######################################################################## -# tests (using cxxtest) -######################################################################## - -SUFFIXES = .cxx - -CXXTEST_DIR = $(top_srcdir)/thirdparty/cxxtest -CXXTEST_GEN = $(CXXTEST_DIR)/cxxtestgen.pl -CXXTEST_ARGS = --error-printer - -TEST_CPPFLAGS = -I$(CXXTEST_DIR) -DTEST_SRCDIR="\"$(top_srcdir)/$(subdir)\"" - -.h.cxx: - $(CXXTEST_GEN) $(CXXTEST_ARGS) -o $@ $< - newtest: @if test -z "$(NAME)"; then echo "run make NAME=TestName [MODULE=ModuleName] newtest"; else $(top_srcdir)/scripts/create-test.sh $(NAME) $(MODULE); fi .PHONY: newtest +SUFFIXES = .totallyfakeplaceholder include $(top_srcdir)/thirdparty/autotroll.mak + +# vim: filetype=automake: diff --git a/config/tests.am b/config/tests.am new file mode 100644 index 000000000..a3790cdc5 --- /dev/null +++ b/config/tests.am @@ -0,0 +1,15 @@ +GTEST_DIR = $(top_srcdir)/thirdparty/gtest + +libgtest_la_SOURCES = $(GTEST_DIR)/src/gtest-all.cc $(GTEST_DIR)/src/gtest_main.cc +# this empty assignment prevents AM_LDFLAGS from applying to libgtest +libgtest_la_LDFLAGS = + +check_LTLIBRARIES = libgtest.la + +AM_CPPFLAGS += -DTEST_SRCDIR="\"$(top_srcdir)/$(subdir)\"" -I$(GTEST_DIR) -I$(GTEST_DIR)/include -g +LDADD = libgtest.la + +# This makes sure we're using the c++ linker +LINK = $(CXXLINK) + +# vim: filetype=automake: diff --git a/config/tests_old.am b/config/tests_old.am new file mode 100644 index 000000000..e460ab87b --- /dev/null +++ b/config/tests_old.am @@ -0,0 +1,14 @@ +######################################################################## +# tests (using cxxtest) +######################################################################## + +SUFFIXES += .cxx + +CXXTEST_DIR = $(top_srcdir)/thirdparty/cxxtest +CXXTEST_GEN = $(CXXTEST_DIR)/cxxtestgen.pl +CXXTEST_ARGS = --error-printer + +TEST_CPPFLAGS = -I$(CXXTEST_DIR) -DTEST_SRCDIR="\"$(top_srcdir)/$(subdir)\"" + +.h.cxx: + $(CXXTEST_GEN) $(CXXTEST_ARGS) -o $@ $< diff --git a/src/vw/Camera/tests/Makefile.am b/src/vw/Camera/tests/Makefile.am index 05fdff7e3..2dc17dc57 100644 --- a/src/vw/Camera/tests/Makefile.am +++ b/src/vw/Camera/tests/Makefile.am @@ -40,3 +40,4 @@ EXTRA_DIST = $(TESTS:%=%.h) test.jpg CLEANFILES = $(TESTS:%=%.cxx) include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/Cartography/tests/Makefile.am b/src/vw/Cartography/tests/Makefile.am index beef03288..45a432333 100644 --- a/src/vw/Cartography/tests/Makefile.am +++ b/src/vw/Cartography/tests/Makefile.am @@ -35,3 +35,4 @@ EXTRA_DIST = $(TESTS:%=%.h) CLEANFILES = $(TESTS:%=%.cxx) include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/Core/tests/Makefile.am b/src/vw/Core/tests/Makefile.am index f49577929..102a4f157 100644 --- a/src/vw/Core/tests/Makefile.am +++ b/src/vw/Core/tests/Makefile.am @@ -39,3 +39,4 @@ EXTRA_DIST = $(TESTS:%=%.h) CLEANFILES = $(TESTS:%=%.cxx) log.txt include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/FileIO/tests/Makefile.am b/src/vw/FileIO/tests/Makefile.am index 38007ca39..4a0b2d973 100644 --- a/src/vw/FileIO/tests/Makefile.am +++ b/src/vw/FileIO/tests/Makefile.am @@ -35,3 +35,4 @@ EXTRA_DIST = $(TESTS:%=%.h) rgb2x2.png rgb2x2.tif rgb2x2.jpg png16.png CLEANFILES = $(TESTS:%=%.cxx) tmp.png tmp.tif rwtest.* test-png16.png include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/GPU/tests/Makefile.am b/src/vw/GPU/tests/Makefile.am index e79c0b0eb..cafa7f6aa 100644 --- a/src/vw/GPU/tests/Makefile.am +++ b/src/vw/GPU/tests/Makefile.am @@ -39,3 +39,4 @@ EXTRA_DIST = $(TESTS:%=%.h) test_images/lighthouse-1000x1000.png CLEANFILES = $(TESTS:%=%.cxx) include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/Geometry/tests/Makefile.am b/src/vw/Geometry/tests/Makefile.am index 101f4e135..4c60f627a 100644 --- a/src/vw/Geometry/tests/Makefile.am +++ b/src/vw/Geometry/tests/Makefile.am @@ -32,3 +32,4 @@ EXTRA_DIST = $(TESTS:%=%.h) CLEANFILES = $(TESTS:%=%.cxx) include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/HDR/tests/Makefile.am b/src/vw/HDR/tests/Makefile.am index 4b194dbc7..0ffa5817e 100644 --- a/src/vw/HDR/tests/Makefile.am +++ b/src/vw/HDR/tests/Makefile.am @@ -31,3 +31,4 @@ EXTRA_DIST = $(TESTS:%=%.h) CLEANFILES = $(TESTS:%=%.cxx) include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/Image/tests/Makefile.am b/src/vw/Image/tests/Makefile.am index 509440813..1296f5518 100644 --- a/src/vw/Image/tests/Makefile.am +++ b/src/vw/Image/tests/Makefile.am @@ -48,3 +48,4 @@ EXTRA_DIST = $(TESTS:%=%.h) CLEANFILES = $(TESTS:%=%.cxx) include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/InterestPoint/tests/Makefile.am b/src/vw/InterestPoint/tests/Makefile.am index 0190bd7ca..f9eb51da3 100644 --- a/src/vw/InterestPoint/tests/Makefile.am +++ b/src/vw/InterestPoint/tests/Makefile.am @@ -33,3 +33,4 @@ EXTRA_DIST = $(TESTS:%=%.h) sub.png noisy_gradient_60.png CLEANFILES = $(TESTS:%=%.cxx) include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/Math/tests/Makefile.am b/src/vw/Math/tests/Makefile.am index c9de6e5cd..ce10fec22 100644 --- a/src/vw/Math/tests/Makefile.am +++ b/src/vw/Math/tests/Makefile.am @@ -52,3 +52,4 @@ EXTRA_DIST = $(TESTS:%=%.h) CLEANFILES = $(TESTS:%=%.cxx) include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/Mosaic/tests/Makefile.am b/src/vw/Mosaic/tests/Makefile.am index 7ef704a4f..8d782d440 100644 --- a/src/vw/Mosaic/tests/Makefile.am +++ b/src/vw/Mosaic/tests/Makefile.am @@ -29,3 +29,4 @@ EXTRA_DIST = $(TESTS:%=%.h) CLEANFILES = $(TESTS:%=%.cxx) include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/Stereo/tests/Makefile.am b/src/vw/Stereo/tests/Makefile.am index 170ccdeb2..9ce190652 100644 --- a/src/vw/Stereo/tests/Makefile.am +++ b/src/vw/Stereo/tests/Makefile.am @@ -33,3 +33,4 @@ EXTRA_DIST = $(TESTS:%=%.h) CLEANFILES = $(TESTS:%=%.cxx) include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/tests/Makefile.am b/src/vw/tests/Makefile.am index 6d1460310..0b86f0221 100644 --- a/src/vw/tests/Makefile.am +++ b/src/vw/tests/Makefile.am @@ -32,3 +32,4 @@ EXTRA_DIST = $(TESTS:%=%.h) mural.png mural.jpg CLEANFILES = $(TESTS:%=%.cxx) cropped.mural.* mural.tif include $(top_srcdir)/config/rules.mak +include $(top_srcdir)/config/tests_old.am diff --git a/src/vw/tests/config_test.h b/src/vw/tests/config_test.h new file mode 100644 index 000000000..598223b8a --- /dev/null +++ b/src/vw/tests/config_test.h @@ -0,0 +1,18 @@ +#ifndef __VW_TESTS_CONFIG_TEST_H__ +#define __VW_TESTS_CONFIG_TEST_H__ + +#include + +#if defined(VW_ENABLE_EXCEPTIONS) && (VW_ENABLE_EXCEPTIONS==1) +#define HAS_EXCEPTIONS(x) x +#else +#define HAS_EXCEPTIONS(x) DISABLED_ ## x +#endif + +#if defined(VW_ENABLE_CONFIG_FILE) && (VW_ENABLE_CONFIG_FILE==1) +#define HAS_CONFIG_FILE(x) x +#else +#define HAS_CONFIG_FILE(x) DISABLED_ ## x +#endif + +#endif