Improve unit testing (Part 1)#3380
Merged
nlohmann merged 12 commits intonlohmann:developfrom Mar 24, 2022
Merged
Conversation
Contributor
Author
|
|
Contributor
Author
|
|
0dbab35 to
04b4a29
Compare
3920370 to
ec60320
Compare
ec60320 to
40ba9e3
Compare
2 tasks
40ba9e3 to
2f11b10
Compare
2f11b10 to
674ca50
Compare
gregmarr
reviewed
Mar 10, 2022
674ca50 to
6f92c1b
Compare
6f92c1b to
6595402
Compare
Add functions for creating tests and to supply test- and
standard-specific build settings.
Raises minimum CMake version to 3.13 in test directory.
json_test_add_test_for(
<file>
MAIN <main>
[CXX_STANDARDS <version_number>...] [FORCE])
Given a <file> unit-foo.cpp, produces
test-foo_cpp<version_number>
if C++ standard <version_number> is supported by the compiler and
thesource file contains JSON_HAS_CPP_<version_number>. Use FORCE to
create the test regardless of the file containing
JSON_HAS_CPP_<version_number>. Test targets are linked against <main>.
CXX_STANDARDS defaults to "11".
json_test_set_test_options(
all|<tests>
[CXX_STANDARDS all|<args>...]
[COMPILE_DEFINITIONS <args>...]
[COMPILE_FEATURES <args>...]
[COMPILE_OPTIONS <args>...]
[LINK_LIBRARIES <args>...]
[LINK_OPTIONS <args>...])
Supply test- and standard-specific build settings.
Specify multiple tests using a list e.g., "test-foo;test-bar".
Must be called BEFORE the test is created.
Incidentally enables the regression tests for nlohmann#2546 and nlohmann#3070. A CHECK_THROWS_WITH_AS in nlohmann#3070 was disabled which is tracked in nlohmann#3377 and a line in from_json(..., std_fs::path&) was marked with LCOV_EXCL_LINE.
Redelcaration of inline constexpr static data members in namespace scope was deprecated in C++17. Fixes -Werror=deprecated compilation failures.
Also change default for JSON_BuildTests option to depend on CMake version.
5bc2beb to
3419363
Compare
nlohmann
reviewed
Mar 14, 2022
Owner
nlohmann
left a comment
There was a problem hiding this comment.
Some first comments - I am not done yet reviewing cmake/test.cmake and test/CMakeLists.txt.
Owner
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refactors the CMake code for creating unit tests (see commit message cac4e9f).
It also removes duplicate macro definitions from unit tests and reuses the ones provided by
json.hpp(see commit message 02138cf). To that end the macroJSON_TEST_KEEP_MACROSis introduced which keeps some macros from being undefined inmacro_unscope.hpp.A new CMake cache variable
JSON_TestStandardsis added to replace-DCMAKE_CXX_STANDARD=<version> -DCMAKE_CXX_STANDARD_REQUIRED=ON.CMake 3.13 has been added to the
ci_cmake_flagstest.Various compilation issues have been fixed. (These could be moved into a separate PR, if desired.)
As described in #3384, some tests had to be disabled. These failures are not caused by this PR but uncovered, since it enables some previously untested configurations.
Documentation may need updating.