Bug 1410250 - Use transform for appending --mochitest-suite=<suite> et al, r?dustin draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 19 Oct 2017 14:34:59 -0400
changeset 683523 5bd2b8ebdc80ec184b1d3a879cfa566dafbeb046
parent 683249 31af3ee0436093bfd3300e9002f1118df0420309
child 683524 4cf468ba19160f3abb0c4c3628a328c3a8815b93
push id85403
push userahalberstadt@mozilla.com
push dateThu, 19 Oct 2017 21:36:48 +0000
reviewersdustin
bugs1410250
milestone58.0a1
Bug 1410250 - Use transform for appending --mochitest-suite=<suite> et al, r?dustin Every task that uses the desktop_unittest.py or android_emulator_unittest.py mozharness scripts needs to pass in either --<suite>-suite=<flavor>, or --test-suite=<flavor> respectively. In almost all cases, <suite> and <flavor> are identical to the value that is already specified under the test['suite'] key. This means we can use a transform to append these command line arguments and reduce the complexity of the yaml files. MozReview-Commit-ID: EaPlOzsESQ3
taskcluster/ci/test/compiled.yml
taskcluster/ci/test/mochitest.yml
taskcluster/ci/test/reftest.yml
taskcluster/ci/test/xpcshell.yml
taskcluster/taskgraph/transforms/tests.py
--- a/taskcluster/ci/test/compiled.yml
+++ b/taskcluster/ci/test/compiled.yml
@@ -12,32 +12,28 @@ cppunit:
             default: built-projects
     mozharness:
         by-test-platform:
             android.*:
                 script: android_emulator_unittest.py
                 no-read-buildbot-config: true
                 config:
                     - android/androidarm_4_3.py
-                extra-options:
-                    - --test-suite=cppunittest
             default:
                 script: desktop_unittest.py
                 no-read-buildbot-config: true
                 config:
                     by-test-platform:
                         windows.*:
                             - unittests/win_taskcluster_unittest.py
                         macosx.*:
                             - unittests/mac_unittest.py
                         linux.*:
                             - unittests/linux_unittest.py
                             - remove_executables.py
-                extra-options:
-                    - --cppunittest-suite=cppunittest
     tier:
         by-test-platform:
             windows10-64-asan.*: 3
             default: default
 
 gtest:
     description: "GTests run"
     suite: gtest
@@ -57,18 +53,16 @@ gtest:
             by-test-platform:
                 windows.*:
                     - unittests/win_taskcluster_unittest.py
                 macosx.*:
                     - unittests/mac_unittest.py
                 linux.*:
                     - unittests/linux_unittest.py
                     - remove_executables.py
-        extra-options:
-            - --gtest-suite=gtest
     tier:
         by-test-platform:
             windows7-32-pgo.*: 3
             windows10-64-pgo.*: 3
             windows10-64-asan.*: 3
             default: default
 
 jittest:
@@ -96,14 +90,12 @@ jittest:
             by-test-platform:
                 windows.*:
                     - unittests/win_taskcluster_unittest.py
                 macosx.*:
                     - unittests/mac_unittest.py
                 linux.*:
                     - unittests/linux_unittest.py
                     - remove_executables.py
-        extra-options:
-            - --jittest-suite=jittest-chunked
     tier:
         by-test-platform:
             windows10-64-asan.*: 3
             default: default
--- a/taskcluster/ci/test/mochitest.yml
+++ b/taskcluster/ci/test/mochitest.yml
@@ -54,22 +54,16 @@ mochitest:
                     by-test-platform:
                         windows.*:
                             - unittests/win_taskcluster_unittest.py
                         macosx.*:
                             - unittests/mac_unittest.py
                         linux.*:
                             - unittests/linux_unittest.py
                             - remove_executables.py
-                extra-options:
-                    by-test-platform:
-                        linux64-jsdcov/opt:
-                            - --mochitest-suite=plain-chunked-coverage
-                        default:
-                            - --mochitest-suite=plain-chunked
 
 mochitest-a11y:
     description: "Mochitest a11y run"
     suite: mochitest/a11y
     treeherder-symbol: tc-M(a11y)
     loopback-video: true
     e10s: false
     run-on-projects:
@@ -85,18 +79,16 @@ mochitest-a11y:
             by-test-platform:
                 windows.*:
                     - unittests/win_taskcluster_unittest.py
                 macosx.*:
                     - unittests/mac_unittest.py
                 linux.*:
                     - unittests/linux_unittest.py
                     - remove_executables.py
