sigpipe-remote: check environment variable sooner
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 11 Jul 2021 23:08:00 +0200
changeset 47616 df6148ca7120
parent 47615 a8d1adeeba87
child 47617 d5fc1b59a2df
sigpipe-remote: check environment variable sooner Lets make sure we have everything before doing anything. Differential Revision: https://phab.mercurial-scm.org/D11085
tests/testlib/sigpipe-remote.py
--- a/tests/testlib/sigpipe-remote.py	Mon Jul 12 00:14:11 2021 +0200
+++ b/tests/testlib/sigpipe-remote.py	Sun Jul 11 23:08:00 2021 +0200
@@ -9,6 +9,21 @@
 
 # we cannot use mercurial.testing as long as python2 is not dropped as the test will only install the mercurial module for python2 in python2 run
 
+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"""
@@ -56,21 +71,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])