Bug 1384257 - Fix AttributeError when passing paths into |mach try|, r?maja_zf
MozReview-Commit-ID: IuuXt1XHUuM
--- a/tools/tryselect/mach_commands.py
+++ b/tools/tryselect/mach_commands.py
@@ -1,25 +1,36 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
import argparse
+import os
+import sys
from mach.decorators import (
CommandArgument,
CommandProvider,
Command,
SubCommand,
)
from mozbuild.base import BuildEnvironmentNotFoundException, MachCommandBase
+CONFIG_ENVIRONMENT_NOT_FOUND = '''
+No config environment detected. This means we are unable to properly
+detect test files in the specified paths or tags. Please run:
+
+ $ mach configure
+
+and try again.
+'''.lstrip()
+
def syntax_parser():
from tryselect.selectors.syntax import arg_parser
parser = arg_parser()
# The --no-artifact flag is only interpreted locally by |mach try|; it's not
# like the --artifact flag, which is interpreted remotely by the try server.
#
# We need a tri-state where set is different than the default value, so we
@@ -106,13 +117,18 @@ class TrySelect(MachCommandBase):
if self.substs.get("MOZ_ARTIFACT_BUILDS"):
kwargs['local_artifact_build'] = True
except BuildEnvironmentNotFoundException:
# If we don't have a build locally, we can't tell whether
# an artifact build is desired, but we still want the
# command to succeed, if possible.
pass
+ config_status = os.path.join(self.topobjdir, 'config.status')
+ if (kwargs['paths'] or kwargs['tags']) and not config_status:
+ print(CONFIG_ENVIRONMENT_NOT_FOUND)
+ sys.exit(1)
+
def resolver_func():
return self._spawn(TestResolver)
at = AutoTry(self.topsrcdir, resolver_func, self._mach_context)
return at.run(**kwargs)
--- a/tools/tryselect/selectors/syntax.py
+++ b/tools/tryselect/selectors/syntax.py
@@ -10,25 +10,16 @@ import os
import re
import subprocess
import sys
import which
from collections import defaultdict
import mozpack.path as mozpath
-CONFIG_ENVIRONMENT_NOT_FOUND = '''
-No config environment detected. This means we are unable to properly
-detect test files in the specified paths or tags. Please run:
-
- $ mach configure
-
-and try again.
-'''.lstrip()
-
def arg_parser():
parser = argparse.ArgumentParser()
parser.add_argument('paths', nargs='*', help='Paths to search for tests to run on try.')
parser.add_argument('-b', '--build', dest='builds', default='do',
help='Build types to run (d for debug, o for optimized).')
parser.add_argument('-p', '--platform', dest='platforms', action='append',
help='Platforms to run (required if not found in the environment as '
@@ -724,20 +715,16 @@ class AutoTry(object):
sys.exit(1)
if not any(kwargs[item] for item in ("paths", "tests", "tags")):
kwargs["paths"], kwargs["tags"] = self.find_paths_and_tags(kwargs["verbose"])
builds, platforms, tests, talos, jobs, paths, tags, extra = self.validate_args(**kwargs)
if paths or tags:
- if not os.path.exists(os.path.join(self.topobjdir, 'config.status')):
- print(CONFIG_ENVIRONMENT_NOT_FOUND)
- sys.exit(1)
-
paths = [os.path.relpath(os.path.normpath(os.path.abspath(item)), self.topsrcdir)
for item in paths]
paths_by_flavor = self.paths_by_flavor(paths=paths, tags=tags)
if not paths_by_flavor and not tests:
print("No tests were found when attempting to resolve paths:\n\n\t%s" %
paths)
sys.exit(1)