wiki:Tests

The parent directory's Makefile.am may need to descend into a tests directory, for example:

SUBDIRS = tests

If the code needs to be built prior to test code, you can do current directory (.) first, like:

SUBDIRS = . tests

Python tests

The following is example Makefile.am code:

# later will have configure option to choose this, like: coverage run --branch
PYCOVERAGE = $(PYTHON)
#PYCOVERAGE=@PYCOVERAGE@
PYTESTS = foo_test.py
EXTRA_DIST = $(PYTESTS)

# test using command-line arguments, so use check-local target instead of TESTS
check-local:
      for pytest in $(PYTESTS) ; do \
      echo Running test: $$pytest ; \
      env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/FOO \
      $(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
      done

Python tests are included in the release tarball by adding EXTRA_DIST to the respective tests Makefile.am. The PYCOVERAGE is set to python by default, but may be set to py-coverage (coverage) instead. (This will be documented later.) Set the PYTHONPATH as needed (see FOO). Later will add to this example steps for python coverage testing and/or will create a generic Makefile.am macro or include files for this.

C++ tests

The GoogleTest-based tests already are included in the tarball (when using TESTS and foo_SOURCES), but you do need to use EXTRA_DIST to include data file or other supplementary testing files to the release tarball.

Last modified 7 years ago Last modified on Jun 30, 2010, 4:35:49 PM