Bug 1278702 - Error out when compiled-code test is requested with artifact build; r?chmanchester draft
authorMaja Frydrychowicz <mjzffr@gmail.com>
Wed, 21 Sep 2016 14:22:34 -0400
changeset 416244 3bac857398bad7f5a65cfd46e9addc35ba5ac09e
parent 416020 560b2c805bf7bebeb3ceebc495a81b2aa4c0c755
child 416245 f6003a967dbc6333f8e8d124125cbd22b31e0898
push id30071
push usermjzffr@gmail.com
push dateWed, 21 Sep 2016 18:24:31 +0000
reviewerschmanchester
bugs1278702
milestone52.0a1
Bug 1278702 - Error out when compiled-code test is requested with artifact build; r?chmanchester MozReview-Commit-ID: Es66ZuFq6PJ
testing/tools/autotry/autotry.py
--- a/testing/tools/autotry/autotry.py
+++ b/testing/tools/autotry/autotry.py
@@ -166,16 +166,38 @@ class AutoTry(object):
         "chrome": "mochitest-o",
         "browser-chrome": "mochitest-bc",
         "devtools-chrome": "mochitest-dt",
         "crashtest": "crashtest",
         "reftest": "reftest",
         "web-platform-tests": "web-platform-tests",
     }
 
+    compiled_suites = [
+        "cppunit",
+        "gtest",
+        "jittest",
+    ]
+
+    common_suites = [
+        "cppunit",
+        "crashtest",
+        "firefox-ui-functional",
+        "gtest",
+        "jittest",
+        "jsreftest",
+        "marionette",
+        "marionette-e10s",
+        "media-tests",
+        "mochitests",
+        "reftest",
+        "web-platform-tests",
+        "xpcshell",
+    ]
+
     # Arguments we will accept on the command line and pass through to try
     # syntax with no further intervention. The set is taken from
     # http://trychooser.pub.build.mozilla.org with a few additions.
     #
     # Note that the meaning of store_false and store_true arguments is
     # not preserved here, as we're only using these to echo the literal
     # arguments to another consumer. Specifying either store_false or
     # store_true here will have an equivalent effect.
@@ -220,16 +242,21 @@ class AutoTry(object):
             'action': 'store_true',
             'dest': 'all_emails',
             'help': 'Request all emails',
         },
         '--all-emails': {
             'action': 'store_true',
             'dest': 'all_emails',
             'help': 'Request all emails',
+        },
+        '--artifact': {
+            'action': 'store_true',
+            'dest': 'artifact',
+            'help': 'Force artifact builds where possible.',
         }
     }
 
     def __init__(self, topsrcdir, resolver_func, mach_context):
         self.topsrcdir = topsrcdir
         self._resolver_func = resolver_func
         self._resolver = None
         self.mach_context = mach_context
@@ -367,16 +394,25 @@ class AutoTry(object):
                 for job_name in self.flavor_jobs[flavor]:
                     for test in flavor_tests:
                         paths.add("%s:%s" % (flavor, test))
                     suites[job_name] = tests.get(suite, [])
 
         if not suites:
             raise ValueError("No tests found matching filters")
 
+        if extras.get('artifact'):
+            rejected = []
+            for suite in suites.keys():
+                if any([suite.startswith(c) for c in self.compiled_suites]):
+                    rejected.append(suite)
+            if rejected:
+                raise ValueError("You can't run {} with "
+                                 "--artifact option.".format(', '.join(rejected)))
+
         parts.append("-u")
         parts.append(",".join("%s%s" % (k, "[%s]" % ",".join(v) if v else "")
                               for k,v in sorted(suites.items())) if suites else "none")
 
         parts.append("-t")
         parts.append(",".join("%s%s" % (k, "[%s]" % ",".join(v) if v else "")
                               for k,v in sorted(talos.items())) if talos else "none")
 
@@ -396,17 +432,31 @@ class AutoTry(object):
                 parts.append(value)
             if action == 'append':
                 for e in value:
                     parts.append(arg)
                     parts.append(e)
             if action in ('store_true', 'store_false'):
                 parts.append(arg)
 
-        return " ".join(parts)
+        try_syntax = " ".join(parts)
+        if extras.get('artifact') and 'all' in suites.keys():
+            message = ('You asked for |-u all| with |--artifact| but compiled-code tests ({tests})'
+                       ' can\'t run against an artifact build. Try listing the suites you want'
+                       ' instead. For example, this syntax covers most suites:\n{try_syntax}')
+            string_format = {
+                'tests': ','.join(self.compiled_suites),
+                'try_syntax': try_syntax.replace(
+                    '-u all',
+                    '-u ' + ','.join(sorted(set(self.common_suites) - set(self.compiled_suites)))
+                )
+            }
+            raise ValueError(message.format(**string_format))
+
+        return try_syntax
 
     def _run_git(self, *args):
         args = ['git'] + list(args)
         ret = subprocess.call(args)
         if ret:
             print('ERROR git command %s returned %s' %
                   (args, ret))
             sys.exit(1)