-        extra-options:
-            - --mochitest-suite=a11y
     tier:
         by-test-platform:
             windows10-64-asan.*: 3
             default: default
 
 mochitest-browser-chrome:
     description: "Mochitest browser-chrome run"
     suite:
@@ -137,22 +129,16 @@ mochitest-browser-chrome:
             by-test-platform:
                 windows.*:
                     - unittests/win_taskcluster_unittest.py
                 macosx.*:
                     - unittests/mac_unittest.py
                 linux.*:
                     - unittests/linux_unittest.py
                     - remove_executables.py
-        extra-options:
-            by-test-platform:
-                linux64-jsdcov/opt:
-                    - --mochitest-suite=browser-chrome-coverage
-                default:
-                    - --mochitest-suite=browser-chrome-chunked
     # Bug 1281241: migrating to m3.large instances
     instance-size:
         by-test-platform:
             linux64-jsdcov/opt: xlarge
             default: legacy
     allow-software-gl-layers: false
     tier:
         by-test-platform:
@@ -181,18 +167,16 @@ mochitest-browser-screenshots:
             by-test-platform:
                 windows.*:
                     - unittests/win_taskcluster_unittest.py
                 macosx.*:
                     - unittests/mac_unittest.py
                 linux.*:
                     - unittests/linux_unittest.py
                     - remove_executables.py
-        extra-options:
-            - --mochitest-suite=browser-chrome-screenshots
     allow-software-gl-layers: false
 
 mochitest-chrome:
     description: "Mochitest chrome run"
     suite: mochitest/chrome
     treeherder-symbol: tc-M(c)
     loopback-video: true
     instance-size:
@@ -230,18 +214,16 @@ mochitest-chrome:
                         windows.*:
                             - unittests/win_taskcluster_unittest.py
                         macosx.*:
                             - remove_executables.py
                             - unittests/mac_unittest.py
                         linux.*:
                             - unittests/linux_unittest.py
                             - remove_executables.py
-                extra-options:
-                    - --mochitest-suite=chrome
     tier:
         by-test-platform:
             windows10-64-asan.*: 3
             default: default
 
 mochitest-clipboard:
     description: "Mochitest clipboard run"
     suite: mochitest/clipboard
@@ -315,22 +297,16 @@ mochitest-devtools-chrome:
             by-test-platform:
                 windows.*:
                     - unittests/win_taskcluster_unittest.py
                 macosx.*:
                     - unittests/mac_unittest.py
                 linux.*:
                     - unittests/linux_unittest.py
                     - remove_executables.py
-        extra-options:
-            by-test-platform:
-                linux64-jsdcov/opt:
-                    - --mochitest-suite=mochitest-devtools-chrome-coverage
-                default:
-                    - --mochitest-suite=mochitest-devtools-chrome-chunked
     instance-size:
         by-test-platform:
             # Bug 1281241: migrating to m3.large instances
             linux64-asan/opt: legacy
             default: default
     # Bug 1296086: high number of intermittents observed with software GL and large instances
     allow-software-gl-layers: false
     tier:
@@ -400,18 +376,16 @@ mochitest-media:
     mozharness:
         by-test-platform:
             android.*:
                 mochitest-flavor: plain
                 script: android_emulator_unittest.py
                 no-read-buildbot-config: true
                 config:
                     - android/androidarm_4_3.py
-                extra-options:
-                    - --test-suite=mochitest-media
             default:
                 mochitest-flavor: plain
                 script: desktop_unittest.py
                 no-read-buildbot-config: true
                 chunked:
                   by-test-platform:
                     macosx64.*: false
                     windows10-64.*: false
@@ -420,18 +394,16 @@ mochitest-media:
                     by-test-platform:
                         windows.*:
                             - unittests/win_taskcluster_unittest.py
                         macosx.*:
                             - unittests/mac_unittest.py
                         linux.*:
                             - unittests/linux_unittest.py
                             - remove_executables.py
-                extra-options:
-                    - --mochitest-suite=mochitest-media
     tier:
         by-test-platform:
             linux64-qr/.*: 1
             windows10-64-asan.*: 3
             default: default
 
 mochitest-plain-headless:
     description: "Mochitest plain headless run"
