即使有些失败,也要执行子目录中的所有测试

时间:2015-11-19 12:34:32

标签: testing automated-tests autotools automake regression-testing

我们的软件利用autotools(autoconf& automake)基础设施进行了多次回归测试。这些回归测试根据他们测试的功能/单元在不同的子目录之间分开。我们发现,一旦其中一个子目录在任何测试中失败,后续子目录中的后续测试就不会执行,因此我们无法全面了解哪些功能按预期工作。有没有办法改变这种行为并强制执行所有测试,即使有一些测试失败了?

考虑以下最小的例子,其中subdir1失败,然后make检查没有进展到subdir2。使用make check检查输出(通过autoreconf -fiv生成配置和简单的./configure调用之后):

...
make[2]: Entering directory `x/subdir1'
make[3]: Entering directory `x/subdir1'
FAIL: fail
PASS: pass
make[4]: Entering directory `x/subdir1'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `x/subdir1'
============================================================================
Testsuite summary for test 1.0
============================================================================
# TOTAL: 2
# PASS:  1
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See subdir1/test-suite.log
============================================================================
make[3]: *** [test-suite.log] Error 1
make[3]: Leaving directory `x/subdir1'
make[2]: *** [check-TESTS] Error 2
make[2]: Leaving directory `x/subdir1'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `x/subdir1'
make: *** [check-recursive] Error 1

这个小测试的文件是:

configure.ac

AC_INIT([test], [1.0])
AM_INIT_AUTOMAKE()
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
 Makefile
 subdir1/Makefile
 subdir2/Makefile
])
AC_OUTPUT

subdir1 / Makefile.am

check_PROGRAMS = fail pass
TESTS = fail pass
fail_SOURCES = fail.c
pass_SOURCES = pass.c

subdir2 / Makefile.am

check_PROGRAMS = pass
TESTS = pass
pass_SOURCES = pass.c

以及fail.c和pass.c的共享源

pass.c

int main (void)
{ return 0; }

fail.c

int main (void)
{ return 1; }

2 个答案:

答案 0 :(得分:2)

我知道它并不漂亮,但解决问题的一种方法是将所有子目录中的所有测试放入一个Makefile中的单个TESTS对象中。例如:

<强> configure.ac

AC_INIT([test], [1.0])
AM_INIT_AUTOMAKE()
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
 Makefile
 subdir1/Makefile
 subdir2/Makefile
])
AC_OUTPUT

<强> subdir1 / Makefile.am

check_PROGRAMS = fail pass
fail_SOURCES = fail.c
pass_SOURCES = pass.c

<强> subdir2 / Makefile.am

check_PROGRAMS = pass
pass_SOURCES = pass.c

附加到顶级 Makefile.am

TESTS = subdir1/fail subdir1/pass subdir2/pass

答案 1 :(得分:2)

继续执行make即使某些子目标失败,您也可以添加-k标志 - 无论实际目标如何,这都有效:

make -k check
相关问题