phpExtensions.gnupg: fix flaky tests with upstream patches

Replace the local `missing-new-line-test.patch` with two upstream commits:

- 4b9160b: fixes `--TEST--n` typos in 7 test files that caused the PHP
  test runner to report them as BORKED
- 6eda368: fixes clearsign test expectations to accept both with and
  without trailing newline, handling FreePG-patched GnuPG

https://github.com/php-gnupg/php-gnupg/issues/62
This commit is contained in:
Piotr Kwiecinski
2026-03-15 13:10:18 +01:00
parent e3e8d0f0c8
commit 198d6043fa
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";