开发者

Automake with multiple test suites (coding/deployment)

开发者_如何学GoI'm using Automake for a project that is starting to have longer running integration/deployment style tests in addition to the typical unit tests. The issue is that during normal programming there is no need to run the longer tests, only the shorter set of unit tests. However, the final merge, and/or repository build, must run the complete test suite.

Is there a standard way to handle this with automake? Ideally I'd like to just have two targets, the normal check target to run everything and perhaps a check-lite to run the reduced test.

The project is spread across several sub-projects and directories, thus a standard automake approach would be ideal to ensure consistency.


I suggest adding a --enable-extended-tests option to your configure script:

AC_MSG_CHECKING([whether to run extended tests])
AC_ARG_ENABLE([extended-tests],
  [AS_HELP_STRING([--enable-extended-tests], [run full integration tests])],
  [enable_extended_tests="yes"], [enable_extended_tests="no"])
AC_MSG_RESULT([$enable_extended_tests])

AM_CONDITIONAL([EXTENDED_TESTS], [test "X$enable_extended_tests" != "Xno"])

Then you can use an Automake conditional in your Makefile.am:

if EXTENDED_TESTS
EXTRA_TESTS = extra_test1 extra_test2 ...
else
EXTRA_TESTS =
endif

TESTS = $(EXTRA_TESTS) normal_test1 normal_test2 ...


If you have split your test suite into separate directories based on the test type, then you can add some additional targets to the top level Makefile.am to do partial test suite runs.

For example, if your tree is organised as:

$(srcdir)
  - tests
     - unit
     - integration

You could add the following to the makefile:

check-unit:
    $(MAKE) $(AM_MAKEFLAGS) -C tests/unit check

check-integration:
    $(MAKE) $(AM_MAKEFLAGS) -C tests/integration check

Now when you run make check-unit, it will only run your unit tests. And running make check-integration will run the other half of the tests. The standard make check target will continue to run the whole suite.

If you can't organise all the tests under a single directory, you can add additional $(MAKE) invocations to the targets. It does require some knowledge of the project structure at the top level, but there isn't a clear way to pass the required information up from the Makefile.am files in subdirectories.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