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
sed -e 's#$(prefix)#$(top_builddir)/check#g' support/apxs > $@
chmod +x $@
+# A version of apachectl with the PREFIX overridden to point inside the install root
+check/bin/apachectl:
+ mkdir -p check
+ sed -e 's#$(prefix)#$(top_builddir)/check#g' support/apachectl > $@
+ chmod +x $@
+
# A version of config_vars.mk with PREFIX and SBINDIR and BINDIR overridden.
check/build/config_vars.mk: build/config_vars.out
mkdir -p check/build
check-make: $(TEST_SUITE_LOCATION)/Makefile
-check-no:
- @echo 'Re-run configure with the --with-test-suite option to enable in-tree tests.'
- @false
+check-tree: check-include check-dirs check-conf check/build/config_vars.mk \
+ check-binaries
-check-yes: check-include check-dirs check-conf check/build/config_vars.mk \
- check-binaries $(TEST_SUITE_LOCATION)/Makefile
+# Run the Apache::Test Perl framework
+check-test-framework: check-tree $(TEST_SUITE_LOCATION)/Makefile
cd $(TEST_SUITE_LOCATION) && $(MAKE) && ./t/TEST $(TEST_CONFIG) $(TESTS)
-# Run the Apache::Test suite if it has been configured with --with-test-suite.
-check: check-$(WITH_TEST_SUITE)
+# Generate config.ini suitable for running against the check/ install prefix
+check/config.ini: test/pyhttpd/config.ini
+ sed -e 's#$(prefix)#$(top_builddir)/check#g' test/pyhttpd/config.ini > $@
+
+check/modules/stamp: build/config_vars.mk
+ mkdir -p check/modules
+ rm -f check/modules/*.so
+ find modules -name \*.so -exec ln -s $(top_builddir)/{} check/modules/ \;
+ find server/mpm -name \*.so -exec ln -s $(top_builddir)/{} check/modules/ \;
+ date > $@
+
+check-pytest: check-tree check/bin/apachectl check/config.ini check/modules/stamp
+ PYHTTPD_CONFIG=$(top_builddir)/check/config.ini $(PYTEST3) $(PYTEST_DIRS)
+
+# Runs all configured/available test targets.
+check: $(CHECK_TARGETS)
#
# Unit Test Suite
$(httpdunit_OBJECTS): override LTCFLAGS += $(UNITTEST_CFLAGS)
test/httpdunit: $(httpdunit_OBJECTS) $(PROGRAM_DEPENDENCIES) $(PROGRAM_OBJECTS)
$(LINK) $(httpdunit_OBJECTS) $(PROGRAM_OBJECTS) $(UNITTEST_LIBS) $(PROGRAM_LDADD)
+
+check-unittests: test/httpdunit
+ test/httpdunit
/^EXPORTS_DOT_C/d
/^LIBMAIN_LIB/d
/TEST_SUITE/d
+/^PYTEST3/d
+/^CHECK_TARGETS/d
"
dnl Enable the unit test executable if Check is installed.
dnl TODO: at the moment, only pkg-config discovery is supported.
AC_MSG_CHECKING([for Check to enable unit tests])
-if test "x$PKGCONFIG" != "x" -a "$ap_reduced_exports" = "no" && `$PKGCONFIG --atleast-version='0.9.12' check`; then
+if test "x$PKGCONFIG" != "x" -a -d "./test" -a "$ap_reduced_exports" = "no" && `$PKGCONFIG --atleast-version='0.9.12' check`; then
UNITTEST_CFLAGS=`$PKGCONFIG --cflags check`
UNITTEST_LIBS=`$PKGCONFIG --libs check`
other_targets="$other_targets test/httpdunit"
+ CHECK_TARGETS="$CHECK_TARGETS check-unittests"
AC_MSG_RESULT([yes])
else
APACHE_SUBST(UNITTEST_CFLAGS)
APACHE_SUBST(UNITTEST_LIBS)
+if test -d "./test"; then
+ AC_PATH_PROG(PYTEST3, pytest-3)
+ if test -n "$ac_cv_path_PYTEST3"; then
+ CHECK_TARGETS="$CHECK_TARGETS check-pytest"
+ fi
+fi
+APACHE_SUBST(PYTEST3)
prefix="$orig_prefix"
APACHE_ENABLE_MODULES
APACHE_SUBST(SHLIBPATH_VAR)
APACHE_SUBST(OS_SPECIFIC_VARS)
APACHE_SUBST(HTTPD_LIBS)
+APACHE_SUBST(CHECK_TARGETS)
PRE_SHARED_CMDS='echo ""'
POST_SHARED_CMDS='echo ""'
else
test -f "$withval/Makefile.PL" || AC_MSG_ERROR([--with-test-suite directory $withval does not contain the expected Makefile.PL])
TEST_SUITE_LOCATION="$withval"
- WITH_TEST_SUITE=yes
+ CHECK_TARGETS="$CHECK_TARGETS check-test-framework"
fi
- ],
- [ WITH_TEST_SUITE=no ]
-)
+ ])
APACHE_SUBST(TEST_SUITE_LOCATION)
-APACHE_SUBST(WITH_TEST_SUITE)
APACHE_FAST_OUTPUT(Makefile modules/Makefile srclib/Makefile)
APACHE_FAST_OUTPUT(os/Makefile server/Makefile)
def __init__(self, pytestconfig=None):
self._our_dir = os.path.dirname(inspect.getfile(Dummy))
+ self._config_ini = os.getenv("PYHTTPD_CONFIG",
+ os.path.join(self._our_dir, 'config.ini'))
self.config = ConfigParser(interpolation=ExtendedInterpolation())
- self.config.read(os.path.join(self._our_dir, 'config.ini'))
+ self.config.read(self._config_ini)
self._bin_dir = self.config.get('global', 'bindir')
self._apxs = self.config.get('global', 'apxs')