Skip to content
Snippets Groups Projects
Commit db0618d9 authored by Jonathan Schöbel's avatar Jonathan Schöbel
Browse files

configure: added automatic depency checking for check

Until now, the configure script just checked for check to be installed,
which is needed to compile the tests.
Now, configure provides a conditional (MISSING_CHECK) depending on its
presence for use by automake. If check is missing, the tests aren't
compiled. Instead a special script is executed to inform the user of the
problem and stops the testsuite. Note, that it was not possible to
directly stop the generation of the testsuite by injecting a rule to a
Makefile without relying on implementation details of automake.
See:
https://stackoverflow.com/questions/76376806/automake-how-to-portably-throw-an-error-and-aborting-the-target/76382437
To allow the script to issue messages to stderr, AM_TESTS_FD_REDIRECT is
used, because the parallel test harness redirects output of its tests to
logfiles. This isn't used for the serial test harness, because there is
no redirection to logfiles, but there AM_TESTS_FD_REDIRECT is also not
taken into account.
See:
https://www.gnu.org/software/automake/manual/html_node/Testsuite-Environment-Overrides.html
Additionaly configure also provides an argument to enforce both
behaviours. When specifying --enable-tests=no the tests are not compiled
regardless of the presence of check. If --enable-tests=yes, it is
assumed, that tests are really needed and the mandantory check for check
is performed thus providing the former behaviour. If not specified
--enable-tests default to auto, which results in the same behaviour as
--enable-tests=yes, if check is present, and like --enable-tests=no
otherwise.
parent edba1aa3
No related branches found
No related tags found
No related merge requests found
......@@ -10,12 +10,44 @@ AC_CONFIG_MACRO_DIR([build-macro])
AM_INIT_AUTOMAKE([foreign -Wall -Werror subdir-objects])
AC_ARG_PROGRAM
# Checks for programs.
AC_PROG_CC
AM_PROG_AR
AC_PROG_LIBTOOL
PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
PKG_PROG_PKG_CONFIG()
# Optional test suite
AC_ARG_ENABLE([tests],
[AS_HELP_STRING([--enable-tests@<:@=auto|yes|no@:>@],
[support building tests @<:@default=auto@:>@
This needs check to be installed.],26,65)],
[],
[enable_tests=auto])
case ${enable_tests} in
yes)
PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
;;
no)
;;
auto)
PKG_CHECK_MODULES([CHECK], [check >= 0.9.4],
[enable_tests=yes],
[
enable_tests=no
AC_MSG_WARN([tests are disabled, due to missing check])
])
;;
*)
AC_MSG_ERROR([invalid --enable-tests argument])
;;
esac
AM_CONDITIONAL([MISSING_CHECK], [test x${enable_tests} = xno])
# Checks for libraries.
LT_INIT()
......@@ -35,9 +67,10 @@ AC_CHECK_HEADER([string.h])
# Checks for library functions.
# Makefiles
AC_CONFIG_FILES([Makefile
src/Makefile
src/lib/Makefile
tests/Makefile])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([src/lib/Makefile])
AC_CONFIG_FILES([tests/Makefile])
AC_CONFIG_FILES([tests/no_test.sh], [chmod +x tests/no_test.sh])
AC_OUTPUT
......@@ -28,10 +28,10 @@ long_line_behaviour=1
long_line_column=72
[files]
current_page=0
current_page=31
FILE_NAME_0=139;None;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2FREADME;0;8
FILE_NAME_1=134;None;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2F.gitignore;0;8
FILE_NAME_2=923;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fconfigure.ac;0;8
FILE_NAME_2=1751;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fconfigure.ac;0;8
FILE_NAME_3=73;Make;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2FMakefile.am;0;8
FILE_NAME_4=1143;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Fmain.c;0;8
FILE_NAME_5=747;Make;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2FMakefile.am;0;8
......@@ -59,14 +59,15 @@ FILE_NAME_26=4735;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fp
FILE_NAME_27=901;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Flog.h;0;4
FILE_NAME_28=907;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fmacro.h;0;8
FILE_NAME_29=1078;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fsefht.h;0;8
FILE_NAME_30=1044;Make;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2FMakefile.am;0;8
FILE_NAME_31=1085;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_cms.c;0;8
FILE_NAME_32=3283;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_data.c;0;8
FILE_NAME_33=63675;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_node_fragment.c;0;8
FILE_NAME_34=15195;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_attr.c;0;8
FILE_NAME_35=11068;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_text.c;0;8
FILE_NAME_36=5744;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_validator.c;0;8
FILE_NAME_37=165;None;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftodo.txt;0;8
FILE_NAME_30=555;Make;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2FMakefile.am;0;8
FILE_NAME_31=218;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Fno_test.sh.in;0;8
FILE_NAME_32=1085;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_cms.c;0;8
FILE_NAME_33=3283;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_data.c;0;8
FILE_NAME_34=63675;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_node_fragment.c;0;8
FILE_NAME_35=15195;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_attr.c;0;8
FILE_NAME_36=11068;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_text.c;0;8
FILE_NAME_37=5744;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftests%2Ftest_validator.c;0;8
FILE_NAME_38=165;None;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Ftodo.txt;0;8
[VTE]
last_dir=/home/jonathan/Documents/projects/prgm/internet/web/SeFHT/tests
......
......@@ -2,14 +2,25 @@
AM_CFLAGS = -Wall -Wextra -Wno-nonnull $(CHECK_CFLAGS)
TESTS =
TESTS += sefht_attr_test
TESTS += sefht_cms_test
TESTS += sefht_data_test
TESTS += sefht_node_fragment_test
TESTS += sefht_text_test
check_PROGRAMS = $(TESTS)
# if check is missing, run script to inform the user of this
if MISSING_CHECK
check_SCRIPTS = no_test.sh
# allow the script to echo to stderr
AM_TESTS_FD_REDIRECT = 9>&2
endif
if !MISSING_CHECK
check_PROGRAMS =
check_PROGRAMS += sefht_attr_test
check_PROGRAMS += sefht_cms_test
check_PROGRAMS += sefht_data_test
check_PROGRAMS += sefht_node_fragment_test
check_PROGRAMS += sefht_text_test
endif
TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
AM_CPPFLAGS =
AM_CPPFLAGS += -DSEFHT_COMPILATION
......
#!/bin/bash
# Inform the user that tests are disabled and how to change that.
echo "No tests created due to missing check or user preference." >&2;
echo "No tests created due to missing check or user preference." >&9;
echo "To enable tests, run configure with --enable-tests=yes" >&2;
echo "To enable tests, run configure with --enable-tests=yes" >&9;
exit 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment