unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Matt Wette <matt.wette@gmail.com>
To: 71980@debbugs.gnu.org
Subject: bug#71980: [3.0.10] posix.test uses depcrecated tmpnam
Date: Sun, 7 Jul 2024 09:27:14 -0700	[thread overview]
Message-ID: <cb7271f9-96d5-415c-bac7-c5963d411bd5@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1537 bytes --]

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

[-- Attachment #2: PATCH --]
[-- Type: text/plain, Size: 1181 bytes --]

--- 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

             reply	other threads:[~2024-07-07 16:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-07 16:27 Matt Wette [this message]
2024-07-07 16:46 ` bug#71980: [3.0.10] posix.test uses depcrecated tmpnam Tomas Volf
2024-07-07 17:00 ` bug#71980: tmpnam Matt Wette
2024-07-07 17:06 ` bug#71980: close Matt Wette
2024-07-07 17:12 ` bug#71980: close 71980 Matt Wette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb7271f9-96d5-415c-bac7-c5963d411bd5@gmail.com \
    --to=matt.wette@gmail.com \
    --cc=71980@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).