zsh-workers
 help / color / mirror / code / Atom feed
From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: ZTST_continue (was Re: Lots of test failures when --disable-multibyte)
Date: Thu, 7 Apr 2022 21:34:52 +0900	[thread overview]
Message-ID: <58534D69-1D2F-4F0F-B79F-CD272EF6759A@kba.biglobe.ne.jp> (raw)
In-Reply-To: <728406102.562615.1649252226266@mail2.virginmedia.com>

This is for taking care of the return value of ZTST_prep.

ZTST_prep is modified so that if ZTST_unimplemented is set in any chunk
then the remaining chunks of %prep are skipped.

P01privileged.ztst is split into several chunks, and returns 0
when it sets ZTST_unimplemented.



diff --git a/Test/P01privileged.ztst b/Test/P01privileged.ztst
index 7c4a1be35..5d45c1a4c 100644
--- a/Test/P01privileged.ztst
+++ b/Test/P01privileged.ztst
@@ -26,23 +26,23 @@
 
 %prep
 
-  # Mind your empty lines here. The logic in this %prep section is somewhat
-  # complex compared to most others; to avoid lots of nested/duplicated
-  # conditions we need to make sure that this all gets executed as a single
-  # function from which we can return early
+  # If ZTST_unimplemented is set to non-null in a chunk then all the
+  # remaining chunks (and all of %test and %clean sections) will be skipped.
   [[ $EUID == 0 || -n $ZSH_TEST_UNPRIVILEGED_UID$ZSH_TEST_UNPRIVILEGED_GID ]] || {
     ZTST_unimplemented='PRIVILEGED tests require super-user privileges (or env var)'
-    return 1
+    return 0
   }
+
   (( $+commands[perl] )) || { # @todo Eliminate this dependency with a C wrapper?
     ZTST_unimplemented='PRIVILEGED tests require Perl'
-    return 1
+    return 0
   }
+
   grep -qE '#define HAVE_SETRES?UID' $ZTST_testdir/../config.h || {
     ZTST_unimplemented='PRIVILEGED tests require setreuid()/setresuid()'
-    return 1
+    return 0
   }
-  #
+
   ruid= euid= rgid= egid=
   #
   if [[ -n $ZSH_TEST_UNPRIVILEGED_UID ]]; then
@@ -76,13 +76,14 @@
   #
   [[ -n $ruid && -n $euid ]] || {
     ZTST_unimplemented='PRIVILEGED tests require unprivileged UID:EUID'
-    return 1
+    return 0
   }
+
   [[ -n $rgid || -n $egid ]] || {
     ZTST_unimplemented='PRIVILEGED tests require unprivileged GID:EGID'
-    return 1
+    return 0
   }
-  #
+
   print -ru$ZTST_fd \
     "Using unprivileged UID $ruid, EUID $euid, GID $rgid, EGID $egid"
   #
diff --git a/Test/ztst.zsh b/Test/ztst.zsh
index cdc84b160..190deecfd 100755
--- a/Test/ztst.zsh
+++ b/Test/ztst.zsh
@@ -299,16 +299,18 @@ ZTST_execchunk() {
 }
 
 # Functions for preparation and cleaning.
-# When cleaning up (non-zero string argument), we ignore status.
-ZTST_prepclean() {
-  # Execute indented code chunks.
-  while ZTST_getchunk; do
-    ZTST_execchunk >/dev/null || [[ -n $1 ]] || {
-      [[ -n "$ZTST_unimplemented" ]] ||
+ZTST_prep ZTST_clean () {
+  # Execute indented code chunks. If ZTST_unimplemented is set
+  # in any chunk then we will skip the remaining chunks.
+  # We ignore return status of chunks when cleaning up.
+  while [[ -z "$ZTST_unimplemented" ]] && ZTST_getchunk; do
+    ZTST_execchunk >/dev/null || [[ $0 = ZTST_clean ]] || {
       ZTST_testfailed "non-zero status from preparation code:
-$ZTST_code" && return 0
+$ZTST_code"
+      return 1
     }
   done
+  return 0
 }
 
 # diff wrapper
@@ -577,27 +579,29 @@ while [[ -z "$ZTST_unimplemented" ]] && ZTST_getsect $ZTST_skipok; do
     (prep) if (( ${ZTST_sects[prep]} + ${ZTST_sects[test]} + \
 	        ${ZTST_sects[clean]} )); then
 	    ZTST_testfailed "\`prep' section must come first"
-            exit 1
+	    break   # skip %test and %clean sections, but run ZTST_cleanup
 	  fi
-	  ZTST_prepclean
+	  ZTST_prep || ZTST_skipok=1
 	  ZTST_sects[prep]=1
 	  ;;
     (test)
 	  if (( ${ZTST_sects[test]} + ${ZTST_sects[clean]} )); then
 	    ZTST_testfailed "bad placement of \`test' section"
-	    exit 1
+	    break   # skip %clean section, but run ZTST_cleanup
 	  fi
-	  # careful here: we can't execute ZTST_test before || or &&
-	  # because that affects the behaviour of traps in the tests.
-	  ZTST_test
-	  (( $? )) && ZTST_skipok=1
+          if [[ -z "$ZTST_skipok" ]]; then  # if no error in %prep
+            # careful here: we can't execute ZTST_test before || or &&
+            # because that affects the behaviour of traps in the tests.
+            ZTST_test
+            (( $? )) && ZTST_skipok=1
+          fi
 	  ZTST_sects[test]=1
 	  ;;
     (clean)
 	   if (( ${ZTST_sects[test]} == 0 || ${ZTST_sects[clean]} )); then
 	     ZTST_testfailed "bad use of \`clean' section"
 	   else
-	     ZTST_prepclean 1
+	     ZTST_clean
 	     ZTST_sects[clean]=1
 	   fi
 	   ZTST_skipok=





  parent reply	other threads:[~2022-04-07 12:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04  2:03 Lots of test failures when --disable-multibyte Bart Schaefer
2022-04-04 14:43 ` Peter Stephenson
2022-04-04 15:31   ` Bart Schaefer
2022-04-04 16:23     ` Peter Stephenson
2022-04-04 21:10     ` Bart Schaefer
2022-04-04 21:45       ` Bart Schaefer
2022-04-04 22:00         ` Bart Schaefer
2022-04-05 16:00           ` Bart Schaefer
2022-04-05 16:15             ` Mikael Magnusson
2022-04-05 20:29           ` Peter Stephenson
2022-04-06  3:48             ` Bart Schaefer
2022-04-06  5:32             ` ZTST_continue (was Re: Lots of test failures when --disable-multibyte) Jun T
2022-04-06 13:37               ` Peter Stephenson
2022-04-07 12:33                 ` Jun T
2022-04-07 12:34                 ` Jun T [this message]
2022-04-04 18:52 ` Lots of test failures when --disable-multibyte Bart Schaefer

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=58534D69-1D2F-4F0F-B79F-CD272EF6759A@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).