[PATCH 4 of 4 v2] test-http-branchmap: enable on Windows

Patrick Mezard patrick at mezard.eu
Mon Aug 20 15:42:58 CDT 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1345495209 -7200
# Node ID b7ac68a52746cf877db028b37102bc2d4a213d64
# Parent  bb633ef1cf19e04450cf953ed8c107a7ff942d28
test-http-branchmap: enable on Windows

Tests using "hg serve --daemon" are currently disabled on Windows for
lack of proper kill utility. The one shipped with MinGW operates on
internal process identifiers and not on the ones recorded by hg serve.
Fortunately we can replace most of them by calls to killdaemons.py.

This patch is a proof of concept on how to run these tests on Windows.
The plan is:
- Check test-http-branchmap.t does not fail/hang on the buildbot
- Convert all kill utility calls to killdaemons.py calls.
- Add a rule in check-code.py to forbid kill calls, or ignore the
  remaining ones (test-hup.t, etc.).
- Possibly drop the 'serve' rule from hghave.

The:

  listening at http://*:$HGPORT1/

line does not appear on Windows because the detached process can no
longer write on its parent streams. Grepping hg serve stdout directly
causes the parent process to never return and hangs the test. This is a
bug, but I have no simple solution and prefer to pay this small price
and enable hg serve tests on Windows.

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -118,6 +118,9 @@
     except OSError:
         return False
 
+def has_killdaemons():
+    return True
+
 def has_cacheable_fs():
     from mercurial import util
 
@@ -286,6 +289,7 @@
     "hardlink": (has_hardlink, "hardlinks"),
     "icasefs": (has_icasefs, "case insensitive file system"),
     "inotify": (has_inotify, "inotify extension support"),
+    "killdaemons": (has_killdaemons, 'killdaemons.py support'),
     "lsprof": (has_lsprof, "python lsprof module"),
     "mtn": (has_mtn, "monotone client (>= 1.0)"),
     "outer-repo": (has_outer_repo, "outer repo"),
diff --git a/tests/test-http-branchmap.t b/tests/test-http-branchmap.t
--- a/tests/test-http-branchmap.t
+++ b/tests/test-http-branchmap.t
@@ -1,7 +1,10 @@
-  $ "$TESTDIR/hghave" serve || exit 80
-
+  $ "$TESTDIR/hghave" killdaemons || exit 80
+ 
   $ hgserve() {
-  >     hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid -E errors.log -v $@
+  >     hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid \
+  >       -E errors.log -v $@ > startup.log
+  >     # Grepping hg serve stdout would hang on Windows
+  >     grep -v 'listening at' startup.log
   >     cat hg.pid >> "$DAEMON_PIDS"
   > }
   $ hg init a
@@ -12,7 +15,6 @@
   $ hg -R a ci -Am foo
   adding foo
   $ hgserve -R a --config web.push_ssl=False --config web.allow_push=* --encoding latin1
-  listening at http://*:$HGPORT1/ (bound to 127.0.0.1:$HGPORT1) (glob)
   $ hg --encoding utf-8 clone http://localhost:$HGPORT1 b
   requesting all changes
   adding changesets
@@ -52,7 +54,7 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     foo
   
-  $ kill `cat hg.pid`
+  $ "$TESTDIR/killdaemons.py" hg.pid
 
 verify 7e7d56fe4833 (encoding fallback in branchmap to maintain compatibility with 1.3.x)
 


More information about the Mercurial-devel mailing list