From patchwork Wed Apr 2 07:15:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: test: prevent test-hup to hang forever if the transaction does not start From: Pierre-Yves David X-Patchwork-Id: 4193 Message-Id: <108f59ec681455498e7f.1396422941@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: pierre-yves.david@ens-lyon.org Date: Wed, 02 Apr 2014 00:15:41 -0700 # HG changeset patch # User Pierre-Yves David # 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. 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