Skip to content

Commit b7bd90f

Browse files
committed
Have "make check" run all of the libcheck-based unit tests,
pytest-based tests, and perl-framework-based tests if available. * test/pyhttpd/env.py (HttpdTestEnv.__init__): Use config.ini from $PYHTTPD_CONFIG if set. * configure.in: Check for pytest-3, add check-pytest to $CHECK_TARGETS if found. Add check-unittests to $CHECK_TARGETS if test/httpdunit is generated. Add check-test-framework to $CHECK_TARGETS if the Perl test framework is present. Stop generating WITH_TEST_SUITE. * Makefile.in (check): Depend on $CHECK_TARGETS. (check-tree, check/bin/apachectl, check/config.ini, check/modules/stamp): New targets to fill out the check/ install tree for use with pyhttpd. (check-pytest): New target to run pytest-based tests. (check-unittests): New target to run libcheck-based tests. (check-test-framework): Renamed from "check-yes", runs Perl framework tests. Github: closes #598 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1932079 13f79535-47bb-0310-9956-ffa450edef68
1 parent c4e47bc commit b7bd90f

File tree

4 files changed

+46
-14
lines changed

4 files changed

+46
-14
lines changed

Makefile.in

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,12 @@ check/bin/apxs:
449449
sed -e 's#$(prefix)#$(top_builddir)/check#g' support/apxs > $@
450450
chmod +x $@
451451

