[PATCH 4 of 7] tests: use 'do sleep 0' instead of 'do true', also on first line of command

Mads Kiilerich mads at kiilerich.com
Sun Apr 22 19:18:56 CDT 2012


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1335139008 -7200
# Branch stable
# Node ID 086b1c861814e98868cb1959a00e66d4cf43f3c5
# Parent  de4f3656288eeff8676e73533d67eb102a34cc0d
tests: use 'do sleep 0' instead of 'do true', also on first line of command

f64b25f147d7 established that '... do true ...' shouldn't be used, but that was
only enforced on continued lines.

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -71,6 +71,7 @@
     (r'^alias\b.*=', "don't use alias, use a function"),
     (r'if\s*!', "don't use '!' to negate exit status"),
     (r'/dev/u?random', "don't use entropy, use /dev/zero"),
+    (r'do\s*true;\s*done', "don't use true as loop body, use sleep 0"),
   ],
   # warnings
   [
@@ -99,8 +100,6 @@
     (uprefix + r'set -e', "don't use set -e"),
     (uprefix + r'\s', "don't indent commands, use > for continued lines"),
     (uprefixc + r'( *)\t', "don't use tabs to indent"),
-    (uprefixc + r'.*do\s*true;\s*done',
-     "don't use true as loop body, use sleep 0"),
   ],
   # warnings
   []
diff --git a/tests/test-bad-pull.t b/tests/test-bad-pull.t
--- a/tests/test-bad-pull.t
+++ b/tests/test-bad-pull.t
@@ -20,7 +20,7 @@
 
   $ python dumb.py 2> log &
   $ P=$!
-  $ while [ ! -f listening ]; do true; done
+  $ while [ ! -f listening ]; do sleep 0; done
   $ hg clone http://localhost:$HGPORT/foo copy2
   abort: HTTP Error 404: * (glob)
   [255]
diff --git a/tests/test-hgweb-raw.t b/tests/test-hgweb-raw.t
--- a/tests/test-hgweb-raw.t
+++ b/tests/test-hgweb-raw.t
@@ -20,7 +20,7 @@
   $ cat hg.pid >> $DAEMON_PIDS
   $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/?f=a23bf1310f6e;file=sub/some%20%22text%22.txt;style=raw' content-type content-length content-disposition) >getoutput.txt
 
-  $ while kill `cat hg.pid` 2>/dev/null; do true; done
+  $ while kill `cat hg.pid` 2>/dev/null; do sleep 0; done
 
   $ cat getoutput.txt
   200 Script output follows
@@ -41,7 +41,7 @@
 
   $ cat hg.pid >> $DAEMON_PIDS
   $ ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/?f=a23bf1310f6e;file=sub/some%20%22text%22.txt;style=raw' content-type content-length content-disposition) >getoutput.txt
-  $ while kill `cat hg.pid` 2>/dev/null; do true; done
+  $ while kill `cat hg.pid` 2>/dev/null; do sleep 0; done
 
   $ cat getoutput.txt
   200 Script output follows
diff --git a/tests/test-http-proxy.t b/tests/test-http-proxy.t
--- a/tests/test-http-proxy.t
+++ b/tests/test-http-proxy.t
@@ -9,7 +9,7 @@
   $ cat hg.pid >> $DAEMON_PIDS
   $ cd ..
   $ "$TESTDIR/tinyproxy.py" $HGPORT1 localhost >proxy.log 2>&1 </dev/null &
-  $ while [ ! -f proxy.pid ]; do true; done
+  $ while [ ! -f proxy.pid ]; do sleep 0; done
   $ cat proxy.pid >> $DAEMON_PIDS
 
 url for proxy, stream
diff --git a/tests/test-https.t b/tests/test-https.t
--- a/tests/test-https.t
+++ b/tests/test-https.t
@@ -233,12 +233,12 @@
   $ hg -R copy-pull id https://127.0.0.1:$HGPORT/
   5fed3813f7f5
 
-  $ while kill `cat hg1.pid` 2>/dev/null; do true; done
+  $ while kill `cat hg1.pid` 2>/dev/null; do sleep 0; done
 
 Prepare for connecting through proxy
 
   $ "$TESTDIR/tinyproxy.py" $HGPORT1 localhost >proxy.log </dev/null 2>&1 &
-  $ while [ ! -f proxy.pid ]; do true; done
+  $ while [ ! -f proxy.pid ]; do sleep 0; done
   $ cat proxy.pid >> $DAEMON_PIDS
 
   $ echo "[http_proxy]" >> copy-pull/.hg/hgrc


More information about the Mercurial-devel mailing list