VS2010 的错误列表中不再显示 Boost.Test 错误消息

发布于 2024-10-20 06:30:16 字数 387 浏览 4 评论 0原文

我正在将 Boost.Test 单元测试框架用于本机 C++ 项目。一切工作正常,但升级到 Visual Studio 2010 后遇到一个问题:在测试作为生成后步骤运行后,有关失败测试的消息不再显示在错误列表中。这是一个遗憾,因为 Boost.Test 与本机 C++ 项目的组合最接近(尽管仍然很远)我习惯于单元测试托管项目的舒适度。我正在使用 Boost.Test 作者推荐的配置 此处。任何人都可以帮助解决这个小但有点降低舒适度的问题吗?

问候,

保罗

I am using Boost.Test Unit Test Framework for native C++ projects. All is working fine, but I've got one issue after upgrading to Visual Studio 2010: The messages about failed tests are no more shown in the error list after the tests ran as a post build step. This is a pity since the combination of Boost.Test with native C++ project came closest (although still beeing far away) to the comfort I am used to from unit testing managed projects. I am using the configuration recommended by the authors of Boost.Test here. Can anyone help with this minor but a bit comfort lessening issue?

Regards,

Paul

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

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

发布评论

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

评论(2

南街九尾狐 2024-10-27 06:30:16

如果您不想等待发布并希望自己修复格式化程序,

请打开

BOOST_PATH\boost\test\impl\compiler_log_formatter.ipp

更改(boost_1_46_1 中的第 163 行)

output << "error in \"" << test_phase_identifier() << "\": ";

output << "error : in \"" << test_phase_identifier() << "\": ";

再次使用 bjam 重新编译 boost。

cd BOOST_PATH
bjam.exe

If you don't want to wait for a release and want to fix the formatter by yourself

open

BOOST_PATH\boost\test\impl\compiler_log_formatter.ipp

change (line 163 in boost_1_46_1)

output << "error in \"" << test_phase_identifier() << "\": ";

to

output << "error : in \"" << test_phase_identifier() << "\": ";

and recompile boost with bjam again.

cd BOOST_PATH
bjam.exe
伪装你 2024-10-27 06:30:16

Visual Studio 2005 编译器错误的构建输出如下所示:

|.\ut_TEMPLATE.cpp(8) : error C2065: 'x' : undeclared identifier

而 Visual Studio 2010 编译器错误在输出窗口中如下所示:(

|1>ut_TEMPLATE.cpp(8): error C2065: 'x' : undeclared identifier

编辑:请参阅 gbjbaanb 关于 >1。)

现在,交叉检查 BOOST_ERROR 输出的内容(如果您在构建后步骤中有 exe,则可以使用简单的 printf 来重现):

VS 2005:

|./ut_TEMPLATE.cpp(8): error in "test_TEST": check true == false failed [1 != 0]

VS 2010:

|1>  ut_TEMPLATE.cpp(10): error in "test_TEST": check true == false failed [true != false]

略有差异,但不是太多,并使用手动 printf 进一步测试:

printf("ut_TEMPLATE.cpp(00): error : in \"test_TEST\": check true == false failed [true != false]" "\n");
                                  ^^^ .. Note colon here

我们还让 VS 2010 将此输出识别为错误:

BOOST_AUTO_TEST_CASE(test_TEST)
{
    printf("ut_TEMPLATE.cpp(00): error : in \"test_TEST\": check true == false failed [true != false]" "\n");
    BOOST_CHECK_EQUAL( true, false);
}

1>------ Build started: Project: ut_TEMPLATE, Configuration: Release Win32 ------
1>  ut_TEMPLATE.cpp
1>  ut_TEMPLATE.vcxproj -> ....\UnitTests\ut_TEMPLATE\..\..\..\Release\ut_TEMPLATE.exe
1>  Running 1 test case...
1>ut_TEMPLATE.cpp : error : in "test_TEST": check true == false failed [true != false]
1>  ut_TEMPLATE.cpp(9): error in "test_TEST": check true == false failed [true != false]
1>C:\Programme\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command ""....\\ut_TEMPLATE.exe" --result_code=no --report_level=no
1>C:\Programme\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

所以看来您/我们/Boost.Test 需要调整它输出,以便 VS2010 IDE 仍然可以识别错误消息。

Visual Studio 2005 Build output for compiler errors looks like this:

|.\ut_TEMPLATE.cpp(8) : error C2065: 'x' : undeclared identifier

Whereas Visual Studio 2010 compiler errors look like this in the output window:

|1>ut_TEMPLATE.cpp(8): error C2065: 'x' : undeclared identifier

(Edit: See the comment by gbjbaanb about the >1.)

Now, crosschecking what BOOST_ERROR outputs (you can use a simple printf to reproduce if you have your exe in the post build step):

VS 2005:

|./ut_TEMPLATE.cpp(8): error in "test_TEST": check true == false failed [1 != 0]

VS 2010:

|1>  ut_TEMPLATE.cpp(10): error in "test_TEST": check true == false failed [true != false]

Slight difference, but not too much and testing further with a manual printf:

printf("ut_TEMPLATE.cpp(00): error : in \"test_TEST\": check true == false failed [true != false]" "\n");
                                  ^^^ .. Note colon here

We also get VS 2010 to recognize this output as error:

BOOST_AUTO_TEST_CASE(test_TEST)
{
    printf("ut_TEMPLATE.cpp(00): error : in \"test_TEST\": check true == false failed [true != false]" "\n");
    BOOST_CHECK_EQUAL( true, false);
}

1>------ Build started: Project: ut_TEMPLATE, Configuration: Release Win32 ------
1>  ut_TEMPLATE.cpp
1>  ut_TEMPLATE.vcxproj -> ....\UnitTests\ut_TEMPLATE\..\..\..\Release\ut_TEMPLATE.exe
1>  Running 1 test case...
1>ut_TEMPLATE.cpp : error : in "test_TEST": check true == false failed [true != false]
1>  ut_TEMPLATE.cpp(9): error in "test_TEST": check true == false failed [true != false]
1>C:\Programme\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command ""....\\ut_TEMPLATE.exe" --result_code=no --report_level=no
1>C:\Programme\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

So it would appear you/we/Boost.Test needs to tweak it's output so that the VS2010 IDE still recognizes the error message.

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