D11085: sigpipe-remote: check environment variable sooner

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Mon Jul 12 03:59:58 UTC 2021


marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Lets make sure we have everything before doing anything.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11085

AFFECTED FILES
  tests/testlib/sigpipe-remote.py

CHANGE DETAILS

diff --git a/tests/testlib/sigpipe-remote.py b/tests/testlib/sigpipe-remote.py
--- a/tests/testlib/sigpipe-remote.py
+++ b/tests/testlib/sigpipe-remote.py
@@ -16,6 +16,21 @@
     print('SIGPIPE-HELPER:   %s is running %s' % (exe, ver), file=sys.stderr)
     sys.exit(255)
 
+DEBUG_FILE = os.environ.get('SIGPIPE_REMOTE_DEBUG_FILE')
+if DEBUG_FILE is None:
+    debug_stream = sys.stderr.buffer
+else:
+    debug_stream = open(DEBUG_FILE, 'bw', buffering=0)
+
+SYNCFILE1 = os.environ.get('SYNCFILE1')
+SYNCFILE2 = os.environ.get('SYNCFILE2')
+if SYNCFILE1 is None:
+    print('SIGPIPE-HELPER: missing variable $SYNCFILE1', file=sys.stderr)
+    sys.exit(255)
+if SYNCFILE2 is None:
+    print('SIGPIPE-HELPER: missing variable $SYNCFILE2', file=sys.stderr)
+    sys.exit(255)
+
 
 def _timeout_factor():
     """return the current modification to timeout"""
@@ -59,21 +74,6 @@
 stderr_writer = os.fdopen(piped_stderr[1], "rb")
 stderr_reader = os.fdopen(piped_stderr[0], "rb")
 
-DEBUG_FILE = os.environ.get('SIGPIPE_REMOTE_DEBUG_FILE')
-if DEBUG_FILE is None:
-    debug_stream = sys.stderr.buffer
-else:
-    debug_stream = open(DEBUG_FILE, 'bw', buffering=0)
-
-SYNCFILE1 = os.environ.get('SYNCFILE1')
-SYNCFILE2 = os.environ.get('SYNCFILE2')
-if SYNCFILE1 is None:
-    print('SIGPIPE-HELPER: missing variable $SYNCFILE1', file=sys.stderr)
-    sys.exit(255)
-if SYNCFILE2 is None:
-    print('SIGPIPE-HELPER: missing variable $SYNCFILE2', file=sys.stderr)
-    sys.exit(255)
-
 debug_stream.write(b'SIGPIPE-HELPER: Starting\n')
 
 TESTLIB_DIR = os.path.dirname(sys.argv[0])



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list