run-tests: detect active virtualenv (bug 1357201); r?glob draft
authorGregory Szorc <gps@mozilla.com>
Mon, 17 Apr 2017 15:17:51 -0700
changeset 10811 e732d34f586944be8b77aff3f759f64e9a36aeed
parent 10810 2eedb051778c774a493b61c5ee03e5bcb35140f5
child 10812 314de7fc2939965348da374c0a79a4d74fc15c89
push id1633
push userbmo:gps@mozilla.com
push dateWed, 19 Apr 2017 18:36:25 +0000
reviewersglob
bugs1357201
run-tests: detect active virtualenv (bug 1357201); r?glob Upcoming patches will make run-tests behave a bit more intelligently depending on the current virtualenv. In order to do that, we need to detect the current virtualenv. This commit adds code to do that. MozReview-Commit-ID: 9PWE4SBMGqr
run-tests
--- a/run-tests
+++ b/run-tests
@@ -21,16 +21,26 @@ EXTDIR = os.path.join(HERE, 'hgext')
 
 if __name__ == '__main__':
     if 'VIRTUAL_ENV' not in os.environ:
         activate = os.path.join(HERE, 'venv', 'bin', 'activate_this.py')
         execfile(activate, dict(__file__=activate))
         sys.executable = os.path.join(HERE, 'venv', 'bin', 'python')
         os.environ['VIRTUAL_ENV'] = os.path.join(HERE, 'venv')
 
+    venv_name = os.path.relpath(os.environ['VIRTUAL_ENV'],
+                                os.path.join(HERE, 'venv'))
+
+    if venv_name == '.':
+        venv_name = 'global'
+
+    if venv_name not in ('global', 'vcssync'):
+        print('unknown virtualenv: %s (this should not happen)' % venv_name)
+        sys.exit(1)
+
     try:
         import vcttesting.docker as vctdocker
     except ImportError:
         vctdocker = None
 
     from vcttesting.testing import (
         get_docker_state,
         get_extensions,