Patchwork [3,of,3] test-lfs: allow the test server to be killed on Windows

login
register
mail settings
Submitter Matt Harbison
Date Nov. 21, 2017, 6:31 a.m.
Message ID <cdc5b2fc8d5477140277.1511245874@Envy>
Download mbox | patch
Permalink /patch/25701/
State Accepted
Headers show

Comments

Matt Harbison - Nov. 21, 2017, 6:31 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1511241849 18000
#      Tue Nov 21 00:24:09 2017 -0500
# Node ID cdc5b2fc8d54771402773287a241924878a3aebe
# Parent  8e1c165cf1eef41c1db8359ed07424629c932c42
test-lfs: allow the test server to be killed on Windows

Apparently '$!' doesn't return a Win32 PID, so the process was never killed, and
the next run was screwed up.  Oddly, without the explicit killdaemons.py at the
end, the test seems to hang.  This spawning is just sad, so I limited it to
Windows.
Yuya Nishihara - Nov. 26, 2017, 11:06 a.m.
On Tue, 21 Nov 2017 01:31:14 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1511241849 18000
> #      Tue Nov 21 00:24:09 2017 -0500
> # Node ID cdc5b2fc8d54771402773287a241924878a3aebe
> # Parent  8e1c165cf1eef41c1db8359ed07424629c932c42
> test-lfs: allow the test server to be killed on Windows

Queued, thanks.

Appears that there isn't no easy way to make lfs-test-server dump a pid file.
https://github.com/git-lfs/lfs-test-server/blob/master/main.go

Patch

diff --git a/tests/test-lfs-test-server.t b/tests/test-lfs-test-server.t
--- a/tests/test-lfs-test-server.t
+++ b/tests/test-lfs-test-server.t
@@ -4,8 +4,26 @@ 
   $ LFS_HOST="localhost:$HGPORT"
   $ LFS_PUBLIC=1
   $ export LFS_LISTEN LFS_HOST LFS_PUBLIC
+#if no-windows
   $ lfs-test-server &> lfs-server.log &
   $ echo $! >> $DAEMON_PIDS
+#else
+  $ cat >> $TESTTMP/spawn.py <<EOF
+  > import os
+  > import subprocess
+  > import sys
+  > 
+  > for path in os.environ["PATH"].split(os.pathsep):
+  >     exe = os.path.join(path, 'lfs-test-server.exe')
+  >     if os.path.exists(exe):
+  >         with open('lfs-server.log', 'wb') as out:
+  >             p = subprocess.Popen(exe, stdout=out, stderr=out)
+  >             sys.stdout.write('%s\n' % p.pid)
+  >             sys.exit(0)
+  > sys.exit(1)
+  > EOF
+  $ $PYTHON $TESTTMP/spawn.py >> $DAEMON_PIDS
+#endif
 
   $ cat >> $HGRCPATH <<EOF
   > [extensions]
@@ -104,3 +122,5 @@ 
   updating to branch default
   abort: LFS server error. Remote object for file data/a.i not found:(.*)! (re)
   [255]
+
+  $ $PYTHON $RUNTESTDIR/killdaemons.py $DAEMON_PIDS