2019-08-09 20:48:53 +03:00
|
|
|
from io import BytesIO
|
|
|
|
|
|
|
|
import metamerge
|
2022-12-21 17:38:37 +03:00
|
|
|
import mozunit
|
2019-08-09 20:48:53 +03:00
|
|
|
|
|
|
|
ancestor = """
|
|
|
|
global-new-deleted: A
|
|
|
|
global-new-changed: A
|
|
|
|
global-current-deleted: A
|
|
|
|
global-current-changed: A
|
|
|
|
|
|
|
|
[failing-test.html]
|
|
|
|
[Unchanged subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[New deleted subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[New modified subtest]
|
|
|
|
expected: TIMEOUT
|
|
|
|
|
|
|
|
[Current deleted subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[New modified current deleted]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[Ancestor no expected new expected]
|
|
|
|
bug: 1234
|
|
|
|
|
|
|
|
[new-deleted-test.html]
|
|
|
|
[Deleted subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[current-deleted-test.html]
|
|
|
|
[Deleted subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[test-modified.html]
|
|
|
|
expected: TIMEOUT
|
|
|
|
|
|
|
|
[new-modified-current-deleted.html]
|
|
|
|
expected:
|
|
|
|
if os == "linux": FAIL
|
|
|
|
TIMEOUT
|
2019-08-28 16:37:58 +03:00
|
|
|
|
|
|
|
[new-add-expected-with-subtest.html]
|
|
|
|
[subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[current-add-expected-with-subtest.html]
|
|
|
|
[subtest]
|
|
|
|
expected: FAIL
|
2019-08-09 20:48:53 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
new = """
|
|
|
|
global-new-added: A
|
|
|
|
global-new-changed: B
|
|
|
|
global-current-deleted: A
|
|
|
|
global-current-changed: A
|
|
|
|
|
|
|
|
[failing-test.html]
|
|
|
|
[Unchanged subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[New added subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[New modified subtest]
|
|
|
|
expected:
|
|
|
|
if os == "linux": FAIL
|
|
|
|
TIMEOUT
|
|
|
|
|
|
|
|
[Current deleted subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[New modified current deleted]
|
|
|
|
expected: TIMEOUT
|
|
|
|
|
|
|
|
[Ancestor no expected new expected]
|
|
|
|
bug: 1234
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[new-added-test.html]
|
|
|
|
[Added subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[current-deleted-test.html]
|
|
|
|
[Deleted 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
|
2019-08-28 16:37:58 +03:00
|
|
|
|
|
|
|
[new-add-expected-with-subtest.html]
|
|
|
|
expected: FAIL
|
|
|
|
[subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[current-add-expected-with-subtest.html]
|
|
|
|
[subtest]
|
|
|
|
expected: FAIL
|
2019-08-09 20:48:53 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
current = """
|
|
|
|
global-new-deleted: A
|
|
|
|
global-new-changed: A
|
|
|
|
global-current-added: A
|
|
|
|
global-current-changed: B
|
|
|
|
|
|
|
|
[failing-test.html]
|
|
|
|
[Unchanged subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[New deleted subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[New modified subtest]
|
|
|
|
expected: TIMEOUT
|
|
|
|
|
|
|
|
[Current added subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[Ancestor no expected new expected]
|
|
|
|
bug: 1234
|
|
|
|
|
|
|
|
[new-deleted-test.html]
|
|
|
|
[Deleted subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[current-added-test.html]
|
|
|
|
[Added subtest]
|
|
|
|
expected: FAIL
|
2019-08-28 16:37:58 +03:00
|
|
|
|
|
|
|
[new-add-expected-with-subtest.html]
|
|
|
|
[subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[current-add-expected-with-subtest.html]
|
|
|
|
expected: FAIL
|
|
|
|
[subtest]
|
|
|
|
expected: FAIL
|
2019-08-09 20:48:53 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
updated = """global-new-deleted: A
|
|
|
|
global-new-changed: A
|
|
|
|
global-current-added: A
|
|
|
|
global-current-changed: B
|
|
|
|
[failing-test.html]
|
|
|
|
[Unchanged subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[New modified subtest]
|
|
|
|
expected:
|
|
|
|
if os == "linux": FAIL
|
|
|
|
TIMEOUT
|
|
|
|
|
|
|
|
[Current added subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[Ancestor no expected new expected]
|
|
|
|
expected: FAIL
|
2019-08-28 16:37:58 +03:00
|
|
|
bug: 1234
|
2019-08-09 20:48:53 +03:00
|
|
|
|
|
|
|
[New added subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
[New modified current deleted]
|
|
|
|
expected: TIMEOUT
|
|
|
|
|
|
|
|
|
|
|
|
[current-added-test.html]
|
|
|
|
[Added subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
|
2019-08-28 16:37:58 +03:00
|
|
|
[new-add-expected-with-subtest.html]
|
|
|
|
expected: FAIL
|
|
|
|
[subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
|
|
|
|
[current-add-expected-with-subtest.html]
|
|
|
|
expected: FAIL
|
|
|
|
[subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
|
2019-08-09 20:48:53 +03:00
|
|
|
[new-added-test.html]
|
|
|
|
[Added subtest]
|
|
|
|
expected: FAIL
|
|
|
|
|
|
|
|
|
2019-08-28 16:37:58 +03:00
|
|
|
[test-modified.html]
|
2019-08-09 20:48:53 +03:00
|
|
|
expected:
|
|
|
|
if os == "linux": FAIL
|
|
|
|
|
2019-08-28 16:37:58 +03:00
|
|
|
[new-modified-current-deleted.html]
|
2019-08-09 20:48:53 +03:00
|
|
|
expected:
|
|
|
|
if os == "linux": FAIL
|
2019-08-28 16:37:58 +03:00
|
|
|
if os == "mac": FAIL
|
|
|
|
TIMEOUT
|
2019-08-09 20:48:53 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def test_merge():
|
|
|
|
def get_manifest(str_data):
|
2020-09-29 17:22:49 +03:00
|
|
|
bytes_io = BytesIO(str_data.encode("utf-8"))
|
2019-08-09 20:48:53 +03:00
|
|
|
return metamerge.compile(bytes_io, metamerge.data_cls_getter)
|
2020-10-26 21:34:53 +03:00
|
|
|
|
2019-08-09 20:48:53 +03:00
|
|
|
ancestor_manifest = get_manifest(ancestor)
|
|
|
|
current_manifest = get_manifest(current)
|
|
|
|
new_manifest = get_manifest(new)
|
|
|
|
|
2019-08-28 16:37:58 +03:00
|
|
|
result = metamerge.make_changes(ancestor_manifest, current_manifest, new_manifest)
|
|
|
|
assert result == updated
|
2019-08-09 20:48:53 +03:00
|
|
|
|
2020-09-29 17:22:49 +03:00
|
|
|
|
2019-08-09 20:48:53 +03:00
|
|
|
if __name__ == "__main__":
|
|
|
|
mozunit.main()
|