Bug 1321330: fix some aliasing issues; r=jmaher
authorDustin J. Mitchell <dustin@mozilla.com>
Wed, 30 Nov 2016 18:45:55 +0000
changeset 324868 8c4f3476db84e9e779db63d6460a8dc6baa1c4f9
parent 324867 6c94c769aaef9042b594ebbdec5640c7582d3c17
child 324869 800a887c705e02042a53d9093e9c4feb4a4c97cb
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjmaher
bugs1321330, 1302192
milestone53.0a1
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
taskcluster/taskgraph/transforms/base.py
taskcluster/taskgraph/transforms/tests/desktop_test.py
--- 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.
     """
     try:
-        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:
             msg.append(str(error))
         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',
                             item_name=test['test-name'])
         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
 
 
 @transforms.add
 def allow_software_gl_layers(config, tests):
     for test in tests:
 
         # since this value defaults to true, but is not applicable on windows,