Bug 1337827 - [one-click-loaner] Refactor mach environment setup into a standalone function draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 10 Feb 2017 11:39:03 -0500
changeset 481886 7de77353e4bf20da960848ba1ba206c388798c17
parent 481880 511093a0d82882d4b20f91b0287ad4b610c5225f
child 481887 846c667b7578a68003110359373e0b5a02b9454d
push id44942
push userahalberstadt@mozilla.com
push dateFri, 10 Feb 2017 17:18:36 +0000
bugs1337827
milestone54.0a1
Bug 1337827 - [one-click-loaner] Refactor mach environment setup into a standalone function MozReview-Commit-ID: CuxSwkp0Uuk
taskcluster/scripts/tester/run-wizard
--- a/taskcluster/scripts/tester/run-wizard
+++ b/taskcluster/scripts/tester/run-wizard
@@ -8,16 +8,17 @@ from __future__ import print_function, u
 import datetime
 import os
 import subprocess
 import sys
 import time
 from textwrap import wrap
 
 here = os.path.dirname(os.path.abspath(__file__))
+MOZHARNESS_WORKDIR = os.path.expanduser(os.path.join('~', 'workspace', 'build'))
 
 
 def call(cmd, **kwargs):
     print(" ".join(cmd))
     return subprocess.call(cmd, **kwargs)
 
 
 def wait_for_run_mozharness(timeout=60):
@@ -26,16 +27,25 @@ def wait_for_run_mozharness(timeout=60):
         if os.path.isfile(os.path.join(here, 'run-mozharness')):
             break
         time.sleep(0.2)
     else:
         print("Timed out after %d seconds waiting for the 'run-mozharness' binary" % timeout)
         return 1
 
 
+def setup_mach_environment():
+    mach_src = os.path.join(MOZHARNESS_WORKDIR, 'tests', 'mach')
+    mach_dest = os.path.expanduser(os.path.join('~', 'bin', 'mach'))
+
+    if os.path.exists(mach_dest):
+        os.remove(mach_dest)
+    os.symlink(mach_src, mach_dest)
+
+
 def resume():
     wait_for_run_mozharness()
     call(['run-mozharness'])
 
 
 def setup():
     """Run the mozharness script without the 'run-tests' action.
 
@@ -45,23 +55,17 @@ def setup():
     """
     wait_for_run_mozharness()
     status = call(['run-mozharness', '--no-run-tests'])
 
     if status:
         # something went wrong
         return status
 
-    build_dir = os.path.expanduser(os.path.join('~', 'workspace', 'build'))
-    mach_src = os.path.join(build_dir, 'tests', 'mach')
-    mach_dest = os.path.expanduser(os.path.join('~', 'bin', 'mach'))
-
-    if os.path.exists(mach_dest):
-        os.remove(mach_dest)
-    os.symlink(mach_src, mach_dest)
+    setup_mach_environment()
 
     print("""
 Mozharness has finished downloading the build and tests to:
 {}
 
 A limited mach environment has also been set up and added to the $PATH, but
 it may be missing the command you need. To see a list of commands, run:
     $ mach help