Patchwork run-tests: conditionalize HGCATAPULTSERVERPIPE for Windows

login
register
mail settings
Submitter Matt Harbison
Date Aug. 30, 2018, 3:55 a.m.
Message ID <cf1e74e80f0123f9a9fc.1535601322@Envy>
Download mbox | patch
Permalink /patch/34178/
State New
Headers show

Comments

Matt Harbison - Aug. 30, 2018, 3:55 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1535600398 14400
#      Wed Aug 29 23:39:58 2018 -0400
# Node ID cf1e74e80f0123f9a9fc4876035474d6dc525a3b
# Parent  6827d3f47d4f1bab01a0cc92d7d9bfc52ee9f535
run-tests: conditionalize HGCATAPULTSERVERPIPE for Windows

Many of the *.py tests were dying on:

    File "c:\Users\Matt\projects\hg\hgdemandimport\tracing.py", line 27, in log
      _pipe = open(os.environ['HGCATAPULTSERVERPIPE'], 'w', 1)
  IOError: [Errno 2] $ENOENT$: '/dev/null'
Yuya Nishihara - Aug. 30, 2018, 11:30 a.m.
On Wed, 29 Aug 2018 23:55:22 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1535600398 14400
> #      Wed Aug 29 23:39:58 2018 -0400
> # Node ID cf1e74e80f0123f9a9fc4876035474d6dc525a3b
> # Parent  6827d3f47d4f1bab01a0cc92d7d9bfc52ee9f535
> run-tests: conditionalize HGCATAPULTSERVERPIPE for Windows
> 
> Many of the *.py tests were dying on:
> 
>     File "c:\Users\Matt\projects\hg\hgdemandimport\tracing.py", line 27, in log
>       _pipe = open(os.environ['HGCATAPULTSERVERPIPE'], 'w', 1)
>   IOError: [Errno 2] $ENOENT$: '/dev/null'
> 
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -1072,7 +1072,10 @@ class Test(unittest.TestCase):
>          env["HGHOSTNAME"] = "test-hostname"
>          env['HGIPV6'] = str(int(self._useipv6))
>          if 'HGCATAPULTSERVERPIPE' not in env:
> -            env['HGCATAPULTSERVERPIPE'] = '/dev/null'
> +            if os.name == 'nt':
> +                env['HGCATAPULTSERVERPIPE'] = 'NUL'
> +            else:
> +                env['HGCATAPULTSERVERPIPE'] = '/dev/null'

Maybe os.devnull can be used instead.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1072,7 +1072,10 @@  class Test(unittest.TestCase):
         env["HGHOSTNAME"] = "test-hostname"
         env['HGIPV6'] = str(int(self._useipv6))
         if 'HGCATAPULTSERVERPIPE' not in env:
-            env['HGCATAPULTSERVERPIPE'] = '/dev/null'
+            if os.name == 'nt':
+                env['HGCATAPULTSERVERPIPE'] = 'NUL'
+            else:
+                env['HGCATAPULTSERVERPIPE'] = '/dev/null'
 
         extraextensions = []
         for opt in self._extraconfigopts:
@@ -1390,7 +1393,7 @@  class TTest(Test):
             script.append(b'alias pwd="pwd -W"\n')
 
         hgcatapult = os.getenv('HGCATAPULTSERVERPIPE')
-        if hgcatapult and hgcatapult != '/dev/null':
+        if hgcatapult and hgcatapult not in ['/dev/null', 'NUL']:
             # Kludge: use a while loop to keep the pipe from getting
             # closed by our echo commands. The still-running file gets
             # reaped at the end of the script, which causes the while