Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

automake: automatically run unit tests

I am maintaining an autoconf package and wanted to integrate automatic testing. I use the Boost Unit Test Framework for my unit tests and was able to sucessfully integrate it into the package.

That is it can be compiled via make check, but is is not run (although I read that make check both compiles and runs the tests). As result, I have to run it manually after building the tests which is cumbersome.

Makefile.am in the test folder looks like this:

check_PROGRAMS = prog_test
prog_test_SOURCES = test_main.cpp ../src/class1.cpp class1_test.cpp class2.cpp ../src/class2_test.cpp ../src/class3.cpp ../src/class4.cpp
prog_test_LDADD = $(BOOST_FILESYSTEM_LIB) $(BOOST_SYSTEM_LIB) $(BOOST_UNIT_TEST_FRAMEWORK_LIB)

Makefile.am in the root folder:

SUBDIRS = src test
dist_doc_DATA = README
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4

Running test/prog yields the output:

Running 4 test cases...

*** No errors detected

(I don't think you need the contents of my test cases in order to answer my question, so I omitted them for now)

So how can I make automake run my tests every time I run make check?

like image 395
Paddre Avatar asked Apr 18 '15 09:04

Paddre


1 Answers

At least one way of doing this involves setting TESTS variable. Here's what documentation on automake says about it:

If the special variable TESTS is defined, its value is taken to be a list of programs or scripts to run in order to do the testing.

So adding the line

TESTS = $(check_PROGRAMS)

should instruct it to run the tests on make check.

like image 124
xaizek Avatar answered Oct 01 '22 21:10

xaizek