[libdmapsharing/LIBDMAPSHARING_3_0] Backport from 4.0 series: adjust how building tests works



commit 332c8f0b88ee583c5bbb77778b7a597fe0f85854
Author: W. Michael Petullo <mike flyn org>
Date:   Tue Jun 30 07:35:13 2020 -0500

    Backport from 4.0 series: adjust how building tests works
    
    Previously, the presence of the check library led to libdmapsharing
    building its unit tests and supporting facilities, despite the separate
    configure flag --disable-tests. This led to confusion as to whether some
    test facilities should be present in the compiled libdmapsharing. Now,
    --disable-tests disables all tests, whether unit tests or sample programs,
    and it ensure not test facilities exist in libdmapsharing.

 config.h.in                |  6 +++---
 configure.ac               | 26 ++++++++++++--------------
 libdmapsharing/Makefile.am |  2 +-
 tests/Makefile.am          |  4 ++--
 4 files changed, 18 insertions(+), 20 deletions(-)
---
diff --git a/config.h.in b/config.h.in
index 5413c06..8a2924d 100644
--- a/config.h.in
+++ b/config.h.in
@@ -93,6 +93,9 @@
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
+/* Defined when tests are to be built */
+#undef TESTS_ENABLED
+
 /* Version number of package */
 #undef VERSION
 
@@ -104,6 +107,3 @@
 
 /* Define if mDNS/DNS-SD implementation uses Howl */
 #undef WITH_HOWL
-
-/* Defined when tests are to be built */
-#undef WITH_TESTS
diff --git a/configure.ac b/configure.ac
index cdf8c1e..5cde774 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,10 +69,19 @@ AC_CONFIG_MACRO_DIR(m4)
 dnl Test if --disable-tests given
 AC_ARG_ENABLE(tests, [AC_HELP_STRING([--disable-tests],[do not build tests])], tests=$enableval, tests=yes)
 if test x$tests = xyes; then
-       AC_DEFINE(WITH_TESTS,1,[Defined when tests are to be built])
-       AM_CONDITIONAL(WITH_TESTS, true)
+       PKG_CHECK_MODULES([CHECK], [check >= 0.9.4],have_check=yes,have_check=no)
+       AM_CONDITIONAL(HAVE_CHECK, test x"$have_check" = "xyes")
+       if test "x$have_check" = "xyes"; then
+               AC_DEFINE(HAVE_CHECK, 1, [Define if check support is enabled])
+       else
+               AC_MSG_ERROR([Must have check library present when tests enabled])
+       fi
+
+       AC_DEFINE(TESTS_ENABLED,1,[Defined when tests are to be built])
+       AM_CONDITIONAL(TESTS_ENABLED, true)
 else
-       AM_CONDITIONAL(WITH_TESTS, false)
+       AM_CONDITIONAL(TESTS_ENABLED, false)
+       AM_CONDITIONAL(HAVE_CHECK, false)
 fi
                   
 dnl Now check required packages
@@ -363,17 +372,6 @@ if test -n "$BUILD_DPAPVIEW" ; then
        AC_WARN([will not build dpapview])
 fi
 
-AC_ARG_ENABLE(check, [  --disable-check         do not build check support], enable_check=$enableval, 
enable_check=yes)
-if test x$enable_check = xyes; then
-       PKG_CHECK_MODULES([CHECK], [check >= 0.9.4],have_check=yes,have_check=no)
-       AM_CONDITIONAL(HAVE_CHECK, test x"$have_check" = "xyes")
-       if test "x$have_check" = "xyes"; then
-               AC_DEFINE(HAVE_CHECK, 1, [Define if check support is enabled])
-       fi
-else
-       AM_CONDITIONAL(HAVE_CHECK, false)
-fi
-
 AC_CHECK_LIB(z, uncompress)
 
 dnl common/m4/dmap-arch.m4
diff --git a/libdmapsharing/Makefile.am b/libdmapsharing/Makefile.am
index 5258da6..9519f07 100644
--- a/libdmapsharing/Makefile.am
+++ b/libdmapsharing/Makefile.am
@@ -24,7 +24,7 @@ libdmapsharing_3_0_la_SOURCES = \
        dpap-record.c \
        dpap-share.c
 
-if HAVE_CHECK
+if TESTS_ENABLED
 libdmapsharing_3_0_la_SOURCES += \
        test-daap-record.c \
        test-daap-record-factory.c \
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bfc5f6d..08b0b0e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,4 @@
-if WITH_TESTS
+if TESTS_ENABLED
 noinst_PROGRAMS = test-dmap-client test-dmap-server
 
 if HAVE_GEE
@@ -45,7 +45,7 @@ test_dmap_server_LDADD = \
        $(MDNS_LIBS)
 
 if HAVE_VALAC
-if WITH_TESTS
+if TESTS_ENABLED
 BUILT_SOURCES = dacplisten.stamp dpapview.stamp dmapcopy.stamp dmapserve.stamp
 endif
 


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