From 76dbe8f9c96a7d5e46c7cf996cdc05d371419506 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 2 Nov 2026 17:47:21 +0100 Subject: [PATCH] Fix the red CI on develop: Visual Studio 2017 build of the BSON writer, Valgrind timeouts (#6009) * CI: give the Valgrind tests a timeout of one hour Under Valgrind, test-json_view_builder_cpp11 and test-ordered_json_cpp11 took 1435 s and 1390 s on develop (ddc34f5), close to ctest's default timeout of 1500 s. On the next run (b2674a4) the whole job was about 10 % slower and both timed out, failing ci_test_valgrind on develop and on every PR based on it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01N5NasAgbDGG28MqXjQvLqp Signed-off-by: Claude * BSON writer: drop the SFINAE guard that Visual Studio 2017 cannot deduce write_bson_document_single_pass() was a member template enabled by is_detected. MSVC 19.16 (Visual Studio 2017) fails to deduce it through the class-scope alias template (C2672, C2783) when it compiles to_bson() and to_bon8(), so every Visual Studio 2017 job on AppVeyor fails since #5979. The guard is not needed: as a non-template member of the class template, the function is only instantiated when called, and its only caller is the write_bson_document() overload for sinks that have written(), which already calls oa.written() and oa.rewind() itself. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01N5NasAgbDGG28MqXjQvLqp Signed-off-by: Claude --------- Signed-off-by: Claude Co-authored-by: Claude --- cmake/test.cmake | 4 +++- include/nlohmann/detail/output/binary_writer.hpp | 1 - single_include/nlohmann/json.hpp | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/test.cmake b/cmake/test.cmake index 5922c5106..9a42ac263 100644 --- a/cmake/test.cmake +++ b/cmake/test.cmake @@ -178,8 +178,10 @@ function(_json_test_add_test test_name file main cxx_standard) COMMAND ${memcheck_command} $ ${DOCTEST_TEST_FILTER} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) + # under Valgrind the slowest tests take close to 25 minutes, so ctest's + # default timeout of 1500 seconds leaves no headroom set_tests_properties(${test_target}_valgrind PROPERTIES - LABELS "valgrind" FIXTURES_REQUIRED TEST_DATA + LABELS "valgrind" FIXTURES_REQUIRED TEST_DATA TIMEOUT 3600 ) endif() endfunction() diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index 0c3c823ac..c9bdc696f 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -2422,7 +2422,6 @@ class binary_writer nothing large has been written then, and the caller writes the document in two passes, which reports that error */ - template::value, int>::type = 0> bool write_bson_document_single_pass(const BasicJsonType& document) { const std::size_t start = oa.written(); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 693320ed5..2a7289203 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -30394,7 +30394,6 @@ class binary_writer nothing large has been written then, and the caller writes the document in two passes, which reports that error */ - template::value, int>::type = 0> bool write_bson_document_single_pass(const BasicJsonType& document) { const std::size_t start = oa.written();