Commit a1318763 authored by Mathieu Rene's avatar Mathieu Rene
Browse files

protobuf_29: fix darwin tests that would fail due to the temporary

directory being deleted by a forked child process created by death
tests.

- Backports a commit from a future protobuf version which uses a different
temporary directory for each test process.

- Sets the death test mode to "threadsafe", causing gtest to fork and
exec instead of just forking, making it create a new temporary directory
for this specific test.
parent 56781882
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
@@ -42,13 +42,22 @@ stdenv.mkDerivation (finalAttrs: {
      --replace-fail 'tmpnam(b)' '"'$TMPDIR'/foo"'
  '';

  patches = lib.optionals (lib.versionOlder version "22") [
  patches =
    lib.optionals (lib.versionOlder version "22") [
      # fix protobuf-targets.cmake installation paths, and allow for CMAKE_INSTALL_LIBDIR to be absolute
      # https://github.com/protocolbuffers/protobuf/pull/10090
      (fetchpatch {
        url = "https://github.com/protocolbuffers/protobuf/commit/a7324f88e92bc16b57f3683403b6c993bf68070b.patch";
        hash = "sha256-SmwaUjOjjZulg/wgNmR/F5b8rhYA2wkKAjHIOxjcQdQ=";
      })
    ]
    ++ lib.optionals (lib.versions.major version == "29") [
      # fix temporary directory handling to avoid test failures on darwin
      # https://github.com/NixOS/nixpkgs/issues/464439
      (fetchpatch {
        url = "https://github.com/protocolbuffers/protobuf/commit/0e9d0f6e77280b7a597ebe8361156d6bb1971dca.patch";
        hash = "sha256-rIP+Ft/SWVwh9Oy8y8GSUBgP6CtLCLvGmr6nOqmyHhY=";
      })
    ];

  # hook to provide the path to protoc executable, used at build time
@@ -100,6 +109,10 @@ stdenv.mkDerivation (finalAttrs: {
  versionCheckProgramArg = "--version";
  doInstallCheck = true;

  env = lib.optionalAttrs (lib.versions.major version == "29") {
    GTEST_DEATH_TEST_STYLE = "threadsafe";
  };

  passthru = {
    tests = {
      pythonProtobuf = python3.pkgs.protobuf;