Bug 1354232 - Support creating ConditionalValue objects containing a list, r=maja_zf
authorJames Graham <james@hoppipolla.co.uk>
Tue, 29 May 2018 23:42:23 +0100
changeset 1555229 d2d3ad95784696cdd9cb7be7aa5b7d7e023f68d5
parent 1555228 5d9db023723c554add548698eb7828f1ea4a299d
child 1555230 a14c73b1ed2846f8d386d29fa274fcab9318dd15
push id282197
push userjames@hoppipolla.co.uk
push dateTue, 03 Jul 2018 20:12:38 +0000
treeherdertry@03ac4554ef3e [default view] [failures only]
reviewersmaja_zf
bugs1354232
milestone63.0a1
Bug 1354232 - Support creating ConditionalValue objects containing a list, r=maja_zf MozReview-Commit-ID: 5SSt1oeQj7v
testing/web-platform/tests/tools/wptrunner/wptrunner/wptmanifest/backends/conditional.py
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/wptmanifest/backends/conditional.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/wptmanifest/backends/conditional.py
@@ -21,17 +21,24 @@ class ConditionalValue(object):
     def value(self):
         if isinstance(self.value_node, ValueNode):
             return self.value_node.data
         else:
             return [item.data for item in self.value_node.children]
 
     @value.setter
     def value(self, value):
-        self.value_node.data = value
+        if isinstance(self.value_node, ValueNode):
+            self.value_node.data = value
+        else:
+            assert(isinstance(self.value_node, ListNode))
+            for child in self.value_node.children:
+                child.remove()
+            for list_value in value:
+                self.value_node.append(ValueNode(list_value))
 
     def __call__(self, run_info):
         return self.condition_func(run_info)
 
     def set_value(self, value):
         if type(value) not in (str, unicode):
             value = unicode(value)
         self.value = value
@@ -262,17 +269,22 @@ class ManifestItem(object):
                     node = child
                     break
             assert node is not None
 
         else:
             node = KeyValueNode(key)
             self.node.append(node)
 
-        value_node = ValueNode(unicode(value))
+        if isinstance(value, list):
+            value_node = ListNode()
+            for item in value:
+                value_node.append(ValueNode(unicode(item)))
+        else:
+            value_node = ValueNode(unicode(value))
         if condition is not None:
             conditional_node = ConditionalNode()
             conditional_node.append(condition)
             conditional_node.append(value_node)
             node.append(conditional_node)
             cond_value = Compiler().compile_condition(conditional_node)
         else:
             node.append(value_node)