changeset 17538:31ca918d539a

test-static-http.t: enable on Windows We cannot read $! to get the background job process identifier, with MinGW it can return internal identifiers not matching the native Windows ones. Instead we introduce a helper script polling on the pid file. We assume the pid file data will be written in order.
author Patrick Mezard <patrick@mezard.eu>
date Wed, 12 Sep 2012 22:31:54 +0200
parents 31f32a96e1e3
children bc7377160fa7
files tests/test-static-http.t
diffstat 1 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-static-http.t	Tue Sep 11 08:36:09 2012 -0700
+++ b/tests/test-static-http.t	Wed Sep 12 22:31:54 2012 +0200
@@ -1,4 +1,4 @@
-  $ "$TESTDIR/hghave" serve || exit 80
+  $ "$TESTDIR/hghave" killdaemons || exit 80
 
 #if windows
   $ hg clone http://localhost:$HGPORT/ copy
@@ -25,10 +25,27 @@
   >     httpd.serve_forever()
   > 
   > signal.signal(signal.SIGTERM, lambda x, y: sys.exit(0))
+  > fp = file('dumb.pid', 'wb')
+  > fp.write(str(os.getpid()) + '\n')
+  > fp.close()
   > run()
   > EOF
   $ python dumb.py 2>/dev/null &
-  $ echo $! >> $DAEMON_PIDS
+
+Cannot just read $!, it will not be set to the right value on Windows/MinGW
+
+  $ cat > wait.py <<EOF
+  > import time
+  > while True:
+  >     try:
+  >         if '\n' in file('dumb.pid', 'rb').read():
+  >             break
+  >     except IOError:
+  >         pass
+  >     time.sleep(0.2)
+  > EOF
+  $ python wait.py
+  $ cat dumb.pid >> $DAEMON_PIDS
   $ hg init remote
   $ cd remote
   $ echo foo > bar
@@ -171,4 +188,4 @@
   $ hg clone static-http://localhost:$HGPORT/notarepo local3
   abort: 'http://localhost:$HGPORT/notarepo' does not appear to be an hg repository!
   [255]
-  $ kill $!
+  $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS