1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

tests: Fix spawn with #:environment on MacOS.

MacOS adds __CF_USER_TEXT_ENCODING to every program, in similar way GNU
Hurd prepends LD_ORIGIN_PATH (based on the comment).  So extend the
logic to do similar stripping on MacOS.

* test-suite/tests/posix.test ("spawn")
["env with #:environment and #:output"]: Strip trailing
__CF_USER_TEXT_ENCODING environment variable when on Darwin.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Tomas Volf 2024-08-10 00:54:32 +02:00 committed by Ludovic Courtès
parent 8579b73aba
commit 1746dbbe4d
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -442,12 +442,23 @@
(close-port (car input+output)) (close-port (car input+output))
(waitpid pid) (waitpid pid)
;; On GNU/Hurd, the exec server prepends 'LD_ORIGIN_PATH' for (let ((sysname (utsname:sysname (uname))))
;; every program: <https://bugs.gnu.org/62501>. Strip it. (cond
(if (and (string=? "GNU" (utsname:sysname (uname))) ((string=? "GNU" sysname)
(string-prefix? "LD_ORIGIN_PATH=" str)) ;; On GNU/Hurd, the exec server prepends 'LD_ORIGIN_PATH' for
(string-drop str (+ 1 (string-index str #\newline))) ;; every program: <https://bugs.gnu.org/62501>. Strip it.
str)))) (if (string-prefix? "LD_ORIGIN_PATH=" str)
(string-drop str (+ 1 (string-index str #\newline)))
str))
((string-ci=? "darwin" sysname)
;; MacOS appends '__CF_USER_TEXT_ENCODING' for every program. Strip
;; it.
(let ((pos (string-contains str "__CF_USER_TEXT_ENCODING=")))
(if pos
(string-drop-right str (- (string-length str) pos))
str)))
(else
str))))))
(pass-if-equal "ls /proc/self/fd" (pass-if-equal "ls /proc/self/fd"
"0\n1\n2\n3\n" ;fourth FD is for /proc/self/fd "0\n1\n2\n3\n" ;fourth FD is for /proc/self/fd