Bug 1337827 - [one-click-loaner] Print error message if mach binary wasn't found
MozReview-Commit-ID: Dx3rV17FOoJ
--- a/taskcluster/scripts/tester/run-wizard
+++ b/taskcluster/scripts/tester/run-wizard
@@ -5,21 +5,35 @@
from __future__ import print_function, unicode_literals
import datetime
import os
import subprocess
import sys
import time
+from distutils.spawn import find_executable
from textwrap import wrap
here = os.path.dirname(os.path.abspath(__file__))
MOZHARNESS_WORKDIR = os.path.expanduser(os.path.join('~', 'workspace', 'build'))
+MACH_SETUP_FINISHED = """
+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
+""".lstrip().format(MOZHARNESS_WORKDIR)
+
+MACH_SETUP_FAILED = """
+Could not set up mach environment, no mach binary detected.
+""".lstrip()
+
def call(cmd, **kwargs):
print(" ".join(cmd))
return subprocess.call(cmd, **kwargs)
def wait_for_run_mozharness(timeout=60):
starttime = datetime.datetime.now()
@@ -29,21 +43,24 @@ def wait_for_run_mozharness(timeout=60):
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')
+ if not os.path.isfile(mach_src):
+ return 1
+
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)
+ return 0
def resume():
wait_for_run_mozharness()
call(['run-mozharness'])
def setup():
@@ -57,24 +74,22 @@ def setup():
status = call(['run-mozharness', '--no-run-tests'])
if status:
# something went wrong
return status
setup_mach_environment()
- print("""
-Mozharness has finished downloading the build and tests to:
-{}
+ if find_executable('mach'):
+ print(MACH_SETUP_FINISHED)
+ else:
+ print(MACH_SETUP_FAILED)
-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
-""".lstrip().format(build_dir))
+ return status
def clone():
"""Clone the correct gecko repository and update to the proper revision."""
base_repo = os.environ['GECKO_HEAD_REPOSITORY']
dest = os.path.expanduser(os.path.join('~', 'gecko'))
# Specify method to checkout a revision. This defaults to revisions as