From 0a572071e9c08cfaa3e5d4f1beec9241d03d36a0 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 20 Mar 2016 11:27:05 +0000 Subject: [PATCH] Moved the unit testing compilation into a separate Makefile --- source/Makefile.in | 9 +++++---- source/configure | 5 +++-- source/configure.ac | 2 +- source/tests/Makefile.in | 37 +++++++++++++++++++++++++++++++++++++ source/tests/test.commands | 4 ++-- 5 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 source/tests/Makefile.in diff --git a/source/Makefile.in b/source/Makefile.in index 3b8e534..9ec3eb4 100644 --- a/source/Makefile.in +++ b/source/Makefile.in @@ -113,11 +113,12 @@ imexobjs: $(IMEXOBJS) clean: rm -f $(XAB_OUT) $(BMCO_HELP) tools/bitmapcode.o *.o \ vcard/*.o common/*.o carddav/*.o contacteditor/*.o search/*.o \ - widgets/*.o export/*.o import/*.o actmgr/*.o tests/$(XAB_OUT)_test \ - tests/Temp* contacteditor/cdo/*.o + widgets/*.o export/*.o import/*.o actmgr/*.o contacteditor/cdo/*.o \ + tests/Temp* tests/*.o tests/$(XAB_OUT)_test distclean: clean - rm -f Makefile config.status config.log bitmapsdone \ + rm -f Makefile tests/Makefile \ + config.status config.log bitmapsdone \ tools/bitmapcode.helper bitmaps.h find bitmaps -name "*.cpp" -type f -delete find bitmaps -name "*.h" -type f -delete @@ -136,4 +137,4 @@ uninstall: rm @BINDIR@/$(XAB_OUT) test: -@GTEST@ + @echo "To build and run the unit tests, run 'make' from the tests directory." diff --git a/source/configure b/source/configure index 4712964..7694d1b 100755 --- a/source/configure +++ b/source/configure @@ -4968,7 +4968,7 @@ if test -z "$GTEST_FOUND_TRUE"; then : echo "Google Test found on the system. Enabling Unit Tests." fi; -ac_config_files="$ac_config_files Makefile" +ac_config_files="$ac_config_files Makefile tests/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -5558,7 +5558,7 @@ esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. -config_files="$ac_config_files" +config_files="`echo $ac_config_files`" _ACEOF @@ -5700,6 +5700,7 @@ for ac_config_target in $ac_config_targets do case $ac_config_target in "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac diff --git a/source/configure.ac b/source/configure.ac index ed9cdaf..3b75ca2 100644 --- a/source/configure.ac +++ b/source/configure.ac @@ -192,5 +192,5 @@ AM_COND_IF([GTEST_FOUND], [AC_SUBST([GTEST], [`cat tests/test.commands`])], [AC_SUBST([GTEST], [" @echo \"Google Test was not found on the system. Unable to build tests.\""])]) AM_COND_IF([GTEST_FOUND], [echo "Google Test found on the system. Enabling Unit Tests."]); -AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([Makefile tests/Makefile]) AC_OUTPUT diff --git a/source/tests/Makefile.in b/source/tests/Makefile.in new file mode 100644 index 0000000..6796431 --- /dev/null +++ b/source/tests/Makefile.in @@ -0,0 +1,37 @@ +CPP=g++ +STRIP=strip +CPPFLAGS=`xml2-config --cflags` `wx-config --cxxflags` -I.. -std=c++11 -pthread @DBGOUT@ +CPPLIBS=`wx-config --libs` `curl-config --libs` -lsfml-audio -lxml2 -lgtest +MAKE=make +OBJDIR=. + +XABTEST_OUT=xestiaab_test + +TESTOBJS=$(addprefix $(OBJDIR)/, ../contacteditor/cdo/ContactDataObject-unittest.o \ + ../convert-unittest.o \ + ../common/textprocessing-unittest.o \ + ../vcard/vcard34conv-unittest.o \ + ../vcard/vcard34conv-v3conv-unittest.o \ + ../vcard/vcard34conv-v4conv-unittest.o \ + ../vcard/vcard-unittest.o \ + xestiaab_test.o) + +default: testobjs +@GTEST@ + +%.o: %.cpp + $(CPP) $(CPPFLAGS) -c -o $@ $< + +%-unittest.o: %.cpp + $(CPP) $(CPPFLAGS) -c -o $@ $< + +testobjs: $(TESTOBJS) + +clean: + rm -rf *.o ../*-unittest.o $(XABTEST_OUT) + rm -rf ../contacteditor/cdo/*-unittest.o + rm -rf ../common/*-unittest.o + rm -rf ../vcard/*-unittest.o + chmod 644 InvalidPermissions.vcf + +-include $(TESTOBJS:.o=.d) \ No newline at end of file diff --git a/source/tests/test.commands b/source/tests/test.commands index c962107..4f10c05 100644 --- a/source/tests/test.commands +++ b/source/tests/test.commands @@ -1,2 +1,2 @@ - $(CPP) $(CPPFLAGS) -pthread -I. contacteditor/cdo/ContactDataObject.cpp convert.cpp common/textprocessing.cpp vcard/vcard34conv.cpp vcard/vcard34conv-v3conv.cpp vcard/vcard34conv-v4conv.cpp vcard/vcard.cpp tests/xestiaab_test.cpp -o tests/$(XAB_OUT)_test $(CPPLIBS) -lgtest - chmod 000 tests/InvalidPermissions.vcf + $(CPP) $(CPPFLAGS) $(TESTOBJS) -o $(XABTEST_OUT) $(CPPLIBS) + chmod 000 InvalidPermissions.vcf \ No newline at end of file -- 2.39.2