-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Improve unit testing (Part 1) #3380
Improve unit testing (Part 1) #3380
Conversation
|
|
0dbab35
to
04b4a29
Compare
3920370
to
ec60320
Compare
ec60320
to
40ba9e3
Compare
40ba9e3
to
2f11b10
Compare
2f11b10
to
674ca50
Compare
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
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.
Some first comments - I am not done yet reviewing cmake/test.cmake
and test/CMakeLists.txt
.
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.
Looks good to me.
Thanks! |
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_MACROS
is introduced which keeps some macros from being undefined inmacro_unscope.hpp
.A new CMake cache variable
JSON_TestStandards
is added to replace-DCMAKE_CXX_STANDARD=<version> -DCMAKE_CXX_STANDARD_REQUIRED=ON
.CMake 3.13 has been added to the
ci_cmake_flags
test.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.