Patchwork D11085: sigpipe-remote: check environment variable sooner

login
register
mail settings
Submitter phabricator
Date July 12, 2021, 3:59 a.m.
Message ID <differential-rev-PHID-DREV-gq5wdsx3hexslnaalhqp-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49399/
State Superseded
Headers show

Comments

phabricator - July 12, 2021, 3:59 a.m.
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




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

Patch

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])