452+
# A version of apachectl with the PREFIX overridden to point inside the install root
453+
check/bin/apachectl:
454+
mkdir -p check
455+
sed -e 's#$(prefix)#$(top_builddir)/check#g' support/apachectl > $@
456+
chmod +x $@
457+
452458
# A version of config_vars.mk with PREFIX and SBINDIR and BINDIR overridden.
453459
check/build/config_vars.mk: build/config_vars.out
454460
mkdir -p check/build
@@ -468,16 +474,29 @@ $(TEST_SUITE_LOCATION)/Makefile: $(TEST_SUITE_LOCATION)/Makefile.PL $(INSTALL_HE
468474

469475
check-make: $(TEST_SUITE_LOCATION)/Makefile
470476

471-
check-no:
472-
@echo 'Re-run configure with the --with-test-suite option to enable in-tree tests.'
473-
@false
477+
check-tree: check-include check-dirs check-conf check/build/config_vars.mk \
478+
check-binaries
474479

475-
check-yes: check-include check-dirs check-conf check/build/config_vars.mk \
476-
check-binaries $(TEST_SUITE_LOCATION)/Makefile
480+
# Run the Apache::Test Perl framework
481+
check-test-framework: check-tree $(TEST_SUITE_LOCATION)/Makefile
477482
cd $(TEST_SUITE_LOCATION) && $(MAKE) && ./t/TEST $(TEST_CONFIG) $(TESTS)
478483

479-
# Run the Apache::Test suite if it has been configured with --with-test-suite.
480-
check: check-$(WITH_TEST_SUITE)
484+
# Generate config.ini suitable for running against the check/ install prefix
485+
check/config.ini: test/pyhttpd/config.ini
486+
sed -e 's#$(prefix)#$(top_builddir)/check#g' test/pyhttpd/config.ini > $@
487+
488+
check/modules/stamp: build/config_vars.mk
489+
mkdir -p check/modules
490+
rm -f check/modules/*.so
491+
find modules -name \*.so -exec ln -s $(top_builddir)/{} check/modules/ \;
492+
find server/mpm -name \*.so -exec ln -s $(top_builddir)/{} check/modules/ \;
493+
date > $@
494+
495+
check-pytest: check-tree check/bin/apachectl check/config.ini check/modules/stamp
496+
PYHTTPD_CONFIG=$(top_builddir)/check/config.ini $(PYTEST3) $(PYTEST_DIRS)
497+
498+
# Runs all configured/available test targets.
499+
check: $(CHECK_TARGETS)
481500

482501
#
483502
# Unit Test Suite
@@ -513,3 +532,6 @@ httpdunit_OBJECTS := test/httpdunit.lo $(testcase_OBJECTS)
513532
$(httpdunit_OBJECTS): override LTCFLAGS += $(UNITTEST_CFLAGS)
514533
test/httpdunit: $(httpdunit_OBJECTS) $(PROGRAM_DEPENDENCIES) $(PROGRAM_OBJECTS)
515534
$(LINK) $(httpdunit_OBJECTS) $(PROGRAM_OBJECTS) $(UNITTEST_LIBS) $(PROGRAM_LDADD)
535+
536+
check-unittests: test/httpdunit
537+
test/httpdunit

build/config_vars.sh.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,6 @@ exec sed "
8888
/^EXPORTS_DOT_C/d
8989
/^LIBMAIN_LIB/d
9090
/TEST_SUITE/d
91+
/^PYTEST3/d
92+
/^CHECK_TARGETS/d
9193
"

configure.in

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -791,10 +791,11 @@ AC_ARG_WITH(valgrind,
791791
dnl Enable the unit test executable if Check is installed.
792792
dnl TODO: at the moment, only pkg-config discovery is supported.
793793
AC_MSG_CHECKING([for Check to enable unit tests])
794-
if test "x$PKGCONFIG" != "x" -a "$ap_reduced_exports" = "no" && `$PKGCONFIG --atleast-version='0.9.12' check`; then
794+
if test "x$PKGCONFIG" != "x" -a -d "./test" -a "$ap_reduced_exports" = "no" && `$PKGCONFIG --atleast-version='0.9.12' check`; then
795795
UNITTEST_CFLAGS=`$PKGCONFIG --cflags check`
796796
UNITTEST_LIBS=`$PKGCONFIG --libs check`
797797
other_targets="$other_targets test/httpdunit"
798+
CHECK_TARGETS="$CHECK_TARGETS check-unittests"
798799

799800
AC_MSG_RESULT([yes])
800801
else
@@ -803,6 +804,13 @@ fi
803804
APACHE_SUBST(UNITTEST_CFLAGS)
804805
APACHE_SUBST(UNITTEST_LIBS)
805806

807+
if test -d "./test"; then
808+
AC_PATH_PROG(PYTEST3, pytest-3)
809+
if test -n "$ac_cv_path_PYTEST3"; then
810+
CHECK_TARGETS="$CHECK_TARGETS check-pytest"
811+
fi
812+
fi
813+
APACHE_SUBST(PYTEST3)
806814

807815
prefix="$orig_prefix"
808816
APACHE_ENABLE_MODULES
@@ -817,6 +825,7 @@ APACHE_SUBST(BUILTIN_LIBS)
817825
APACHE_SUBST(SHLIBPATH_VAR)
818826
APACHE_SUBST(OS_SPECIFIC_VARS)
819827
APACHE_SUBST(HTTPD_LIBS)
828+
APACHE_SUBST(CHECK_TARGETS)
820829

821830
PRE_SHARED_CMDS='echo ""'
822831
POST_SHARED_CMDS='echo ""'
@@ -1007,14 +1016,11 @@ AC_ARG_WITH([test-suite],
10071016
else
10081017
test -f "$withval/Makefile.PL" || AC_MSG_ERROR([--with-test-suite directory $withval does not contain the expected Makefile.PL])
10091018
TEST_SUITE_LOCATION="$withval"
1010-
WITH_TEST_SUITE=yes
1019+
CHECK_TARGETS="$CHECK_TARGETS check-test-framework"
10111020
fi
1012-
],
1013-
[ WITH_TEST_SUITE=no ]
1014-
)
1021+
])
10151022

10161023
APACHE_SUBST(TEST_SUITE_LOCATION)
1017-
APACHE_SUBST(WITH_TEST_SUITE)
10181024

10191025
APACHE_FAST_OUTPUT(Makefile modules/Makefile srclib/Makefile)
10201026
APACHE_FAST_OUTPUT(os/Makefile server/Makefile)

test/pyhttpd/env.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,10 @@ def has_shared_module(cls, name):
238238

239239
def __init__(self, pytestconfig=None):
240240
self._our_dir = os.path.dirname(inspect.getfile(Dummy))
241+
self._config_ini = os.getenv("PYHTTPD_CONFIG",
242+
os.path.join(self._our_dir, 'config.ini'))
241243
self.config = ConfigParser(interpolation=ExtendedInterpolation())
242-
self.config.read(os.path.join(self._our_dir, 'config.ini'))
244+
self.config.read(self._config_ini)
243245

244246
self._bin_dir = self.config.get('global', 'bindir')
245247
self._apxs = self.config.get('global', 'apxs')

0 commit comments

Comments
 (0)