From ec43d27f9fec220c7b01b27619a84cb75f6b3d55 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Mon, 22 Apr 2019 08:15:53 +0430 Subject: [PATCH 1/9] Add Debug builds for AppVeyor --- appveyor.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 0dfc34e96..9ecbabed1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,28 @@ version: '{build}' environment: matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Debug + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + GENERATOR: Visual Studio 14 2015 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Debug + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + GENERATOR: Visual Studio 15 2017 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Debug + COMPILER: mingw + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + GENERATOR: Ninja + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 COMPILER: mingw platform: x86 @@ -48,6 +70,8 @@ environment: init: - cmake --version - msbuild /version + # set the default build configuration to Release + - if "%configuration%"=="" (set configuration="Release") install: - if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip @@ -57,10 +81,10 @@ install: - if "%COMPILER%"=="mingw" g++ --version before_build: - - cmake . -G "%GENERATOR%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" + - cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" build_script: - - cmake --build . --config Release + - cmake --build . --config "%configuration%" test_script: - - ctest -C Release -V -j + - ctest -C "%configuration%" -V -j From 4ac0fe262807e2ee86216bf7449626db921bcfb3 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Mon, 22 Apr 2019 08:16:10 +0430 Subject: [PATCH 2/9] Increase timeout of test-unicode_all in Debug build --- test/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b73dfc9ad..8b1809dd7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,6 +133,12 @@ foreach(file ${files}) ) set_tests_properties("${testcase}_all" PROPERTIES LABELS "all") + # Increase timeout for test-unicode_all on Debug build + string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) + if (("${testcase}" STREQUAL "test-unicode") AND (uppercase_CMAKE_BUILD_TYPE STREQUAL DEBUG)) + set_tests_properties("${testcase}_all" PROPERTIES TIMEOUT 3600) + endif() + if(JSON_Valgrind) add_test(NAME "${testcase}_valgrind" COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase} ${DOCTEST_TEST_FILTER} From d28b4b900e47f0d5144182d16097dfd035a4203a Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Tue, 21 May 2019 17:26:30 +0430 Subject: [PATCH 3/9] Add a separate build with Windows.h included --- appveyor.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 9ecbabed1..038d282dc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -37,6 +37,13 @@ environment: LINKER_FLAGS: "" GENERATOR: Visual Studio 14 2015 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + platform: x86 + name: with_win_header + CXX_FLAGS: "" + LINKER_FLAGS: "" + GENERATOR: Visual Studio 14 2015 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 platform: x86 CXX_FLAGS: "" @@ -81,6 +88,9 @@ install: - if "%COMPILER%"=="mingw" g++ --version before_build: + # for with_win_header build, inject the inclusion of Windows.h to the single-header library + - ps: if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" } + - ps: if ($env:name -Eq "with_win_header") { "#include `n" + (Get-Content $header_path | Out-String) | Set-Content $header_path } - cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" build_script: From 798e83a038ed7b0ae048ee508e7aaf0cfb62ceba Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Fri, 21 Jun 2019 23:16:42 +0430 Subject: [PATCH 4/9] Workaround msvc2015 bug with explicit copy-constructor for const_iterator --- include/nlohmann/detail/iterators/iter_impl.hpp | 7 +++++++ single_include/nlohmann/json.hpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index 0b0282c29..8492c2346 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -118,6 +118,13 @@ class iter_impl to iterator is not defined. */ + /* We had to explicitly define the copy constructor for the const + case to circumvent a bug on msvc 2015 debug build. + More info: https://github.com/nlohmann/json/issues/1608 + */ + iter_impl(const iter_impl& other) noexcept + : m_object(other.m_object), m_it(other.m_it) {} + /*! @brief converting constructor @param[in] other non-const iterator to copy from diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index bb2dacbc2..c652b35a0 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -7821,6 +7821,13 @@ class iter_impl to iterator is not defined. */ + /* We had to explicitly define the copy constructor for the const + case to circumvent a bug on msvc 2015 debug build. + More info: https://github.com/nlohmann/json/issues/1608 + */ + iter_impl(const iter_impl& other) noexcept + : m_object(other.m_object), m_it(other.m_it) {} + /*! @brief converting constructor @param[in] other non-const iterator to copy from From eba8244ead0e0beb50bed694d2d2eea432e09234 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Sat, 22 Jun 2019 02:33:13 +0430 Subject: [PATCH 5/9] Avoid collision of ::max with windows.h macro --- test/src/unit-concepts.cpp | 4 ++-- test/src/unit-regression.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/src/unit-concepts.cpp b/test/src/unit-concepts.cpp index 9649af407..f28f04324 100644 --- a/test/src/unit-concepts.cpp +++ b/test/src/unit-concepts.cpp @@ -73,8 +73,8 @@ TEST_CASE("concepts") // X::size_type must return an unsigned integer CHECK((std::is_unsigned::value)); // X::size_type can represent any non-negative value of X::difference_type - CHECK(static_cast(std::numeric_limits::max()) <= - std::numeric_limits::max()); + CHECK(static_cast((std::numeric_limits::max)()) <= + (std::numeric_limits::max)()); // the expression "X u" has the post-condition "u.empty()" { diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 6b7d90aa9..88b12114d 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -719,7 +719,7 @@ TEST_CASE("regression tests") }; check_roundtrip(100000000000.1236); - check_roundtrip(std::numeric_limits::max()); + check_roundtrip((std::numeric_limits::max)()); // Some more numbers which fail to roundtrip when serialized with digits10 significand digits (instead of max_digits10) check_roundtrip(1.541888611948064e-17); From f559142008291e1b6e9a6d028b6ce076b90a4197 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Sat, 22 Jun 2019 20:48:02 +0430 Subject: [PATCH 6/9] Appveyor: Set build mode explicitly --- appveyor.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 038d282dc..aa5bb339b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,6 +25,7 @@ environment: GENERATOR: Ninja - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release COMPILER: mingw platform: x86 CXX_FLAGS: "" @@ -32,12 +33,14 @@ environment: GENERATOR: Ninja - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release platform: x86 CXX_FLAGS: "" LINKER_FLAGS: "" GENERATOR: Visual Studio 14 2015 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release platform: x86 name: with_win_header CXX_FLAGS: "" @@ -45,30 +48,35 @@ environment: GENERATOR: Visual Studio 14 2015 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release platform: x86 CXX_FLAGS: "" LINKER_FLAGS: "" GENERATOR: Visual Studio 15 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release platform: x86 CXX_FLAGS: "/permissive- /std:c++latest /utf-8" LINKER_FLAGS: "" GENERATOR: Visual Studio 15 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release platform: x64 CXX_FLAGS: "" LINKER_FLAGS: "" GENERATOR: Visual Studio 14 2015 Win64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release platform: x64 CXX_FLAGS: "" LINKER_FLAGS: "" GENERATOR: Visual Studio 15 2017 Win64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release platform: x64 CXX_FLAGS: "/permissive- /std:c++latest /utf-8 /F4000000" LINKER_FLAGS: "/STACK:4000000" @@ -77,8 +85,6 @@ environment: init: - cmake --version - msbuild /version - # set the default build configuration to Release - - if "%configuration%"=="" (set configuration="Release") install: - if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip From 0a137b78ac4ebde994e68e2edc1380fe65bf0c75 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Sat, 22 Jun 2019 21:05:15 +0430 Subject: [PATCH 7/9] Appveyor: Set timeout of unit-tests in appveyor.yml instead of CMake --- appveyor.yml | 4 +++- test/CMakeLists.txt | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index aa5bb339b..ae8dbfa97 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -103,4 +103,6 @@ build_script: - cmake --build . --config "%configuration%" test_script: - - ctest -C "%configuration%" -V -j + # Set 1 hour timeout to avoid the occasional + # timeouts on test-unicode_all + - ctest --timeout 3600 -C "%configuration%" -V -j diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8b1809dd7..b73dfc9ad 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,12 +133,6 @@ foreach(file ${files}) ) set_tests_properties("${testcase}_all" PROPERTIES LABELS "all") - # Increase timeout for test-unicode_all on Debug build - string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) - if (("${testcase}" STREQUAL "test-unicode") AND (uppercase_CMAKE_BUILD_TYPE STREQUAL DEBUG)) - set_tests_properties("${testcase}_all" PROPERTIES TIMEOUT 3600) - endif() - if(JSON_Valgrind) add_test(NAME "${testcase}_valgrind" COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase} ${DOCTEST_TEST_FILTER} From 3db14cbfae858707b31419877d37be46bcbd95a3 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Mon, 24 Jun 2019 15:40:01 +0430 Subject: [PATCH 8/9] :memo: Improve doc on const_inter constructor --- include/nlohmann/detail/iterators/iter_impl.hpp | 11 +++++++---- single_include/nlohmann/json.hpp | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index 8492c2346..bc87de29f 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -118,10 +118,13 @@ class iter_impl to iterator is not defined. */ - /* We had to explicitly define the copy constructor for the const - case to circumvent a bug on msvc 2015 debug build. - More info: https://github.com/nlohmann/json/issues/1608 - */ + /*! + @brief const copy constructor + @param[in] other const iterator to copy from + @note This copy constuctor had to be defined explicitely to circumvent a bug + occuring on msvc v19.0 compiler (VS 2015) debug build. For more + information refer to: https://github.com/nlohmann/json/issues/1608 + */ iter_impl(const iter_impl& other) noexcept : m_object(other.m_object), m_it(other.m_it) {} diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index c652b35a0..08c4fc641 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -7821,10 +7821,13 @@ class iter_impl to iterator is not defined. */ - /* We had to explicitly define the copy constructor for the const - case to circumvent a bug on msvc 2015 debug build. - More info: https://github.com/nlohmann/json/issues/1608 - */ + /*! + @brief const copy constructor + @param[in] other const iterator to copy from + @note This copy constuctor had to be defined explicitely to circumvent a bug + occuring on msvc v19.0 compiler (VS 2015) debug build. For more + information refer to: https://github.com/nlohmann/json/issues/1608 + */ iter_impl(const iter_impl& other) noexcept : m_object(other.m_object), m_it(other.m_it) {} From 5b2e2305a054a2ea3354a124bda467e5018b8ce6 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Mon, 24 Jun 2019 20:11:56 +0430 Subject: [PATCH 9/9] CI: Skip test-unit_all on MSVC Debug builds --- appveyor.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ae8dbfa97..0a92a6c9a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -103,6 +103,9 @@ build_script: - cmake --build . --config "%configuration%" test_script: - # Set 1 hour timeout to avoid the occasional - # timeouts on test-unicode_all - - ctest --timeout 3600 -C "%configuration%" -V -j + - if "%configuration%"=="Release" ctest -C "%configuration%" -V -j + # On Debug builds, skip test-unicode_all + # as it is extremely slow to run and cause + # occasional timeouts on AppVeyor. + # More info: https://github.com/nlohmann/json/pull/1570 + - if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode_all" -C "%configuration%" -V -j