File.cpp:line reporting from function calls
i find File.cpp:line incredibly useful in log messages, clicking them in VSCode navigates to that location which is so convenient. if action logs printed them too it would be even better (depending on a test a bunch of actions may run since last IM_CHECK* and then fail, at this point pinpointing exact failure line requires some effort). there is a new C++20 thingy that would allow this without using macros: https://en.cppreference.com/w/cpp/utility/source_location.html
I assume you have set ImGuiTestEngineSrcFileOpenFunc and you'd like this to be used from the log?
You know you can right-click a Test or a check entry in Test Log and use "Open Source" ?
As I understand source_location works by typically defaulting a param to std::source_location::current(), so as I understand it we would still need to include as a param to all functions?
What I believe is possible, without adding a source_location to every 150+ functions in ImGuiTestContext:
Improve the Test Log so that:
- clicking on an intermediary line would offer to open the last recorded location in the log (advertised as so)
- clicking on an intermediary line before any check happen would offer to open at the test starting location
- add a helper call that's basically a rebranded
IM_CHECK(false)orIM_CHECK_SILENT(false)to occasionally be able to record intermediary location if you have a particularly long script without checks, but I suspect user might figure out and useIM_CHECK(false)faster than they would recall the name for a rebranded macro.
I assume you have set ImGuiTestEngineSrcFileOpenFunc and you'd like this to be used from the log?
You know you can right-click a Test or a check entry in Test Log and use "Open Source" ?
Yes, i am aware and i have that set up, but i do not use it that much. Since i have test engine logs piped to my own log output i observe logs in the VSCode console instead of test engine UI. VSCode handles opening relevant file/line by parsing log messages and figuring out what log components should be clickable.
C++ is also adding facilities to access stack traces: https://en.cppreference.com/w/cpp/utility/basic_stacktrace.html Looks like this could be used without invading function signature. This does require a fresh compiler though (C++23), so probably not immediately useful to most users.