Subject: Re: bug#8571: misc/tty-eof SKIP reason
From: Jim Meyering <[email-masked]>
To: Bruno Haible <[email-masked]>
Cc: [email-masked]
Date: Thu, 28 Apr 2011 11:16:42 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Bruno Haible wrote:
> building coreutils 8.12 on a Linux 2.6.25.20, glibc 2.8 machine, "make check"
> shows this line:
>
>   SKIP: misc/tty-eof
>
> But unlike for the other tests that are skipped, there is no explanation why
> it was skipped. I have to look into the misc/tty-eof.log file, there I find:
>   tty-eof: this script requires Perl's Expect package >=1.11
>
> Could the explanation be repeated in stdout or stderr, like for the other
> tests when they are skipped?

Sure.

From 11a5a943f6c557f5cc057f073bed67829b0a05d0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email-masked]>
Date: Thu, 28 Apr 2011 11:12:01 +0200
Subject: [PATCH] tests: tty-eof: when skipping, announce the reason to outer
 stderr,

where a person will be more likely to see it, not just to the log file.
* tests/misc/tty-eof (emit_skip_msg): New function.
Use it instead of "warn".
Suggested by Bruno Haible.
---
 tests/misc/tty-eof |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/tests/misc/tty-eof b/tests/misc/tty-eof
index 14910dc..f5a6159 100755
--- a/tests/misc/tty-eof
+++ b/tests/misc/tty-eof
@@ -22,11 +22,26 @@
 use strict;
 (my $ME = $0) =~ s|.*/||;

+# Emit a diagnostic both to stderr and to $stderr_fileno_.
+# FIXME: don't hard-code that value (9), since it's already defined in init.cfg.
+sub emit_skip_msg ($)
+{
+  my ($msg) = @_;
+  my $stderr_fileno_ = 9;
+  warn $msg;
+  open FH, ">&$stderr_fileno_"
+    or warn "$ME: failed to dup stderr\n";
+  print FH $msg;
+  close FH
+    or warn "$ME: failed to close FD $stderr_fileno_\n";
+}
+
 # Some older versions of Expect.pm (e.g. 1.07) lack the log_user method,
 # so check for that, too.
 eval { require Expect; Expect->require_version('1.11') };
-$@ and (warn "$ME: this script requires Perl's Expect package >=1.11\n"),
-  exit 77;
+$@
+  and emit_skip_msg "$ME: this script requires Perl's Expect package >=1.11\n",
+    exit 77;

 {
   my $fail = 0;
--
1.7.5.421.g9d34e