Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version;
        bh=aBEApFhbpDg7+GZZ+D/h2KfoDxBtlBSqJaCm/NN3Qoc=;
        b=iGT+Sm/2WXwN2tcopJ22QWAWn9n9mpaO1YyMiKW2gyYYhWRTmPcAra8tNwqAcMqS0I
         k5YHII8F6sgamaPP5o6KQvKuhJITcZJDr8hcRppvwCzoqEDz1wCIiC5QcjdWD1n+E/7E
         KlWr8wnbb+HIar4M2F/1JOIr2NDj+U02HENeb9ce0zfYoSqNqgffr5h155rTXTrk4q6q
         ZUQH5nRaHOWHfKv6oVbEcxqZBR7qYuq1gnlmSFIisdD88vsQxof0AtzVIpg5JMAE4SIa
         ZHLqlnf4EU4Y8snm0FdgO06QrjnLg68CX9jn3srH5gcBMYHa5W8KUPtK+lyJDFCXciLq
         /73A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version;
        bh=aBEApFhbpDg7+GZZ+D/h2KfoDxBtlBSqJaCm/NN3Qoc=;
        b=EInEp6ZhDY3Lxw9ipcFW64sb5bsr2DnblrTtYzIfaYC2wgo2Kmw3EzlOkyyyVWLg4P
         1KIFLh4qBbWb62Ek91M9XEO15OxAhdbWUlDIV4F9aEvdMnzVJm9GJAW3Al0VXEVrfQmF
         CtAI8pgRrmw4/b3EoXfasj+TdLf5KDQQpw0FZH55+7DX2QJ29It1slUeYCvWT1Kxue1f
         wJWhMEDcgH2R27PbdjlVj75lo3QNz5xFrqd7bYsRCb+g2Ei0qOwuKL51WMN5IE0SaeBV
         QlIduxzRY8eaxQS0LhQXLUKcnHVLZtRDpHzKzdjDFfZsholw2iefBrZSWKRAkJg+pTeP
         /W6A==
X-Gm-Message-State: AOPr4FUY2kE12+I3INiH4mNNh3IfaMt4Ai/8xypqJAM2P5byP1/TjBhAC1rY1h3/Q9jLag==
X-Received: by 10.98.65.90 with SMTP id o87mr38044245pfa.151.1462038914624;
        Sat, 30 Apr 2016 10:55:14 -0700 (PDT)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160430105547.ZM10892@torch.brasslantern.com>
Date: Sat, 30 Apr 2016 10:55:47 -0700
In-Reply-To: <CAH+w=7b9kKY1Xr5YHFHMS4YzSptJWwU_N6p+s3R=Q=QjYYSo3w@mail.gmail.com>
Comments: In reply to Bart Schaefer <schaefer@brasslantern.com>
        "Re: Bug in C02cont.ztst's -N test" (Apr 29,  8:51pm)
References: <ufa1t5pl0yg.fsf@epithumia.math.uh.edu> 
	<160429131027.ZM22749@torch.brasslantern.com> 
	<ufashy4ghvy.fsf@epithumia.math.uh.edu> 
	<20160430004639.GA1360@tarsus.local2> 
	<20160430010131.GA34472@CptOrmolo.darkstar> 
	<20160430012828.GA3334@tarsus.local2> 
	<CAH+w=7b9kKY1Xr5YHFHMS4YzSptJWwU_N6p+s3R=Q=QjYYSo3w@mail.gmail.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Bug in C02cont.ztst's -N test
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 38374

On Apr 29,  8:51pm, Bart Schaefer wrote:
} Subject: Re: Bug in C02cont.ztst's -N test
}
} Is there some magic reason it has to total 60 seconds?

Oh, it's because not all versions of "ls" will show file times down to
the second, so we have to wait a full minute.  But that would mean
waiting one minute between creating and accessing the file, not just
between the runs of "ls".  

So what we need is to first determine whether {mount || /sbin/mount}
is going to return useful mount attribute information, and then do the
60-second sleep only if we can't trust it.

Wild guess without actually attempting to set up mock follows.  This
also handles the case where mount is neither in $PATH nor in /sbin.
Still breaks if "ls" is not in $PATH, but that seems unlikely.


diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index f9fc185..189c233 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -146,7 +146,12 @@
 
 # can't be bothered with -S
 
-  print -u $ZTST_fd 'This test takes two seconds...'
+  if [[ ${mtab::="$({mount || /sbin/mount})"} = *[(]?*[)] ]]; then
+    print -u $ZTST_fd 'This test takes two seconds...'
+  else
+    unmodified_ls="$(ls -lu $unmodified)"
+    print -u $ZTST_fd 'This test takes up to 60 seconds...'
+  fi
   sleep 2
   cat $unmodified
   touch $newnewnew
@@ -154,7 +159,14 @@
     ZTST_skip="[[ -N file ]] not supported on Cygwin"
   elif (( isnfs )); then
     ZTST_skip="[[ -N file ]] not supported with NFS"
-  elif { df -k -- ${$({mount || /sbin/mount} | awk '/noatime/ {print $1,$3}'):-""} | tr -s ' ' | fgrep -- "$(df -k . | tail -1 | tr -s ' ')" } >&/dev/null; then
+  elif { (( ! $+unmodified_ls )) &&
+         { df -k -- ${$(print -r -- "$mtab" |
+                        awk '/noatime/ {print $1,$3}'):-""} | tr -s ' ' |
+           fgrep -- "$(df -k . | tail -1 | tr -s ' ')" } >&/dev/null } ||
+       { (( $+unmodified_ls )) &&
+         ! repeat 30; do ZTST_hashmark; sleep 2
+             [[ $unmodified_ls != "$(ls -lu $unmodified)" ]] && break
+	   done }; then
     ZTST_skip="[[ -N file ]] not supported with noatime file system"
   else
     [[ -N $newnewnew && ! -N $unmodified ]]

