Bug 1315032 - Make |mach try| set --artifact flag when --enable-artifact-builds is set. r=maja_zf,chmanchester
Tri-state flags: I hate them. I don't want to default "--artifact" in
the autotry parser, since not all consumers of that code have a
mozconfig. However, we also can't overwrite the `artifact` value from
a "--no-artifact" flag without knowing if we're changing anything.
Therefore, we add a new "--no-artifact" flag and manage the tri-state
ourselves.
MozReview-Commit-ID: 19gl3mM4YO0
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -489,17 +489,28 @@ class JsapiTestsCommand(MachCommandBase)
jsapi_tests_cmd.append(params['test_name'])
jsapi_tests_result = subprocess.call(jsapi_tests_cmd)
return jsapi_tests_result
def autotry_parser():
from autotry import arg_parser
- return 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
+ # use a different variable than --artifact.
+ parser.add_argument('--no-artifact',
+ dest='no_artifact',
+ action='store_true',
+ help='Force compiled (non-artifact) builds even when '
+ '--enable-artifact-builds is set.')
+ return parser
@CommandProvider
class PushToTry(MachCommandBase):
def normalise_list(self, items, allow_subitems=False):
from autotry import parse_arg
rv = defaultdict(list)
for item in items:
@@ -661,23 +672,42 @@ class PushToTry(MachCommandBase):
paths)
sys.exit(1)
if not kwargs["intersection"]:
paths_by_flavor = at.remove_duplicates(paths_by_flavor, tests)
else:
paths_by_flavor = {}
+ # Add --artifact if --enable-artifact-builds is set ...
+ if self.substs.get("MOZ_ARTIFACT_BUILDS"):
+ extra["artifact"] = True
+ # ... unless --no-artifact is explicitly given.
+ if kwargs["no_artifact"]:
+ if "artifact" in extra:
+ del extra["artifact"]
+
try:
msg = at.calc_try_syntax(platforms, tests, talos, builds, paths_by_flavor, tags,
extra, kwargs["intersection"])
except ValueError as e:
print(e.message)
sys.exit(1)
+ if kwargs["verbose"]:
+ if self.substs.get("MOZ_ARTIFACT_BUILDS"):
+ if kwargs["no_artifact"]:
+ print('mozconfig has --enable-artifact-builds but '
+ '--no-artifact specified, not including --artifact '
+ 'flag in try syntax')
+ else:
+ print('mozconfig has --enable-artifact-builds; including '
+ '--artifact flag in try syntax (use --no-artifact '
+ 'to override)')
+
if kwargs["verbose"] and paths_by_flavor:
print('The following tests will be selected: ')
for flavor, paths in paths_by_flavor.iteritems():
print("%s: %s" % (flavor, ",".join(paths)))
if kwargs["verbose"] or not kwargs["push"]:
print('The following try syntax was calculated:\n%s' % msg)