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.

(cherry picked from commit a1318763c2)
This commit is contained in:
Mathieu Rene
2025-11-26 14:00:24 -05:00
committed by github-actions[bot]
parent a65c5584e4
commit c6c6a3fc6e

View File

@@ -42,14 +42,23 @@ stdenv.mkDerivation (finalAttrs: {
--replace-fail 'tmpnam(b)' '"'$TMPDIR'/foo"'
'';
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=";
})
];
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
build_protobuf =
@@ -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;