如何使用 Eclipse 处理 Boost.Test 输出

发布于 2024-08-25 21:26:06 字数 127 浏览 11 评论 0原文

我正在使用 Eclipse CDT 和 Boost.Test(带有 Boost.Build)。 我希望 Eclipse 能够解析构建期间运行测试套件时生成的 Boost.Test 的输出。
有人知道如何实现这一目标吗? 提前致谢

I'm using Eclipse CDT and Boost.Test(with Boost.Build).
I would like Eclipse to parse output of Boost.Test generated during by run of test suites during build.
Does anybody know how to achieve this?
Thanks in advance

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

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

发布评论

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

评论(3

荒人说梦 2024-09-01 21:26:06

转到窗口>偏好。在首选项对话框中,选择 C/C++ >从选项树构建。在错误解析器下,单击“添加...”在新对话框中,将“Regex Error Parser”替换为“Boost Unit Test Error Parser”之类的内容。

在“错误解析器选项”窗格中,添加以下行。我不能保证这些规则捕获来自 boost 单元测试的所有可能的输出,但到目前为止它们对我有用,并且我们以后总是可以添加更多:

Severity | Pattern                                          | File | Line | Description
Error    | (.*)\((\d*)\): ((fatal )?error in ".*":.*)       | $1   | $2   | $3
Error    | \*\*\* (\d* failures detected in test suite ".*")|      |      | $1
Info     | (.*)\((\d*)\): (last checkpoint)                 | $1   | $2   | $3

请注意,新的解析器不会自动在现有项目中使用。要为现有项目启用解析器,请转到“项目”>“属性、C/C++ Make 项目、错误解析器选项卡。如果新添加的解析器不在列表中,请单击“恢复默认值”,它现在应该可用。

Go to Window > Preferences. In the preferences dialog, choose C/C++ > Build from the options tree. Under error parsers, click "Add..." In the new dialog, replace "Regex Error Parser" with something like "Boost Unit Test Error Parser".

In the Error Parser Options pane, add the following lines. I can't guarantee that these rules catch all possible output from boost unit tests, but so far they work for me, and we can always add more later:

Severity | Pattern                                          | File | Line | Description
Error    | (.*)\((\d*)\): ((fatal )?error in ".*":.*)       | $1   | $2   | $3
Error    | \*\*\* (\d* failures detected in test suite ".*")|      |      | $1
Info     | (.*)\((\d*)\): (last checkpoint)                 | $1   | $2   | $3

Note that the new parser will not automatically be used in existing projects. To enable the parser for an existing project, go to Project > Properties, C/C++ Make Project, Error Parsers tab. If the newly added parser is not in the list, click "Restore Defaults", and it should now be available.

饮惑 2024-09-01 21:26:06

还有一个不错的插件,叫做 cdt c/c++testsrunner,它支持 Google 测试、boost 测试和 qt 测试。

您可以在以下链接中找到说明:

https://github.com/xgsa/ cdt-tests-runner/wiki/Tutorial

我已经使用它有一段时间了,发现它高效且漂亮。它具有类似于 Java 的 JUnit 插件的功能。

There is also a nice plugin called cdt c/c++ tests runner, which supports Google test, boost test, and qt test.

You can find instructions at the following link:

https://github.com/xgsa/cdt-tests-runner/wiki/Tutorial

I have been using it for a while, and found it efficient and nice. It has features like a JUnit plugin for Java.

笙痞 2024-09-01 21:26:06

我的 IDE (gedit) 也有同样的问题,无法识别 Boost.Test 的输出格式(由于某种原因,它与 gnu 和 clang 输出不兼容)。

您可以通过将其粘贴到测试中以编程方式更改输出格式:(

#include<boost/test/output/compiler_log_formatter.hpp>
struct gedit_config{
    struct formatter : boost::unit_test::output::compiler_log_formatter{
        void print_prefix(std::ostream& out, boost::unit_test::const_string file, std::size_t line){
            out<< file <<':'<< line <<": ";
        }
    };
    gedit_config(){boost::unit_test::unit_test_log.set_formatter(new formatter);}
};
BOOST_GLOBAL_FIXTURE(gedit_config);

此处的原始答案:https://stackoverflow.com/ a/64619245/225186

I had the same problem of my IDE (gedit) not recognizing the output format of Boost.Test (which is not compatible with gnu and clang output for some reason).

You can change the output format programmatically by sticking this in your test(s):

#include<boost/test/output/compiler_log_formatter.hpp>
struct gedit_config{
    struct formatter : boost::unit_test::output::compiler_log_formatter{
        void print_prefix(std::ostream& out, boost::unit_test::const_string file, std::size_t line){
            out<< file <<':'<< line <<": ";
        }
    };
    gedit_config(){boost::unit_test::unit_test_log.set_formatter(new formatter);}
};
BOOST_GLOBAL_FIXTURE(gedit_config);

(original answer here: https://stackoverflow.com/a/64619245/225186)

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