@@ -456,17 +428,16 @@ mochitest-plain-headless:
                 windows.*:
                     - unittests/win_taskcluster_unittest.py
                 macosx.*:
                     - unittests/mac_unittest.py
                 linux.*:
                     - unittests/linux_unittest.py
                     - remove_executables.py
         extra-options:
-            - --mochitest-suite=plain-chunked
             - --headless
 
 mochitest-valgrind:
     description: "Mochitest plain Valgrind run"
     suite: mochitest/valgrind-plain
     treeherder-symbol: tc-M-V()
     run-on-projects: []
     tier: 3
@@ -486,18 +457,16 @@ mochitest-valgrind:
             by-test-platform:
                 windows.*:
                     - unittests/win_taskcluster_unittest.py
                 macosx.*:
                     - unittests/mac_unittest.py
                 linux.*:
                     - unittests/linux_unittest.py
                     - remove_executables.py
-        extra-options:
-            - --mochitest-suite=valgrind-plain
 
 mochitest-webgl:
     description: "Mochitest webgl run"
     suite: mochitest/mochitest-gl
     treeherder-symbol: tc-M(gl)
     virtualization: virtual-with-gpu
     chunks:
         by-test-platform:
@@ -523,31 +492,27 @@ mochitest-webgl:
     mozharness:
         by-test-platform:
             android.*:
                 mochitest-flavor: plain
                 script: android_emulator_unittest.py
                 no-read-buildbot-config: true
                 config:
                     - android/androidarm_4_3.py
-                extra-options:
-                    - --test-suite=mochitest-gl
             default:
                 mochitest-flavor: plain
                 script: desktop_unittest.py
                 no-read-buildbot-config: true
                 chunked: true
                 config:
                     by-test-platform:
                         windows.*:
                             - unittests/win_taskcluster_unittest.py
                         macosx.*:
                             - unittests/mac_unittest.py
                         linux.*:
                             - unittests/linux_unittest.py
                             - remove_executables.py
-                extra-options:
-                    - --mochitest-suite=mochitest-gl
     tier:
         by-test-platform:
             linux64-qr/.*: 1
             windows10-64-asan.*: 3
             default: default
--- a/taskcluster/ci/test/reftest.yml
+++ b/taskcluster/ci/test/reftest.yml
@@ -17,33 +17,29 @@ crashtest:
             default: true
     mozharness:
         by-test-platform:
             android.*:
                 script: android_emulator_unittest.py
                 no-read-buildbot-config: true
                 config:
                     - android/androidarm_4_3.py
-                extra-options:
-                    - --test-suite=crashtest
             default:
                 script: desktop_unittest.py
                 chunked: false
                 no-read-buildbot-config: true
                 config:
                     by-test-platform:
                         windows.*:
                             - unittests/win_taskcluster_unittest.py
                         macosx.*:
                             - unittests/mac_unittest.py
                         linux.*:
                             - unittests/linux_unittest.py
                             - remove_executables.py
-                extra-options:
-                    - --reftest-suite=crashtest
     tier:
         by-test-platform:
             linux64-qr/.*: 1
             windows10-64-asan.*: 3
             default: default
 
 jsreftest:
     description: "JS Reftest run"
@@ -73,33 +69,29 @@ jsreftest:
             default: 3600
     mozharness:
         by-test-platform:
             android.*:
                 script: android_emulator_unittest.py
                 no-read-buildbot-config: true
                 config:
                     - android/androidarm_4_3.py
-                extra-options:
-                    - --test-suite=jsreftest
             default:
                 script: desktop_unittest.py
                 no-read-buildbot-config: true
                 chunked: true
                 config:
                     by-test-platform:
                         windows.*:
                             - unittests/win_taskcluster_unittest.py
                         macosx.*:
                             - unittests/mac_unittest.py
                         linux.*:
                             - unittests/linux_unittest.py
                             - remove_executables.py
-                extra-options:
-                    - --reftest-suite=jsreftest
     when:
         schedules: ['jsreftest']
     tier:
         by-test-platform:
             linux64-qr/.*: 1
             windows10-64-asan.*: 3
             default: default
 
@@ -135,18 +127,16 @@ reftest:
             default: 3600
     mozharness:
         by-test-platform:
             android.*:
                 script: android_emulator_unittest.py
                 no-read-buildbot-config: true
                 config:
                     - android/androidarm_4_3.py
