From 73a8ca88fba38beb2ddeeca3317696d5a7eb706c Mon Sep 17 00:00:00 2001 From: Michael Gran Date: Fri, 2 Jun 2023 18:57:06 -0700 Subject: [PATCH] ports.test: catch pipe errors Refactors a couple of the ports tests to catch errors in the test runner, so that the test suite will print ERROR on failure. * test-suite/tests/ports.test (pipe:write, pipe:read): modified --- test-suite/tests/ports.test | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test index bec5e356c..82881aa28 100644 --- a/test-suite/tests/ports.test +++ b/test-suite/tests/ports.test @@ -2,7 +2,7 @@ ;;;; Jim Blandy --- May 1999 ;;;; ;;;; Copyright (C) 1999, 2001, 2004, 2006-2007, 2009-2015, 2017, 2019-2021, -;;;; 2024 Free Software Foundation, Inc. +;;;; 2024,2025 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -736,22 +736,23 @@ ;;;; Pipe (popen) ports. ;;; Run a command, and read its output. -(let* ((pipe (open-pipe "echo 'Howdy there, partner!'" "r")) - (in-string (read-all pipe))) - (close-pipe pipe) - (pass-if "pipe: read" - (equal? in-string "Howdy there, partner!\n"))) +(pass-if "pipe: read" + (let* ((pipe (open-pipe "echo 'Howdy there, partner!'" "r")) + (in-string (read-all pipe))) + (close-pipe pipe) + (equal? in-string "Howdy there, partner!\n"))) + ;;; Run a command, send some output to it, and see if it worked. -(let* ((filename (test-file)) - (pipe (open-pipe (string-append "grep Mommy > " filename) "w"))) - (display "Now Jimmy lives on a mushroom cloud\n" pipe) - (display "Mommy, why does everybody have a bomb?\n" pipe) - (close-pipe pipe) - (let ((in-string (read-file filename))) - (pass-if "pipe: write" - (equal? in-string "Mommy, why does everybody have a bomb?\n"))) - (delete-file filename)) +(pass-if "pipe: write" + (let* ((filename (test-file)) + (pipe (open-pipe (string-append "grep Mommy > " filename) "w"))) + (display "Now Jimmy lives on a mushroom cloud\n" pipe) + (display "Mommy, why does everybody have a bomb?\n" pipe) + (close-pipe pipe) + (let ((in-string (read-file filename))) + (delete-file filename) + (equal? in-string "Mommy, why does everybody have a bomb?\n")))) (pass-if-equal "pipe, fdopen, and line buffering" "foo\nbar\n"