autotools在测试失败时输出test-suite.log内容

时间:2014-01-07 00:36:23

标签: 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

在受限制的构建器(在本例中为launchpad buildd)中不会发生这种情况,但我只能看到构建日志。 受影响目录中的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

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

3 个答案:

答案 0 :(得分:4)

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

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

# Report outcome to console.
echo "${col}${res}${std}: $test_name"

在那之后将这些行附加到某处(就像在脚本的末尾):

if test $estatus != 0
then
    sed -e "s/^/$log_file:\t/" $log_file # but a cat is fine too
fi

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

对于记录,这里有些东西不起作用:定义从makefile本身运行check-local的{​​{1}}规则将无效,因为一旦测试失败,automake就会停止,而你只能挂钩cat $TEST_LOGS,仅在check-local成功时才会运行。

答案 1 :(得分:1)

我在使用Fedora koji包构建器时遇到了同样的问题,解决方案只是在测试运行失败后打印出文件。

对于Fedora RPM,这很容易。

%check
make check || cat ./test-suite.log

从那时起,只要测试失败,测试日志的内容就是构建日志的一部分。如此简单和有用。

我希望Launchpad和其他构建器的程序非常相似。

答案 2 :(得分:0)

较旧的automake版本用于将输出发送到stdout。我想在引入并行测试时这会改变,所以我遇到了和Árpád一样的问题。

您可以使用serial test harness启用旧行为,方法是将以下内容添加到Makefile.am

AUTOMAKE_OPTIONS = serial-tests
相关问题