Bug 1344281 - Don't accidentally require config.status when running |./mach try|. r=nalexander draft
authorChris Manchester <cmanchester@mozilla.com>
Fri, 03 Mar 2017 11:17:11 -0800
changeset 493284 eb1a038e57dd40940d6bd648728942e26919a5cb
parent 493283 6206a4e24764f287ed5693b0acf4cf4da9ef3dc7
child 547826 d8077059a7b2ad365488222b5d7cfa7cabb82664
push id47721
push usercmanchester@mozilla.com
push dateFri, 03 Mar 2017 19:17:44 +0000
reviewersnalexander
bugs1344281
milestone54.0a1
Bug 1344281 - Don't accidentally require config.status when running |./mach try|. r=nalexander MozReview-Commit-ID: Ez8GI46kv7z
testing/mach_commands.py
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -13,17 +13,17 @@ import shutil
 from collections import defaultdict
 
 from mach.decorators import (
     CommandArgument,
     CommandProvider,
     Command,
 )
 
-from mozbuild.base import MachCommandBase
+from mozbuild.base import BuildEnvironmentNotFoundException, MachCommandBase
 from mozbuild.base import MachCommandConditions as conditions
 import mozpack.path as mozpath
 from argparse import ArgumentParser
 
 UNKNOWN_TEST = '''
 I was unable to find tests from the given argument(s).
 
 You should specify a test directory, filename, test suite name, or
@@ -685,32 +685,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 = {}
 
+        local_artifact_build = False
+        try:
+            if self.substs.get("MOZ_ARTIFACT_BUILDS"):
+                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
+
         # Add --artifact if --enable-artifact-builds is set ...
-        if self.substs.get("MOZ_ARTIFACT_BUILDS"):
+        if local_artifact_build:
             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 self.substs.get("MOZ_ARTIFACT_BUILDS"):
+        if local_artifact_build:
             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)')