I've got a program that's written in C, built using automake/autoconf, and has two test suites. One is a unit test suite also written in C; the other is end-to-end and is (currently) written in Python. I want "make check" to run the unit tests always, and the end-to-end tests only if Python is installed. This is what I have now:
TESTS = unittests
if HAVE_PYTHON
TESTS += tester.py
tester_py_SOURCES = src/test/tester.py.in
tester.py: src/test/tester.py.in Makefile
$(SED) -e 's,[@]PYTHON[@],$(PYTHON),' < $< > $@
chmod +x $@
endif
HAVE_PYTHON
is set by the configure script with
AM_PATH_PYTHON([2.6],, [:])
AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != ":"])
This works correctly on Unix, but blows up with "no rule to make tester.py.exe" on Windows. Also, the copy-and-substitute technique for getting the #!
line right means I can't break up the test suite into multiple modules.
Is there a better way to do this?