-                extra-options:
-                    - --test-suite=reftest
             default:
                 script: desktop_unittest.py
                 no-read-buildbot-config: true
                 chunked:
                   by-test-platform:
                     macosx64/opt: false
                     windows10-64.*/opt: false
                     windows10-64.*/debug: true
@@ -155,18 +145,16 @@ reftest:
                     by-test-platform:
                         windows.*:
                             - unittests/win_taskcluster_unittest.py
                         macosx.*:
                             - unittests/mac_unittest.py
                         linux.*:
                             - unittests/linux_unittest.py
                             - remove_executables.py
-                extra-options:
-                    - --reftest-suite=reftest
     tier:
         by-test-platform:
             linux64-qr/.*: 1
             windows10-64-asan.*: 3
             default: default
 
 reftest-gpu:
     description: "Reftest GPU run"
@@ -189,18 +177,16 @@ reftest-gpu:
             by-test-platform:
                 windows.*:
                     - unittests/win_taskcluster_unittest.py
                 macosx.*:
                     - unittests/mac_unittest.py
                 linux.*:
                     - unittests/linux_unittest.py
                     - remove_executables.py
-        extra-options:
-            - --reftest-suite=reftest-gpu
     tier: default
 
 reftest-no-accel:
     description: "Reftest not accelerated run"
     suite: reftest/reftest-no-accel
     treeherder-symbol: tc-R(Ru)
     virtualization: virtual-with-gpu
     worker-type:
@@ -230,18 +216,16 @@ reftest-no-accel:
             by-test-platform:
                 windows.*:
                     - unittests/win_taskcluster_unittest.py
                 macosx.*:
                     - unittests/mac_unittest.py
                 linux.*:
                     - unittests/linux_unittest.py
                     - remove_executables.py
-        extra-options:
-            - --reftest-suite=reftest-no-accel
     tier:
         by-test-platform:
             windows10-64-asan.*: 3
             default: default
 
 reftest-stylo:
     description: "Reftest run in Stylo vs. Gecko mode"
     suite: reftest/reftest-stylo
@@ -255,10 +239,8 @@ reftest-stylo:
             by-test-platform:
                 windows.*:
                     - unittests/win_taskcluster_unittest.py
                 macosx.*:
                     - unittests/mac_unittest.py
                 default:
                     - unittests/linux_unittest.py
                     - remove_executables.py
-        extra-options:
-            - --reftest-suite=reftest-stylo
--- a/taskcluster/ci/test/xpcshell.yml
+++ b/taskcluster/ci/test/xpcshell.yml
@@ -1,13 +1,13 @@
 xpcshell:
     description: "xpcshell test run"
     suite:
         by-test-platform:
-            linux64-jsdcov/opt: xpcshell-coverage
+            linux64-jsdcov/opt: xpcshell/xpcshell-coverage
             default: xpcshell
     treeherder-symbol: tc-X(X)
     run-on-projects:
         by-test-platform:
             linux64-qr/.*: ['mozilla-central', 'try']
             windows10-64-asan/opt: []  # No XPCShell on ASAN yet
             default: built-projects
     chunks:
@@ -25,18 +25,16 @@ xpcshell:
     max-run-time: 5400
     e10s: false
     allow-software-gl-layers: false
     mozharness:
         by-test-platform:
             android.*:
                 script: android_emulator_unittest.py
                 no-read-buildbot-config: true
-                extra-options:
-                    - --test-suite=xpcshell
                 config:
                     by-test-platform:
                         android-4.2-x86/opt:
                             - android/androidx86.py
                         default:
                             - android/androidarm_4_3.py
             default:
                 script: desktop_unittest.py
@@ -45,22 +43,16 @@ xpcshell:
                     by-test-platform:
                         windows.*:
                             - unittests/win_taskcluster_unittest.py
                         macosx.*:
                             - unittests/mac_unittest.py
                         linux.*:
                             - unittests/linux_unittest.py
                             - remove_executables.py
-                extra-options:
-                    by-test-platform:
-                        linux64-jsdcov/opt:
-                            - --xpcshell-suite=xpcshell-coverage
-                        default:
-                            - --xpcshell-suite=xpcshell
                 requires-signed-builds:
                     by-test-platform:
                         windows10-64-asan/opt: false    # No XPCShell on ASAN yet
                         windows.*: true
                         default: false
     tier:
         by-test-platform:
             windows10-64-asan.*: 3
