如何让我的 hudson 项目构建在第二组鼻子测试中失败?

发布于 2024-10-10 20:22:51 字数 2529 浏览 3 评论 0原文

我对 Hudson 比较陌生,所以如果这是一个“废话”问题,请原谅我。

我有一个用Python编写的项目(使用pylons和nosetests),其中包括服务器组件和客户端组件。我在服务器层次结构和客户端层次结构中都设置了功能测试,以测试这两个组件。在我的构建脚本(从 hudson 项目配置页面启动的 shell 脚本)中,我连续运行两个不同的鼻子测试,如下所示:(

# Python tests for server
find $WORKSPACE/server/src/project/tests -iname "*test_*.py" | xargs $NOSETESTS --with-coverage --cover-package=project --cover-html --cover-erase --with-pylons="$PYLONS_INI"
echo "SERVER TEST EXIT STATUS: $?"
if [ $? -ne 0 ]; then
    test_status=$test_status+$?
    export TEST_STATUS=$test_status
    exit $?
fi

然后,在启动服务器后)

# Python tests for client
find $WORKSPACE/server/src/project/tests -iname "*test_*.py" | xargs $NOSETESTS --with-coverage --cover-package=projectclient --cover-html --cover-erase --with-pylons="$PYLONS_INI"
echo "CLIENT TEST EXIT STATUS: $?"
if [ $? -ne 0 ]; then
    test_status=$test_status+$?
    export TEST_STATUS=$test_status
    exit $?
fi

然后我关闭服务器。

第一组测试(服务器测试)始终有效。如果测试失败,构建会报告失败,并且球会变成红色。然而,第二组(客户端测试)永远不会起作用。如果测试失败,STDOUT 会报告失败,并且脚本显示退出状态 123,但构建永远不会失败。

我尝试过添加

maven.test.failure.ignore=false
to my hudson configuration, based on some other questions I've seen here on stackoverflow, but it doesn't seem to have made a difference. I've tried forcing the script to terminate with an artificial exit value to see if it was even paying attention to the exit value, and that didn't change things. I've also tried moving the client tests above the server tests, to see if there were some reason why hudson only allowed for one set of nosetests, but that didn't seem to change things either.

如果有人知道我可能做错了什么,我一定会很感激你的帮助。如果您需要更多信息,请告诉我。

谢谢!

============================

更新:

我能够让第二组测试像这样工作:

find $WORKSPACE/client/python/src/tests -iname "*test_*.py" | xargs $NOSETESTS --with-coverage --cover-package=projectclient --cover-html --cover-erase --with-pylons="$PYLONS_INI"
client_test_status=$?
if [ $client_test_status -ne 0 ]; then
    echo "Client Test Status = $client_test_status"
    exit $client_test_status
fi

但是,我不必对服务器测试进行此更改。只有客户的。服务器测试仍然有效,并且仍然看起来像这样:

find $WORKSPACE/server/src/project/tests -iname "*test_*.py" | xargs $NOSETESTS --with-coverage --cover-package=project --cover-html --cover-erase --with-pylons="$PYLONS_INI"
if [ $? -ne 0 ]; then
    exit $?
fi

这里流传着一个假设,即 PIPE 吞噬 $ 可能存在问题?,但这并不能解释为什么服务器测试成功(失败),但是客户端测试不会(除非捕获了 $?)。

I'm relatively new to Hudson, so please forgive me if this is a "duh" question.

I have a project written in python (employing pylons and nosetests) that includes both a server component and a client component. I have function tests set up in both the server hierarchy, and the client hierarchy, to exercise both components. In my build script (a shell script launched from the hudson project configuration page), I run two different nosetests, serially, like so:

# Python tests for server
find $WORKSPACE/server/src/project/tests -iname "*test_*.py" | xargs $NOSETESTS --with-coverage --cover-package=project --cover-html --cover-erase --with-pylons="$PYLONS_INI"
echo "SERVER TEST EXIT STATUS: $?"
if [ $? -ne 0 ]; then
    test_status=$test_status+$?
    export TEST_STATUS=$test_status
    exit $?
fi

(Then, after starting up the server)

# Python tests for client
find $WORKSPACE/server/src/project/tests -iname "*test_*.py" | xargs $NOSETESTS --with-coverage --cover-package=projectclient --cover-html --cover-erase --with-pylons="$PYLONS_INI"
echo "CLIENT TEST EXIT STATUS: $?"
if [ $? -ne 0 ]; then
    test_status=$test_status+$?
    export TEST_STATUS=$test_status
    exit $?
fi

Then I shut the server down.

The first set of tests (the server tests) always work. If a test fails, the build reports a failure, and the ball turns red. The second set (the client tests), however, never work. If a test fails, the STDOUT reports the failure, and the script shows an exit status of 123, but the build never fails.

I've tried adding

maven.test.failure.ignore=false

to my hudson configuration, based on some other questions I've seen here on stackoverflow, but it doesn't seem to have made a difference. I've tried forcing the script to terminate with an artificial exit value to see if it was even paying attention to the exit value, and that didn't change things. I've also tried moving the client tests above the server tests, to see if there were some reason why hudson only allowed for one set of nosetests, but that didn't seem to change things either.

If anyone has any idea what I might be doing wrong, I'd sure appreciate the help. If you need more information, just let me know.

Thanks!

============================

UPDATE:

I was able to get the second set of tests working like so:

find $WORKSPACE/client/python/src/tests -iname "*test_*.py" | xargs $NOSETESTS --with-coverage --cover-package=projectclient --cover-html --cover-erase --with-pylons="$PYLONS_INI"
client_test_status=$?
if [ $client_test_status -ne 0 ]; then
    echo "Client Test Status = $client_test_status"
    exit $client_test_status
fi

However, I did not have to make this change to the SERVER tests. Only the client ones. The server tests still work, and still look like this:

find $WORKSPACE/server/src/project/tests -iname "*test_*.py" | xargs $NOSETESTS --with-coverage --cover-package=project --cover-html --cover-erase --with-pylons="$PYLONS_INI"
if [ $? -ne 0 ]; then
    exit $?
fi

One hypothesis floating around here, is that there might be an issue with the PIPE swallowing $?, but that doesn't explain why the server tests succeed (at failing), but the client tests do not (unless the $? is captured).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人问我粥可暖 2024-10-17 20:22:51

只要看看你的退出命令,我就想知道为什么当服务器测试失败时你的构建会中断。这可能与构建失败时服务器无法启动这一事实有关。事实上,您正在检查 echo 的退出状态,而不是测试套件的退出状态。首先捕获退出状态 my_exit = $?,然后始终使用 $my_exit 而不是 $?

Just looking at your exit command makes me wonder why your build breaks when the server test fail. It might be connected with the fact that your server doesn't start when your build fails. In fact you are checking the exit status of echo and not of the exit status of your test suite. Capture your exit status first my_exit = $? and then always use $my_exit instead of $?.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文