public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jon TURNEY <jturney@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: Check exit code of a test, rather than stdout
Date: Sun,  8 Nov 2020 15:21:43 +0000 (GMT)	[thread overview]
Message-ID: <20201108152143.CECE1386F406@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0c448d53e10b1ab8f483f704f9ba07bc143fb788

commit 0c448d53e10b1ab8f483f704f9ba07bc143fb788
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sat Oct 17 00:36:26 2020 +0100

    Cygwin: Check exit code of a test, rather than stdout
    
    In winsup.exp, don't consider a command failed if it produced any output
    (e.g. if the compiler produced warnings).  Instead check the exit code.

Diff:
---
 winsup/testsuite/winsup.api/winsup.exp | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/winsup/testsuite/winsup.api/winsup.exp b/winsup/testsuite/winsup.api/winsup.exp
index 639096267..1550b9445 100644
--- a/winsup/testsuite/winsup.api/winsup.exp
+++ b/winsup/testsuite/winsup.api/winsup.exp
@@ -20,11 +20,19 @@ if { [info exists env(CYGWIN_TESTSUITE_TESTS)] } {
     set test_filter "$env(CYGWIN_TESTSUITE_TESTS)"
 }
 
-proc ws_spawn {cmd args} {
+proc ws_spawn {cmd} {
     global rv
     verbose "running $cmd\n"
-    catch "exec $cmd" rv
-    verbose send "catchCode = $rv\n"
+    try {
+	set msg [exec -ignorestderr {*}$cmd "2>@1"]
+	set rv 0
+    } trap CHILDSTATUS {results options} {
+	verbose "returned $::errorCode\n"
+	set msg $results
+	set rv 1
+    }
+    verbose -log "$msg"
+    return $rv
 }
 
 verbose "Filter: $test_filter"
@@ -52,8 +60,7 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/$subdir/*/*.{cc
 	source "$srcdir/$subdir/$basename.exp"
     } else {
 	ws_spawn "$CC -nodefaultlibs -mwin32 $CFLAGS $src $add_includes $add_libs $runtime_root/binmode.o -lgcc $runtime_root/libcygwin0.a -lkernel32 -luser32 -o $base.exe"
-	if { $rv != "" } {
-	    verbose -log "$rv"
+	if { $rv } {
 	    fail "$testcase (compile)"
 	} else {
 	    if { $verbose } {
@@ -62,8 +69,7 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/$subdir/*/*.{cc
 	       set redirect_output /dev/null
 	    }
 	    ws_spawn "$rootme/cygrun ./$base.exe > $redirect_output"
-	    if { $rv != "" } {
-		verbose -log "$testcase: $rv"
+	    if { $rv } {
 		fail "$testcase (execute)"
 		if { $xfail_expected } {
 		    catch { file delete "$base.exe" } err


                 reply	other threads:[~2020-11-08 15:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=20201108152143.CECE1386F406@sourceware.org \
    --to=jturney@sourceware.org \
    --cc=cygwin-cvs@sourceware.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).