Re-Enable fmt module tests, update module-test.cc#4702
Re-Enable fmt module tests, update module-test.cc#4702MathewBensonCode wants to merge 1 commit intofmtlib:masterfrom
Conversation
12b77b8 to
789a28f
Compare
|
@vitaut, what is the scope of testing that we require for testing the module target? Do we just want to test the public API or the full API? The tests for the regular library involve tests for the entire library as they are able to reach into the entire code base. With the module based library, it brings up the issue of visible and invisible APIs. In this pull request, Ideally I have just remove the "inner" code(and some outdated code), which is being tested by the regular library anyway, and just test that the expected public functionality works. I have commented out the bits that would be deleted if we we're to take this approach. The other approach would be to work out how to work with modules and macro based testing frameworks. I'm doing some experiments with this, but it may need another pull request as the changes are likely to be drastic, like moving tests into headers, or making the tests part of the module, etc. |
|
We definitely don't need to test everything. A simple sanity test that exercises a small subset of the API should be sufficient. I would recommend splitting the changes into smaller PRs, e.g. focusing on one compiler (e.g. clang) first. |
|
That said, we shouldn't delete code from the module test if it is broken with modules. On the contrary - we should keep it as a regression test for the fix. It is OK to conditionally compile it until the fix is available. |
789a28f to
8241bd6
Compare
|
After further investigation, I have identified that the wide string versions of most tests in I have just commented them out with explanations in the comments, however, these may be candidates for removal as I observed that they we're not present in the other Compiler Specific testing does not appear to be an issue in this case. The module-test.cc file was well written to only deal with module tests so likely just needed to be updated. module-test run visible here: https://github.com/fmtlib/fmt/actions/runs/22850169158/job/66276473337?pr=4702#step:7:1404 |
8241bd6 to
b11dc45
Compare
vitaut
left a comment
There was a problem hiding this comment.
Please apply cmake-format and revert unrelated changes.
6f6bce7 to
9acd195
Compare
| set(libs test-main fmt-module) | ||
| else () | ||
| set(libs test-main fmt) | ||
| set(libs test-main) |
There was a problem hiding this comment.
fmt is removed here because it is already included in the test-main target
test/CMakeLists.txt
Outdated
| if (MSVC) | ||
| target_compile_options(module-test PRIVATE /utf-8 /Zc:__cplusplus | ||
| /Zc:externConstexpr /Zc:inline) | ||
| endif () |
There was a problem hiding this comment.
/utf-8 should be inherited from the fmt target and shouldn't be added here. What are the other options for?
|
|
||
| namespace detail { | ||
| bool oops_detail_namespace_is_visible; | ||
| #ifndef _WIN32 //windows msvc has issue with nested namespace |
There was a problem hiding this comment.
Let's disable modules on MSVC for now instead of adding these hacks.
There was a problem hiding this comment.
I had taken inspiration from here
Lines 509 to 520 in 4968433
I think it is better to isolate the one area with an issue and have the rest of the tests active.
Could there perhaps be a more acceptable way of doing this? I chose to use comments, but we could also use the print message stating that the test is disabled
| int n = 42; | ||
| fmt::basic_format_args<fmt::format_context> args = fmt::make_format_args(n); |
There was a problem hiding this comment.
When using fmt::make_format_args(42) as it was before, there was an error stating that a suitable function couldn't be found.
Upon investigation I found that the tests we're written to use an lvalue, for example
Lines 332 to 333 in 4968433
So I used the same pattern everywhere that the fmt::make_format_args() was used in the module-test.cc and the issue went away.
It appears that there was a change and since the module-test.cc wasn't being actively used it fell behind
- Refactor test/CMakeLists.txt to enable testing for modules
- The tests in `module-test.cc` seem to not have been updated in some
time despite changes in the main library.
- Wide String versions of several tests appear to be deprecated so have
been commented out.
- Refactored tests related to `fmt::format_args` that now requires lvalue
references as opposed to direct values.
These include:
- testing for the fmt::detail namespace. The MSVC github workflow could
not differentiate the between the fmt::detail and fmt::v12::detail
and stderr. an exception was being thrown
- Several tests for items that have since been removed from the
library like `fmt::is_char` and `fmt::localtime` as far as I can
tell
9acd195 to
acc41f6
Compare
module-test.ccseem to not have been updated in some time despite changes in the main library.fmt::format_argsthat now requires lvalue references as opposed to direct values.fmt::is_charandfmt::localtimeas far as I can tellShould close #4698