--- a/taskcluster/taskgraph/transforms/tests.py
+++ b/taskcluster/taskgraph/transforms/tests.py
@@ -621,16 +621,46 @@ def handle_keyed_by(config, tests):
     for test in tests:
         for field in fields:
             resolve_keyed_by(test, field, item_name=test['test-name'],
                              project=config.params['project'])
         yield test
 
 
 @transforms.add
+def handle_suite_category(config, tests):
+    for test in tests:
+        if '/' in test['suite']:
+            suite, flavor = test['suite'].split('/', 1)
+        else:
+            suite = flavor = test['suite']
+
+        test.setdefault('attributes', {})
+        test['attributes']['unittest_suite'] = suite
+        test['attributes']['unittest_flavor'] = flavor
+
+        script = test['mozharness']['script']
+        category_arg = None
+        if suite == 'test-verification':
+            pass
+        elif script == 'android_emulator_unittest.py':
+            category_arg = '--test-suite'
+        elif script == 'desktop_unittest.py':
+            category_arg = '--{}-suite'.format(suite)
+
+        if category_arg:
+            test['mozharness'].setdefault('extra-options', [])
+            extra = test['mozharness']['extra-options']
+            if not any(arg.startswith(category_arg) for arg in extra):
+                extra.append('{}={}'.format(category_arg, flavor))
+
+        yield test
+
+
+@transforms.add
 def enable_code_coverage(config, tests):
     """Enable code coverage for the linux64-ccov/opt & linux64-jsdcov/opt build-platforms"""
     for test in tests:
         if test['build-platform'] == 'linux64-ccov/opt' and \
                 not test['test-name'].startswith('test-verify'):
             test['mozharness'].setdefault('extra-options', []).append('--code-coverage')
             test['when'] = {}
             test['instance-size'] = 'xlarge'
@@ -662,17 +692,16 @@ def handle_run_on_projects(config, tests
         yield test
 
 
 @transforms.add
 def split_e10s(config, tests):
     for test in tests:
         e10s = test['e10s']
 
-        test.setdefault('attributes', {})
         test['e10s'] = False
         test['attributes']['e10s'] = False
 
         if e10s == 'both':
             yield copy.deepcopy(test)
             e10s = True
         if e10s:
             test['test-name'] += '-e10s'
@@ -890,30 +919,22 @@ def make_job_description(config, tests):
         try_name = test['try-name']
         if test['suite'] == 'talos':
             attr_try_name = 'talos_try_name'
         else:
             attr_try_name = 'unittest_try_name'
 
         attr_build_platform, attr_build_type = test['build-platform'].split('/', 1)
 
-        suite = test['suite']
-        if '/' in suite:
-            suite, flavor = suite.split('/', 1)
-        else:
-            flavor = suite
-
         attributes = test.get('attributes', {})
         attributes.update({
             'build_platform': attr_build_platform,
             'build_type': attr_build_type,
             'test_platform': test['test-platform'],
             'test_chunk': str(test['this-chunk']),
-            'unittest_suite': suite,
-            'unittest_flavor': flavor,
             attr_try_name: try_name,
         })
 
         jobdesc = {}
         name = '{}-{}'.format(test['test-platform'], test['test-name'])
         jobdesc['name'] = name
         jobdesc['label'] = label
         jobdesc['description'] = test['description']
@@ -929,28 +950,28 @@ def make_job_description(config, tests):
         jobdesc['scopes'] = []
         jobdesc['tags'] = test.get('tags', {})
         jobdesc['extra'] = {
             'chunks': {
                 'current': test['this-chunk'],
                 'total': test['chunks'],
             },
             'suite': {
-                'name': suite,
-                'flavor': flavor,
+                'name': attributes['unittest_suite'],
+                'flavor': attributes['unittest_flavor'],
             },
         }
         jobdesc['treeherder'] = {
             'symbol': test['treeherder-symbol'],
             'kind': 'test',
             'tier': test['tier'],
             'platform': test.get('treeherder-machine-platform', test['build-platform']),
         }
 
-        schedules = [suite, platform_family(test['build-platform'])]
+        schedules = [attributes['unittest_suite'], platform_family(test['build-platform'])]
         when = test.get('when')
         if when and 'schedules' in when:
             schedules.extend(when['schedules'])
         if config.params['project'] != 'try':
             # for non-try branches, include SETA
             jobdesc['optimization'] = {'skip-unless-schedules-or-seta': schedules}
         else:
             # otherwise just use skip-unless-schedules