自动工具在测试失败时输出test-suite.log内容

Árp*_*nyi 5 testing continuous-integration autotools

我有一个基于autotools的项目。当“ make check”目标失败时,我将看到以下内容:

============================================================================
Testsuite summary for 
============================================================================
# TOTAL: 1
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See tests/python/test-suite.log
============================================================================
make[5]: *** [test-suite.log] Error 1
Run Code Online (Sandbox Code Playgroud)

到目前为止,这在受限制的构建器(在这种情况下为launchpad构建)中不会发生的情况下是可以的,我只能在其中看到构建日志。受影响目录中的Makefile.am如下所示:

EXTRA_DIST = test_inetdomain.py test_zone.py test_matcher.py test_dispatch.py test_nat.py test_log.py test_session.py test_stacking.py

noinst_SCRIPTS = runtest.sh

TESTS = runalltests.sh

.PHONY: mkzorp
mkzorp:
    make -C ../../zorp 

runtest.sh: mkzorp
Run Code Online (Sandbox Code Playgroud)

我应该向Makefile.am写入什么/应该给autoreconf / autoconf提供什么参数/应该设置哪些环境变量以查看stdout / stderr上的测试输出?

Dan*_*lKO 4

“check”目标在 automake 中有点僵化,因为它取决于它对其他事情的行为。

最简单的解决方案似乎是自定义测试驱动程序,因为它负责将输出重定向到日志文件。我假设您正在使用默认的测试驱动程序,因此在第 111 行左右打开它,您应该看到类似这样的内容:

# Report outcome to console.
echo "${col}${res}${std}: $test_name"
Run Code Online (Sandbox Code Playgroud)

只需将这些行附加到此后的某个位置(例如在脚本末尾):

if test $estatus != 0
then
    sed -e "s/^/$log_file:\t/" $log_file # but a cat is fine too
fi
Run Code Online (Sandbox Code Playgroud)

请记住将此定制的测试驱动程序添加到您的源代码管理中。

郑重声明,这里有一些行不通的东西:定义一个从 makefile 本身check-local运行的规则cat $TEST_LOGS是行不通的,因为一旦测试失败 automake 就会停止,并且你只能 hook up check-local,它只有在check-TESTS成功时才会运行。