-
Couldn't load subscription status.
- Fork 736
[tests] add log level to string unit tests #3943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tests] add log level to string unit tests #3943
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3943 +/- ##
=======================================
Coverage 89.11% 89.11%
=======================================
Files 255 255
Lines 14603 14603
=======================================
Hits 13014 13014
Misses 1589 1589 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4b19d9c to
94e1fe7
Compare
MULTI-1831 Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
94e1fe7 to
419b813
Compare
Fixed link to Multipass Discourse landing page Signed-off-by: Giulia Zanchi <giulia.zanchi@canonical.com>
Signed-off-by: Giulia Zanchi <giulia.zanchi@canonical.com>
|
Cherry-picked the commits from #3944 to resolve the cyclic CI failure between the two branches. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Not really relating to this PR but mpl::as_string returning CString is interesting, std::string_view seems more appropriate.
|
It looks good to me as well. |
Yeah, I'm not fond of CString as well. The only reason it works is the expression temporary lifetime extension: void foo(CString f){ }
foo(fmt::format("test"));
// fmt::format returns a std::string, which has a temporary lifetime.
// CString has a const std::string& constructor which grabs the return value
// of .c_str() to assign it to a private const char* member.
// The lifetime of the temporary is extended just because of the expression `foo(...)`.
// The following is UB:
CString x = fmt::format("test");
foo(x);
Ideally, the log function should take perfectly forwarded parameters and bind them to something that is not temporary. |
|
+1 on the CString stuff, but I would prefer avoiding |
At least, you know that |
|
ah yes, I mean
Well, unfortunately, the format specifiers are language-agnostic. I'd rather prefer an explicit length specifier |
Do we need it to be, though? The perfect forwarding function would act as an interim step that produces the final formatted string and calls the concrete, polymorphic log() function, which would do the actual logging. It should be good enough for mocking purposes. |
We could also embed the fmt::format() to the interim function, so the log calls would only specify a format string and arguments, if any: log(level::debug, "{} {}", arg1, arg2); |
Good point, I think that'd work really well! +1 from me for that approach! |
I might give that a stab on the next pulse -- I need to fiddle with the log() API to add Unicode support for Windows anyway. |
|
This MP adds log level to string unit test case to ensure all cases are covered.
The MP also includes the commits from #3944 to resolve cyclic dependency between the two branches causing a CI failure
[giuliazanchi] Fixed link to Multipass Discourse landing page
MULTI-1831