Bug 1576991 - Ensure expected is correctly inserted merging wpt ini files - r=maja_zf
authorJames Graham <james@hoppipolla.co.uk>
Wed, 28 Aug 2019 13:37:58 +0000
changeset 554164 a5f33d0358d3d308433110112d47fa804936373d
parent 554163 366ce74393fc40912937e21ff5601c0641404625
child 554165 6b46ba61a963aafd99e15166c45b7297679bb8f7
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1576991
milestone70.0a1
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 1576991 - Ensure expected is correctly inserted merging wpt ini files - r=maja_zf We can't parse files where the key-value pairs are after the subtest data, so ensure that we add it before. Also fix a bug when metadata is added on one side of the merge but unchanged on the other; we were accidentially inserting the entire test rather than just the expected value. Differential Revision: https://phabricator.services.mozilla.com/D43658
testing/web-platform/metamerge.py
testing/web-platform/test_metamerge.py
--- a/testing/web-platform/metamerge.py
+++ b/testing/web-platform/metamerge.py
@@ -67,17 +67,17 @@ class TestManifestItem(ExpectedManifest)
                 item.remove()
                 del self._data["expected"]
                 break
 
         for item in other_manifest.node.children:
             if isinstance(item, KeyValueNode) and item.data == "expected":
                 assert "expected" in other_manifest._data
                 item.remove()
-                self.node.children.append(item)
+                self.node.children.insert(0, item)
                 self._data["expected"] = other_manifest._data.pop("expected")
                 break
 
 
 def data_cls_getter(output_node, visited_node):
     # visited_node is intentionally unused
     if output_node is None:
         return ExpectedManifest
@@ -153,17 +153,17 @@ def compare_test(test, ancestor_manifest
             changes.added.append((subtest, subtest_manifest))
 
     return changes
 
 
 def compare_expected(changes, subtest, ancestor_manifest, new_manifest):
     if (not (ancestor_manifest and ancestor_manifest.has_key("expected")) and
         (new_manifest and new_manifest.has_key("expected"))):
-        changes.added.append((subtest, new_manifest))
+        changes.modified.append(ExpectedModified(subtest, ancestor_manifest, new_manifest))
     elif (ancestor_manifest and ancestor_manifest.has_key("expected") and
           not (new_manifest and new_manifest.has_key("expected"))):
         changes.deleted.append(subtest)
     elif (ancestor_manifest and ancestor_manifest.has_key("expected") and
           new_manifest and new_manifest.has_key("expected")):
         old_expected = ancestor_manifest.get("expected")
         new_expected = new_manifest.get("expected")
         if expected_values_changed(old_expected, new_expected):
--- a/testing/web-platform/test_metamerge.py
+++ b/testing/web-platform/test_metamerge.py
@@ -39,16 +39,24 @@ global-current-changed: A
 
 [test-modified.html]
   expected: TIMEOUT
 
 [new-modified-current-deleted.html]
   expected:
     if os == "linux": FAIL
     TIMEOUT
+
+[new-add-expected-with-subtest.html]
+  [subtest]
+    expected: FAIL
+
+[current-add-expected-with-subtest.html]
+  [subtest]
+    expected: FAIL
 """
 
 new = """
 global-new-added: A
 global-new-changed: B
 global-current-deleted: A
 global-current-changed: A
 
@@ -86,16 +94,25 @@ global-current-changed: A
   expected:
     if os == "linux": FAIL
 
 [new-modified-current-deleted.html]
   expected:
     if os == "linux": FAIL
     if os == "mac": FAIL
     TIMEOUT
+
+[new-add-expected-with-subtest.html]
+  expected: FAIL
+  [subtest]
+    expected: FAIL
+
+[current-add-expected-with-subtest.html]
+  [subtest]
+    expected: FAIL
 """
 
 current = """
 global-new-deleted: A
 global-new-changed: A
 global-current-added: A
 global-current-changed: B
 
@@ -117,16 +134,25 @@ global-current-changed: B
 
 [new-deleted-test.html]
   [Deleted subtest]
     expected: FAIL
 
 [current-added-test.html]
   [Added subtest]
     expected: FAIL
+
+[new-add-expected-with-subtest.html]
+  [subtest]
+    expected: FAIL
+
+[current-add-expected-with-subtest.html]
+  expected: FAIL
+  [subtest]
+    expected: FAIL
 """
 
 updated = """global-new-deleted: A
 global-new-changed: A
 global-current-added: A
 global-current-changed: B
 [failing-test.html]
   [Unchanged subtest]
@@ -136,55 +162,68 @@ global-current-changed: B
     expected:
       if os == "linux": FAIL
       TIMEOUT
 
   [Current added subtest]
     expected: FAIL
 
   [Ancestor no expected new expected]
+    expected: FAIL
     bug: 1234
-    expected: FAIL
 
   [New added subtest]
     expected: FAIL
 
   [New modified current deleted]
     expected: TIMEOUT
 
 
 [current-added-test.html]
   [Added subtest]
     expected: FAIL
 
 
+[new-add-expected-with-subtest.html]
+  expected: FAIL
+  [subtest]
+    expected: FAIL
+
+
+[current-add-expected-with-subtest.html]
+  expected: FAIL
+  [subtest]
+    expected: FAIL
+
+
 [new-added-test.html]
   [Added subtest]
     expected: FAIL
 
 
+[test-modified.html]
+  expected:
+    if os == "linux": FAIL
+
 [new-modified-current-deleted.html]
   expected:
     if os == "linux": FAIL
     if os == "mac": FAIL
     TIMEOUT
-
-[test-modified.html]
-  expected:
-    if os == "linux": FAIL
 """
 
 
 def test_merge():
     def get_manifest(str_data):
         bytes_io = BytesIO(str_data)
         return metamerge.compile(bytes_io,
                                  metamerge.data_cls_getter)
     ancestor_manifest = get_manifest(ancestor)
     current_manifest = get_manifest(current)
     new_manifest = get_manifest(new)
 
-    assert metamerge.make_changes(ancestor_manifest,
-                                  current_manifest,
-                                  new_manifest) == updated
+    result = metamerge.make_changes(ancestor_manifest,
+                                    current_manifest,
+                                    new_manifest)
+    assert result == updated
 
 if __name__ == '__main__':
     mozunit.main()