phpExtensions.gnupg: fix flaky tests with upstream patches (#500047)

This commit is contained in:
Pol Dellaiera
2026-03-15 15:08:17 +00:00
committed by GitHub
2 changed files with 15 additions and 29 deletions
@@ -6,6 +6,7 @@
gnupg,
php,
fetchFromGitHub,
fetchpatch,
}:
let
@@ -41,11 +42,24 @@ buildPecl {
substituteInPlace tests/gnupg_oo_init_file_name.phpt \
--replace-fail '/usr/bin/gpg' '${gnupg}/bin/gpg' \
--replace-fail 'string(12)' 'string(${toString (lib.stringLength "${gnupg}/bin/gpg")})'
# Suppress warnings from unlinking socket files that gpg-agent may have
# already removed during shutdown (TOCTOU race in cleanup code).
substituteInPlace tests/gnupgt.inc \
--replace-fail 'unlink(' '@unlink('
'';
patches = [
# https://github.com/php-gnupg/php-gnupg/issues/62
./missing-new-line-test.patch
(fetchpatch {
name = "fix-test-typos.patch";
url = "https://github.com/php-gnupg/php-gnupg/commit/4b9160b94df1d831d7bcc4f980cb8969d9ab5c11.patch";
hash = "sha256-fJ/H1tbwMuLUpdWe0+oPyzhBFAsjG2QzmZSiuIsMekY=";
})
(fetchpatch {
name = "fix-clearsign-newline-test.patch";
url = "https://github.com/php-gnupg/php-gnupg/commit/6eda368b55044343349a8e76f6beda3ad54660dc.patch";
hash = "sha256-/c+cxfAj3Cg7m2+sFiHWQr4R9atPypQuAUVyAOI8ZeM=";
})
];
doCheck = true;
@@ -1,28 +0,0 @@
diff --git a/tests/gnupg_oo_sign_clear.phpt b/tests/gnupg_oo_sign_clear.phpt
index 4f9b79c..05fda25 100644
--- a/tests/gnupg_oo_sign_clear.phpt
+++ b/tests/gnupg_oo_sign_clear.phpt
@@ -38,8 +38,7 @@ array(1) {
int(0)
}
}
-string(8) "foo bar
-"
+string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
diff --git a/tests/gnupg_res_sign_clear.phpt b/tests/gnupg_res_sign_clear.phpt
index 71dd6c2..74fd26d 100644
--- a/tests/gnupg_res_sign_clear.phpt
+++ b/tests/gnupg_res_sign_clear.phpt
@@ -36,8 +36,7 @@ array(1) {
int(0)
}
}
-string(8) "foo bar
-"
+string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";