在 Python 2.7.4 构建的单个模块上运行“make test”

Ban*_*jer 3 compiling centos python

我正在CentOS 6.4上构建Python 2.7.4。运行该make test步骤时,该test_gdb步骤失败,我想了解更多有关原因的信息。

我正在运行的构建命令:

./configure --prefix=/usr/local/python-2.7.4 --enable-ipv6 --enable-unicode=ucs4 --enable-shared
make
make test
Run Code Online (Sandbox Code Playgroud)

make 测试的输出:

... 测试 test_gdb 失败——出现多个错误;以详细模式运行以获取详细信息...

所以基本上,我试图弄清楚如何test_gdb单独和在详细模式下运行测试。听起来我应该使用regrtest.py,但我似乎可以invalid syntax使用我尝试过的各种选项。有任何想法吗?

banjer@somehost:/usr/local/src/Python-2.7.4> python Lib/test/regrtest.py -v test_gdb
  File "Lib/test/regrtest.py", line 679
    'test_support',
                  ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

Ant*_*hon 7

Lib/test/regrtest.py 中 679 附近的实际行是:

NOTTESTS = {
    'test_support',
    'test_future1',
    'test_future2',
}
Run Code Online (Sandbox Code Playgroud)

这定义了一个可变集,并且语法从 3.1 向后移植到 2.7。此语法在 2.6 或更早版本的 python 中不可用。

您的测试引发语法错误可能是因为您的默认 python 是 2.7 之前的版本。如果你会执行:

./python Lib/test/regrtest.py -v test_gdb
^-- this is the difference
Run Code Online (Sandbox Code Playgroud)

在该目录中,您将测试python刚刚编译的可执行文件,而不是路径中提供的默认可执行文件。使用该可执行文件,您不太可能遇到此特定错误(但可能还有其他真正gdb相关的错误)。