Subject: bug#71980: closed (Re: bug#71980: [3.0.10] posix.test uses depcrecated tmpnam)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 20 Oct 2024 19:28:03 +0000

Your bug report

#71980: [3.0.10] posix.test uses depcrecated tmpnam

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
71980: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71980
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#71980: [3.0.10] posix.test uses depcrecated tmpnam
From: Ludovic Courtès <[email-masked]>
To: Tomas Volf <[email-masked]>
Cc: [email-masked], Matt Wette <[email-masked]>
Date: Sun, 20 Oct 2024 21:26:38 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Tomas Volf <[email-masked]> skribis:

> On 2024-07-07 09:27:14 -0700, Matt Wette wrote:
>> With `--disable-tmpnam'  argument to configure, posix.test fails: missing
>> `tmpnam`.
>>
>> patch attached
>
> There also is #71796 as a possible patch (since June 27th), which is arguably
> bit smaller (albeit I am biased since I am the author over there ^_^ ).

Yes, I’ve just pushed it as ff256c356be9327c24a2d7fc0f007722422e6604.

Thanks,
Ludo’.

Subject: [3.0.10] posix.test uses depcrecated tmpnam
From: Matt Wette <[email-masked]>
To: [email-masked]
Date: Sun, 7 Jul 2024 09:27:14 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

With `--disable-tmpnam'  argument to configure, posix.test fails: 
missing `tmpnam`.

patch attached

--- test-suite/tests/posix.test-orig    2024-07-03 15:45:16.352132881 -0700
+++ test-suite/tests/posix.test    2024-07-07 09:21:53.342855356 -0700
@@ -361,20 +361,21 @@
        (status:exit-val (system* "something-that-does-not-exist"))))

    (pass-if-equal "https://bugs.gnu.org/52835"
-      "bong\n"
-    (let ((file (tmpnam)))
+    "bong\n"
+    (let ((port (mkstemp "T-XXXXXX")))
        ;; Redirect stdout and stderr to FILE.
        (define status
-        (call-with-output-file file
-          (lambda (port)
-            (with-output-to-port port
+        (with-output-to-port port
+          (lambda ()
+            (with-error-to-port port
                (lambda ()
-                (with-error-to-port port
-                  (lambda ()
-                    (system* "sh" "-c" "echo bong >&2"))))))))
+                (system* "sh" "-c" "echo bong >&2"))))))

        (and (zero? (status:exit-val status))
-           (call-with-input-file file get-string-all))))
+           (zero? (seek port 0 SEEK_SET))
+           (let ((contents (get-string-all port)))
+             (close-port port)
+             contents))))

    (pass-if-equal "https://bugs.gnu.org/63024"
        0
--- test-suite/tests/posix.test-orig	2024-07-03 15:45:16.352132881 -0700
+++ test-suite/tests/posix.test	2024-07-07 09:21:53.342855356 -0700
@@ -361,20 +361,21 @@
       (status:exit-val (system* "something-that-does-not-exist"))))
 
   (pass-if-equal "https://bugs.gnu.org/52835"
-      "bong\n"
-    (let ((file (tmpnam)))
+    "bong\n"
+    (let ((port (mkstemp "T-XXXXXX")))
       ;; Redirect stdout and stderr to FILE.
       (define status
-        (call-with-output-file file
-          (lambda (port)
-            (with-output-to-port port
+        (with-output-to-port port
+          (lambda ()
+            (with-error-to-port port
               (lambda ()
-                (with-error-to-port port
-                  (lambda ()
-                    (system* "sh" "-c" "echo bong >&2"))))))))
+                (system* "sh" "-c" "echo bong >&2"))))))
 
       (and (zero? (status:exit-val status))
-           (call-with-input-file file get-string-all))))
+           (zero? (seek port 0 SEEK_SET))
+           (let ((contents (get-string-all port)))
+             (close-port port)
+             contents))))
 
   (pass-if-equal "https://bugs.gnu.org/63024"
       0