]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: support getting `diag_' message from stdin
authorRichard Hansen <rhansen@rhansen.org>
Mon, 3 Feb 2025 23:26:54 +0000 (18:26 -0500)
committerKarl Berry <karl@freefriends.org>
Sun, 23 Feb 2025 01:36:59 +0000 (17:36 -0800)
* t/ax/tap-functions.sh (diag_): Read the diagnostic message from
stdin if no arguments are given.

t/ax/tap-functions.sh

index a458b773e8f1230a545fc75ae82493a8b57524e6..3e0cb50febdf7f5d8b2d7f28669c57f7112f359c 100644 (file)
@@ -69,18 +69,17 @@ planned_=none
 
 # diag_ [EXPLANATION]
 # ------------------
-# Report the given text as TAP diagnostic.  Assumes the string denoting
-# TAP diagnostic lines is stored in the '$diag_string_' variable; this is
-# done to allow better interplay with TAP drivers that allow such a string
-# to be configured.
+# Report the given text, or stdin if no arguments, as TAP diagnostic.
+# Assumes the string denoting TAP diagnostic lines is stored in the
+# '$diag_string_' variable; this is done to allow better interplay
+# with TAP drivers that allow such a string to be configured.
 diag_ ()
 (
   set +x
-  test $# -eq 0 || while IFS= read -r line; do
+  test $# -eq 0 || { printf %s\\n "$*" | diag_; return; }
+  while IFS= read -r line || test -n "$line"; do
     printf %s\\n "$diag_string_ $line"
-  done <<EOF
-$*
-EOF
+  done
 )
 
 # Used by the 'diag_' function above.  User-overridable.