Patchwork test: prevent test-hup to hang forever if the transaction does not start

login
register
mail settings
Submitter Pierre-Yves David
Date April 2, 2014, 7:15 a.m.
Message ID <108f59ec681455498e7f.1396422941@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4193/
State Accepted
Headers show

Comments

Pierre-Yves David - April 2, 2014, 7:15 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1396422081 25200
#      Wed Apr 02 00:01:21 2014 -0700
# Node ID 108f59ec681455498e7fd32410554241f2ec82b5
# Parent  9e9e3a4e9261d31318f0f177538636370c50fe57
test: prevent test-hup to hang forever if the transaction does not start

If the transaction fails to start because of some programing errors, the test
would stay stuck in this while loop forever.

We now added a basic safeguard that abort the loop if nothing happen in 10
seconds. 10 seconds sounds enough to let the server catch up and open a
transaction.
Matt Mackall - April 2, 2014, 9:44 p.m.
On Wed, 2014-04-02 at 00:15 -0700, pierre-yves.david@ens-lyon.org wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1396422081 25200
> #      Wed Apr 02 00:01:21 2014 -0700
> # Node ID 108f59ec681455498e7fd32410554241f2ec82b5
> # Parent  9e9e3a4e9261d31318f0f177538636370c50fe57
> test: prevent test-hup to hang forever if the transaction does not start

Queued for default, thanks. But I expect non-trivial shell programming
is going to mean we're going to have one of OSX/Solaris/AIX complain
about test breakage eventually.

Patch

diff --git a/tests/test-hup.t b/tests/test-hup.t
--- a/tests/test-hup.t
+++ b/tests/test-hup.t
@@ -9,11 +9,20 @@  Test hangup signal in the middle of tran
 Do test while holding fifo open
 
   $ (
   > echo lock
   > echo addchangegroup
-  > while [ ! -s .hg/store/journal ]; do sleep 0; done
+  > start=`date +%s`
+  > # 10 second seems much enough to let the server catch up
+  > deadline=`expr $start + 10`
+  > while [ ! -s .hg/store/journal ]; do
+  >     sleep 0;
+  >     if [ `date +%s` -gt $deadline ]; then
+  >         echo "transaction did not started after 10 seconds" >&2;
+  >         exit 1;
+  >     fi
+  > done
   > kill -HUP $P
   > ) > p
 
   $ wait
   $ cat out