If you run 'make check', it will find python scripts in 'tests' directory and execute all methods which starts with 'test_'.
FIXME: test/Makefile.am is tricky Signed-off-by: MORITA Kazutaka <[email protected]> --- Makefile.am | 2 +- configure.ac | 6 +++++- tests/Makefile.am | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 tests/Makefile.am diff --git a/Makefile.am b/Makefile.am index ddfbfe0..cdc7165 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,7 +17,7 @@ sheepdogsysconfdir = ${SHEEPDOGCONFDIR} sheepdogsysconf_DATA = -SUBDIRS = lib collie sheep include script man +SUBDIRS = lib collie sheep include script man tests install-exec-local: $(INSTALL) -d $(DESTDIR)/${localstatedir}/lib/sheepdog diff --git a/configure.ac b/configure.ac index ca33fab..d25be28 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,7 @@ AM_INIT_AUTOMAKE([-Wno-portability]) AC_CONFIG_SRCDIR([collie/collie.c]) AC_CONFIG_HEADER([include/config.h]) +AC_CONFIG_TESTDIR([tests]) AC_CANONICAL_HOST @@ -69,6 +70,8 @@ AC_PROG_MAKE_SET AC_PROG_RANLIB AC_CHECK_PROGS([GROFF], [groff]) +AM_MISSING_PROG(AUTOM4TE, autom4te, $missing_dir) + # Checks for libraries. AC_CHECK_LIB([socket], [socket]) @@ -122,7 +125,8 @@ AC_CONFIG_FILES([Makefile include/Makefile script/Makefile lib/Makefile - man/Makefile]) + man/Makefile + tests/Makefile]) ### Local business diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..3dafe9f --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,40 @@ +$(srcdir)/package.m4: $(top_srcdir)/configure.ac + @{ \ + echo '# Signature of the current package.'; \ + echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])'; \ + echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])'; \ + echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])'; \ + echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])'; \ + echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])'; \ + echo 'm4_define([AT_PACKAGE_URL], [$(PACKAGE_URL)])'; \ + } > '$(srcdir)/package.m4' + +EXTRA_DIST = +TESTSUITE = $(srcdir)/testsuite +AUTOTEST = $(AUTOM4TE) --language=autotest + +check-local: atconfig $(srcdir)/package.m4 + @{ \ + echo 'AT_INIT()'; \ + echo 'AT_COLOR_TESTS'; \ + for f in *.py; do \ + f=$${f%.py}; \ + echo "AT_BANNER([$$f])"; \ + python -c "import $$f; import sys; \ + [sys.stdout.write( \ + 'AT_SETUP([' + f + '])\n' + \ + 'AT_CHECK([ \ + PYTHONPATH=$(abs_srcdir) \ + SHEEP=$(abs_top_builddir)/sheep/sheep \ + COLLIE=$(abs_top_builddir)/collie/collie \ + python -c \'import $$f; $$f.' + f + '()\' \ + ],,stdout,stderr)\n' + \ + 'AT_CLEANUP()\n' \ + ) for f in dir($$f) if f.startswith('test_')]"; \ + done \ + } > '$(TESTSUITE).at' + $(AUTOTEST) -I '$(srcdir)' -o '$(TESTSUITE)' '$(TESTSUITE).at' + $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) + +clean-local: + test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' --clean -- 1.7.2.5 -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
