Bug 1337827 - [one-click-loaner] Refactor mach environment setup into a standalone function
MozReview-Commit-ID: CuxSwkp0Uuk
--- 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