5

我正在尝试在 Jenkins 中为使用 PyQt4 的 Python 包运行测试,并且测试会创建窗口。由于我在 Jenkins 中运行测试,我需要重定向图形输出,所以我使用 xvfb-run。在大多数情况下,这是可行的,但在少数情况下,测试会随机失败,原因如下:

/usr/bin/xvfb-run: line 171: kill: (27375) - No such process

如果我重新运行测试,它大部分时间都可以正常工作(所以这只是一个一次性的问题)。

有没有人遇到过这个问题?您对提高测试稳定性的解决方法有什么想法吗?

4

2 回答 2

3

它通过找到 Xvfb 进程并杀死它来工作。

ps auwx | grep "Xvfb" | grep -v grep
于 2015-03-26T05:42:20.137 回答
1

If your copy of xvfb-run is the same as mine, I can confirm I've seen this too.

In my case, the target process caused Xvfb to crash. This means that the wrapper script itself fails at line 171 when tearing down no longer running Xvfb. To work around it I wrapped kill $XVFBPID in a set +e/set -e block. It also helps if you specify --error-file= so that xvfb-run saves the asynchronous standard error output from Xvfb while your target process is running, so you can get the underlying cause fixed.

Work around:

# Kill Xvfb now that the command has exited.
# Ignore failure of kill since we want to be forgiving of Xvfb itself crashing
set +e
kill $XVFBPID
set -e
于 2012-10-30T16:30:18.643 回答