Bug 1321330: fix some aliasing issues; r=jmaher
authorDustin J. Mitchell <dustin@mozilla.com>
Wed, 30 Nov 2016 18:45:55 +0000
changeset 324858 8c4f3476db84e9e779db63d6460a8dc6baa1c4f9
parent 324857 6c94c769aaef9042b594ebbdec5640c7582d3c17
child 324859 800a887c705e02042a53d9093e9c4feb4a4c97cb
push id84525
push userphilringnalda@gmail.com
push dateThu, 01 Dec 2016 03:22:09 +0000
treeherdermozilla-inbound@b1d875f4c673 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1321330, 1302192
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1321330: fix some aliasing issues; r=jmaher Always copy objects after schema validation applies defaults, in case the defaults are mutable (`.., default=[]`) When duplicating objects for e10s, copy *before* yielding, as the object will be mutated before the yield returns. As a consequence of the previous point, tests have not yet had `extra-options` expanded via `by-test-platform` when it comes time to append to it, so perform that expansion early. This will get cleaner when bug 1302192 is completd. MozReview-Commit-ID: 76z4OlqZg82
--- a/taskcluster/taskgraph/transforms/base.py
+++ b/taskcluster/taskgraph/transforms/base.py
@@ -1,15 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 from __future__ import absolute_import, print_function, unicode_literals
 import re
+import copy
 import pprint
 import voluptuous
 class TransformConfig(object):
     """A container for configuration affecting transforms.  The `config`
     argument to transforms is an instance of this class, possibly with
     additional kind-specific attributes beyond those set here."""
@@ -60,17 +61,18 @@ class TransformSequence(object):
 def validate_schema(schema, obj, msg_prefix):
     Validate that object satisfies schema.  If not, generate a useful exception
     beginning with msg_prefix.
-        return schema(obj)
+        # deep copy the result since it may include mutable defaults
+        return copy.deepcopy(schema(obj))
     except voluptuous.MultipleInvalid as exc:
         msg = [msg_prefix]
         for error in exc.errors:
         raise Exception('\n'.join(msg) + '\n' + pprint.pformat(obj))
 def get_keyed_by(item, field, item_name, subfield=None):
--- a/taskcluster/taskgraph/transforms/tests/desktop_test.py
+++ b/taskcluster/taskgraph/transforms/tests/desktop_test.py
@@ -68,28 +68,31 @@ def split_e10s(config, tests):
     for test in tests:
         e10s = get_keyed_by(item=test, field='e10s',
         test.setdefault('attributes', {})
         test['e10s'] = False
         test['attributes']['e10s'] = False
         if e10s == 'both':
-            yield test
-            test = copy.deepcopy(test)
+            yield copy.deepcopy(test)
             e10s = True
         if e10s:
             test['test-name'] += '-e10s'
             test['e10s'] = True
             test['attributes']['e10s'] = True
             group, symbol = split_symbol(test['treeherder-symbol'])
             if group != '?':
                 group += '-e10s'
             test['treeherder-symbol'] = join_symbol(group, symbol)
-            test['mozharness'].setdefault('extra-options', []).append('--e10s')
+            test['mozharness']['extra-options'] = get_keyed_by(item=test,
+                                                               field='mozharness',
+                                                               subfield='extra-options',
+                                                               item_name=test['test-name'])
+            test['mozharness']['extra-options'].append('--e10s')
         yield test
 def allow_software_gl_layers(config, tests):
     for test in tests:
         # since this value defaults to true, but is not applicable on windows,