[libpeas] Split common Makefile.am code to Makefile.tests



commit e33b3ef43a454437ad5fd42e6eb2355637040620
Author: Garrett Regier <alias301 gmail com>
Date:   Sun Jan 16 12:45:31 2011 -0800

    Split common Makefile.am code to Makefile.tests
    
    This also adds a hook so the libpeas-gtk tests are
    only run when $DISPLAY is set.

 tests/Makefile.am             |   27 +++++++++++++++++++++------
 tests/Makefile.tests          |   20 ++++++++++++++++++++
 tests/libpeas-gtk/Makefile.am |   25 +++----------------------
 tests/libpeas/Makefile.am     |   22 +---------------------
 4 files changed, 45 insertions(+), 49 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index eea6292..bbbf499 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,5 @@
+GTESTER_REPORT = gtester-report
+
 SUBDIRS = plugins libpeas
 
 if ENABLE_GTK
@@ -7,17 +9,23 @@ endif
 test test-gdb:
 	@for subdir in $(SUBDIRS) ; do \
 	   test "$$subdir" = "plugins" || \
-	   ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $(@) ) || exit $? ; \
+	   ( cd $$subdir && \
+	     if ! $(MAKE) $(AM_MAKEFLAGS) -n run-test-hook 2>/dev/null 1>&2 ; then \
+	       $(MAKE) $(AM_MAKEFLAGS) $(@) ; \
+	     elif $(MAKE) $(AM_MAKEFLAGS) run-test-hook 2>/dev/null 1>&2 ; then \
+	       $(MAKE) $(AM_MAKEFLAGS) $(@) ; \
+	     else \
+	       true ; \
+	     fi \
+	   ) || exit $? ; \
 	 done
 
-GTESTER_REPORT = gtester-report
-
 # test-report: run tests and generate report
 # perf-report: run tests with -m perf and generate report
 # full-report: run tests with -m perf -m slow and generate report
 test-report perf-report full-report:
 	@export GTESTER_LOGDIR=`mktemp -d "$(abs_srcdir)/.testlogs-XXXXXX"` ; \
-	 if test -d "$(top_srcdir)/.git"; then \
+	 if test -d "$(top_srcdir)/.git" ; then \
 	   export REVISION="`git describe`" ;  \
 	 else \
 	   export REVISION="$(VERSION)" ; \
@@ -40,8 +48,15 @@ test-report perf-report full-report:
 	   test "$$subdir" = "plugins" || { \
 	     export GTESTER_LOG=`mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ; \
 	     export GTESTER_ARGS="--verbose $$test_options -o $$GTESTER_LOG" ; \
-	     ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) generate-report ) ; \
-	     sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOG" >> $  xml ; \
+	     ( cd $$subdir && \
+	       if ! $(MAKE) $(AM_MAKEFLAGS) -n run-test-hook 2>/dev/null 1>&2 ; then \
+	         $(MAKE) $(AM_MAKEFLAGS) generate-report ; \
+	       elif $(MAKE) $(AM_MAKEFLAGS) run-test-hook 2>/dev/null 1>&2 ; then \
+	         $(MAKE) $(AM_MAKEFLAGS) generate-report ; \
+	       else \
+	         false ; \
+	       fi \
+	     ) && sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOG" >> $  xml ; \
 	   } \
 	 done ; \
 	 echo >> $  xml ; \
diff --git a/tests/Makefile.tests b/tests/Makefile.tests
new file mode 100644
index 0000000..a121a2e
--- /dev/null
+++ b/tests/Makefile.tests
@@ -0,0 +1,20 @@
+GTESTER = gtester
+
+TEST_PROGS =
+
+test: $(TEST_PROGS)
+	@test -z "$(TEST_PROGS)" || \
+	 $(GTESTER) --verbose $(TEST_PROGS)
+
+test-gdb: $(TEST_PROGS)
+	@test -z "$(TEST_PROGS)" || \
+	 for test_prog in $(TEST_PROGS) ; do \
+	   $(GTESTER) --verbose $$test_prog || { \
+	     libtool --mode=execute gdb --ex "run --verbose" $$test_prog ; \
+	     exit 1 ; \
+	   } \
+	 done
+
+generate-report: $(TEST_PROGS)
+	@test -z "$(TEST_PROGS)" || \
+	 $(GTESTER) $(GTESTER_ARGS) $(TEST_PROGS)
diff --git a/tests/libpeas-gtk/Makefile.am b/tests/libpeas-gtk/Makefile.am
index 27560e2..661137e 100644
--- a/tests/libpeas-gtk/Makefile.am
+++ b/tests/libpeas-gtk/Makefile.am
@@ -1,28 +1,9 @@
-GTESTER = gtester
-
-TEST_PROGS =
+include $(top_srcdir)/tests/Makefile.tests
 
 SUBDIRS = plugins testing
 
-test: $(TEST_PROGS)
-	@test -z "$(TEST_PROGS)" || \
-	 test -z "$(DISPLAY)" || \
-	 $(GTESTER) --verbose $(TEST_PROGS)
-
-test-gdb: $(TEST_PROGS)
-	@test -z "$(TEST_PROGS)" || \
-	 test -z "$(DISPLAY)" || \
-	 for test_prog in $(TEST_PROGS); do \
-	   $(GTESTER) --verbose $$test_prog || { \
-	     libtool --mode=execute gdb --ex "run --verbose" $$test_prog ; \
-	     exit 1 ; \
-	   } \
-	 done
-
-generate-report: $(TEST_PROGS)
-	@test -z "$(TEST_PROGS)" || \
-	 test -z "$(DISPLAY)" || \
-	 $(GTESTER) $(GTESTER_ARGS) $(TEST_PROGS)
+run-test-hook:
+	@test -n "$(DISPLAY)"
 
 INCLUDES = \
 	-I$(top_srcdir)			\
diff --git a/tests/libpeas/Makefile.am b/tests/libpeas/Makefile.am
index dfc566d..109e398 100644
--- a/tests/libpeas/Makefile.am
+++ b/tests/libpeas/Makefile.am
@@ -1,27 +1,7 @@
-GTESTER = gtester
-
-TEST_PROGS =
+include $(top_srcdir)/tests/Makefile.tests
 
 SUBDIRS = introspection plugins testing
 
-test: $(TEST_PROGS)
-	@test -z "$(TEST_PROGS)" || \
-	 $(GTESTER) --verbose $(TEST_PROGS)
-
-test-gdb: $(TEST_PROGS)
-	@test -z "$(TEST_PROGS)" || \
-	 for test_prog in $(TEST_PROGS); do \
-	   $(GTESTER) --verbose $$test_prog || { \
-	     libtool --mode=execute gdb --ex "run --verbose" $$test_prog ; \
-	     exit 1 ; \
-	   } \
-	 done
-
-generate-report: $(TEST_PROGS)
-	@test -z "$(TEST_PROGS)" || \
-	 $(GTESTER) $(GTESTER_ARGS) $(TEST_PROGS)
-
-
 INCLUDES = \
 	-I$(top_srcdir)		\
 	-I$(srcdir)		\



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]