Bug 1342937 - Error out of |mach try| when using test paths and no build config is detected, r=chmanchester
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Mon, 27 Feb 2017 09:42:25 -0500
changeset 490509 6c1627e917136d72f3b7d74da2d10d45315dd929
parent 490508 8ddcd324a0f15735586d9b33dbad87ef4603de89
child 490510 0f5ee692c95699047d89373391b9f81ed269873d
push id47118
push userbmo:ttromey@mozilla.com
push dateTue, 28 Feb 2017 17:09:36 +0000
reviewerschmanchester
bugs1342937
milestone54.0a1
Bug 1342937 - Error out of |mach try| when using test paths and no build config is detected, r=chmanchester MozReview-Commit-ID: 2RE3vc1Kxvc
testing/mach_commands.py
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -37,16 +37,25 @@ a bug at
 https://bugzilla.mozilla.org/enter_bug.cgi?product=Testing&component=General.
 '''.strip()
 
 UNKNOWN_FLAVOR = '''
 I know you are trying to run a %s test. Unfortunately, I can't run those
 tests yet. Sorry!
 '''.strip()
 
+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()
+
 MOCHITEST_CHUNK_BY_DIR = 4
 MOCHITEST_TOTAL_CHUNKS = 5
 
 TEST_SUITES = {
     'cppunittest': {
         'aliases': ('Cpp', 'cpp'),
         'mach_command': 'cppunittest',
         'kwargs': {'test_file': None},
@@ -647,16 +656,20 @@ class PushToTry(MachCommandBase):
             sys.exit(1)
 
         if not any(kwargs[item] for item in ("paths", "tests", "tags")):
             kwargs["paths"], kwargs["tags"] = at.find_paths_and_tags(kwargs["verbose"])
 
         builds, platforms, tests, talos, 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 = at.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)