Add a means to override CATCH_INTERNAL_LINEINFO and specify a different source location
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- cpp
- 领域
- testing-qa
调研方向
首先检查 issue 中描述的 CATCH_INTERNAL_LINEINFO 宏、Catch::SourceLineInfo,以及 FAIL、FAIL_CHECK、WARN 和 INFO 入口点。将所请求的作用域覆盖与现有宏行为以及 std::source_location 风格的参数进行比较。完成的标准是:报告断言可以通过有意设计的公共 API 使用所提供的源位置,同时在该作用域之外保留正常的位置行为。
由索引模型根据 Issue 内容生成。
描述
Description
When integrating other reporting into catch2, e.g. https://github.com/rollbear/trompeloeil/blob/main/include/catch2/trompeloeil.hpp or a https://doc.qt.io/qt-6/qtlogging.html#QtMessageHandler-typedef, it's often the case that you already have source_location about where the message really originates from. But right now there's no way to call FAIL, FAIL_CHECK, WARN, etc and tell them this actual origin. The best you can do is format it into the message somehow, but that still leaves IDE hints and such taking you to the wrong point - where the macro was expanded (in the plumbing code between libraries).
It's possible (albeit hacky) to acheive this by doing something like
char const * file = ...;
int line = ...;
#pragma push_macro("CATCH_INTERNAL_LINEINFO")
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo(file, line)
FAIL(...)
#pragma pop_macro("CATCH_INTERNAL_LINEINFO")
But redefining the CATCH_INTERNAL_LINEINFO macro is clearly not an intended public API :-).
It would be nice if there was a scoped macro like CATCH_LINEINFO(file, line, column, function) which operated a bit like INFO - while it was in scope, any assertions that report would be attributed to this provided location instead of the site of the actual actual macro expansion. I've chosen those 4 args to align with std::source_location, but you might not always have all 4 - having only file and line is certainly common.
This way error callbacks from other libraries could be routed into FAIL, INFO, WARN, etc and attributed the source of the assertion, rather than the plumbing code between e.g. trompeloeil and catch2.
Additional context
See https://github.com/rollbear/trompeloeil/pull/350 - basically just being mildly annoyed that otherwise-excellent IDE experience (error list, detailed failure inlays) that catch2 and C++ TestMate deliver doesn't work as well when on mesages that originate from trompeloil mocks, qWarning, or other such sources.
- 主要语言
- C++
- 星标
- 21.6k
- 派生
- 3.4k
- 平均合并
- 3 天 12 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
catchorg/Catch2 的其他 Issue
-
catch_discover_tests fails for Windows test executables run under Wine since v3.15.2可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 2 天内回复
-
catch_discover_tests passes all EXTRA_ARGS as one argument可能已有人在做 @CyberKun 于 11 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
catchorg/Catch2#3239 · 1 条评论 ·
维护者通常 2 天内回复
-
Not seeing some error messages from fakeit in jetbrains rider可能已有人在做 @Amanpal9 于 21 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
catchorg/Catch2#3228 · 1 条评论 ·
维护者通常 2 天内回复
-
catch_discover_tests fails for Emscripten/WASM tests since v3.16.0可能已有人在做 @nafiurahman00 于 8 天前认领。 未关闭Extras
难度 3/5 1-2 天 新手友好度 72/100
catchorg/Catch2#3241 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
维护者通常 2 天内回复
相似的 Issue
-
difficulty:easy func:python os:windows prio:high type:bug
难度 2/5 1-3 小时 新手友好度 78/100
NatronGitHub/Natron#2029 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
ardazishvili/Sota#114 ·
维护者通常 1 天内回复
-
`Rect::containsPoint` is not `const`, so a `const Rect` cannot be asked whether it holds a point未关闭Needs: Triage :mag:
难度 1/5 1 小时以内 新手友好度 82/100
react/react-native#60349 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100