Browse Source

demote missing gtest to a buildtime warning

We just need it for unit tests and our debian/rules file actually skips
calling them if nocheck is given… but this fails anyhow as we declared a
hard-dependency on it. Demoting the error to a warning in configuration
and adding a test in the 'make test' path with a friendly message allows
nocheck to be useful again.

(Running unit tests is fully encouraged of course, but bootstrappers and
 co do not need to be burdened with this stuff)
David Kalnischkies 11 years ago
parent
commit
42fab5fbc8
2 changed files with 10 additions and 1 deletions
  1. 1 1
      configure.ac
  2. 9 0
      test/libapt/makefile

+ 1 - 1
configure.ac

@@ -91,7 +91,7 @@ AC_CHECK_LIB(curl, curl_easy_init,
 
 AC_LANG_PUSH([C++])
 AC_CHECK_HEADER(gtest/gtest.h,,
-     AC_MSG_ERROR([failed: I need gtest to build tests]),
+     AC_MSG_WARN([failed: I need gtest (packaged as libgtest-dev) for unit testing]),
 )
 AC_LANG_POP([C++])
 

+ 9 - 0
test/libapt/makefile

@@ -8,6 +8,7 @@ APT_DOMAIN=none
 include ../../buildlib/defaults.mak
 
 .PHONY: test
+ifeq (file-okay,$(shell $(CC) -M gtest_runner.cc >/dev/null 2>&1 && echo 'file-okay'))
 test: $(BIN)/gtest$(BASENAME)
 	MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=$(LIB) $(BIN)/gtest$(BASENAME)
 
@@ -71,3 +72,11 @@ $(LIB)/gtest.a: $(OBJ)/gtest-all.o
 	echo Building static library $@
 	-rm -f $@
 	$(AR) $(ARFLAGS) $@ $^
+
+else
+test:
+	@echo "APT uses Googles C++ testing framework for its unit tests"
+	@echo "On Debian systems this is available in the 'libgtest-dev' package."
+	@echo "Please install it before attempting to run the unit tests."
+	exit 100
+endif