rapidjson-unstable: rewrite and fix tests

Some valgrind tests do not pass, see https://github.com/Tencent/rapidjson/issues/2214

Madoura b280deae b5dce721

+120 -17
+35
pkgs/development/libraries/rapidjson/0000-unstable-use-nixpkgs-gtest.patch
··· 1 + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt 2 + index 11c1b04c..762eaa75 100644 3 + --- a/test/CMakeLists.txt 4 + +++ b/test/CMakeLists.txt 5 + @@ -1,20 +1,14 @@ 6 + -find_package(GTestSrc) 7 + +enable_testing() 8 + 9 + -IF(GTESTSRC_FOUND) 10 + - enable_testing() 11 + +if (WIN32 AND (NOT CYGWIN) AND (NOT MINGW)) 12 + + set(gtest_disable_pthreads ON) 13 + + set(gtest_force_shared_crt ON) 14 + +endif() 15 + 16 + - if (WIN32 AND (NOT CYGWIN) AND (NOT MINGW)) 17 + - set(gtest_disable_pthreads ON) 18 + - set(gtest_force_shared_crt ON) 19 + - endif() 20 + +include_directories(SYSTEM ${GTEST_INCLUDE_DIR}) 21 + 22 + - add_subdirectory(${GTEST_SOURCE_DIR} ${CMAKE_BINARY_DIR}/googletest) 23 + - include_directories(SYSTEM ${GTEST_INCLUDE_DIR}) 24 + +set(TEST_LIBRARIES gtest gtest_main) 25 + 26 + - set(TEST_LIBRARIES gtest gtest_main) 27 + - 28 + - add_custom_target(tests ALL) 29 + - add_subdirectory(perftest) 30 + - add_subdirectory(unittest) 31 + - 32 + -ENDIF(GTESTSRC_FOUND) 33 + +add_custom_target(tests ALL) 34 + +add_subdirectory(perftest) 35 + +add_subdirectory(unittest)
+36
pkgs/development/libraries/rapidjson/0001-unstable-valgrind-suppress-failures.patch
··· 1 + diff --git a/test/valgrind.supp b/test/valgrind.supp 2 + index c9d3d226..63af7bf9 100644 3 + --- a/test/valgrind.supp 4 + +++ b/test/valgrind.supp 5 + @@ -24,3 +24,31 @@ 6 + fun:*Uri*Parse_UTF16_Std* 7 + } 8 + 9 + +{ 10 + + Suppress memcpy_chk valgrind report 5 11 + + Memcheck:Overlap 12 + + fun:__memcpy_chk 13 + + fun:*dtoa_normal* 14 + +} 15 + + 16 + +{ 17 + + Suppress memcpy_chk valgrind report 6 18 + + Memcheck:Overlap 19 + + fun:__memcpy_chk 20 + + fun:*dtoa_maxDecimalPlaces* 21 + +} 22 + + 23 + +{ 24 + + Suppress memcpy_chk valgrind report 7 25 + + Memcheck:Overlap 26 + + fun:__memcpy_chk 27 + + ... 28 + + fun:*Reader*ParseDoubleHandler* 29 + +} 30 + + 31 + +{ 32 + + Suppress memcpy_chk valgrind report 8 33 + + Memcheck:Overlap 34 + + fun:__memcpy_chk 35 + + fun:*Reader*ParseNumber_NormalPrecisionError* 36 + +}
+49 -17
pkgs/development/libraries/rapidjson/unstable.nix
··· 1 1 { lib 2 2 , stdenv 3 3 , fetchFromGitHub 4 - , fetchpatch 5 - , pkg-config 6 4 , cmake 5 + , doxygen 6 + , graphviz 7 7 , gtest 8 8 , valgrind 9 + # One of "11" or "17"; default in source is CXX 11 10 + , cxxStandard ? "11" 11 + , buildDocs ? true 12 + , buildTests ? !stdenv.hostPlatform.isStatic && !stdenv.isDarwin 13 + , buildExamples ? true 9 14 }: 10 15 11 - stdenv.mkDerivation rec { 16 + stdenv.mkDerivation (finalAttrs: { 12 17 pname = "rapidjson"; 13 18 version = "unstable-2023-09-28"; 14 19 20 + outputs = [ 21 + "out" 22 + ] ++ lib.optionals buildDocs [ 23 + "doc" 24 + ] ++ lib.optionals buildExamples [ 25 + "example" 26 + ]; 27 + 15 28 src = fetchFromGitHub { 16 29 owner = "Tencent"; 17 30 repo = "rapidjson"; 18 31 rev = "f9d53419e912910fd8fa57d5705fa41425428c35"; 19 32 hash = "sha256-rl7iy14jn1K2I5U2DrcZnoTQVEGEDKlxmdaOCF/3hfY="; 20 33 }; 34 + 35 + patches = lib.optionals buildTests [ 36 + ./0000-unstable-use-nixpkgs-gtest.patch 37 + # https://github.com/Tencent/rapidjson/issues/2214 38 + ./0001-unstable-valgrind-suppress-failures.patch 39 + ]; 21 40 22 41 nativeBuildInputs = [ 23 - pkg-config 24 42 cmake 43 + ] ++ lib.optionals buildDocs [ 44 + doxygen 45 + graphviz 25 46 ]; 26 47 27 - patches = [ 28 - (fetchpatch { 29 - name = "do-not-include-gtest-src-dir.patch"; 30 - url = "https://git.alpinelinux.org/aports/plain/community/rapidjson/do-not-include-gtest-src-dir.patch?id=9e5eefc7a5fcf5938a8dc8a3be8c75e9e6809909"; 31 - hash = "sha256-BjSZEwfCXA/9V+kxQ/2JPWbc26jQn35CfN8+8NW24s4="; 32 - }) 48 + cmakeFlags = [ 49 + (lib.cmakeBool "RAPIDJSON_BUILD_DOC" buildDocs) 50 + (lib.cmakeBool "RAPIDJSON_BUILD_TESTS" buildTests) 51 + (lib.cmakeBool "RAPIDJSON_BUILD_EXAMPLES" buildExamples) 52 + (lib.cmakeBool "RAPIDJSON_BUILD_CXX11" (cxxStandard == "11")) 53 + (lib.cmakeBool "RAPIDJSON_BUILD_CXX17" (cxxStandard == "17")) 54 + ] ++ lib.optionals buildTests [ 55 + (lib.cmakeFeature "GTEST_INCLUDE_DIR" "${lib.getDev gtest}") 56 + ]; 57 + 58 + doCheck = buildTests; 59 + 60 + nativeCheckInputs = [ 61 + gtest 62 + valgrind 33 63 ]; 34 64 35 - # for tests, adding gtest to checkInputs does not work 36 - # https://github.com/NixOS/nixpkgs/pull/212200 37 - buildInputs = [ gtest ]; 38 - cmakeFlags = [ "-DGTEST_SOURCE_DIR=${gtest.dev}/include" ]; 65 + postInstall = lib.optionalString buildExamples '' 66 + mkdir -p $example/bin 39 67 40 - nativeCheckInputs = [ valgrind ]; 41 - doCheck = !stdenv.hostPlatform.isStatic && !stdenv.isDarwin; 68 + find bin -type f -executable \ 69 + -not -name "perftest" \ 70 + -not -name "unittest" \ 71 + -exec cp -a {} $example/bin \; 72 + ''; 42 73 43 74 meta = with lib; { 44 75 description = "Fast JSON parser/generator for C++ with both SAX/DOM style API"; ··· 46 77 license = licenses.mit; 47 78 platforms = platforms.unix; 48 79 maintainers = with maintainers; [ Madouura ]; 80 + broken = (cxxStandard != "11" && cxxStandard != "17"); 49 81 }; 50 - } 82 + })