fune/testing/web-platform/test_metamerge.py
Ricky Stewart 02a7b4ebdf Bug 1654103: Standardize on Black for Python code in mozilla-central.
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly.

To produce this patch I did all of the following:

1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions.

2. Run ./mach lint --linter black --fix

3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks.

4. Make some ad-hoc manual updates to `testing/marionette/client/setup.py`, `testing/marionette/harness/setup.py`, and `testing/firefox-ui/harness/setup.py`, which have hard-coded regexes that break after the reformat.

5. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023).

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D94045
2020-10-26 18:34:53 +00:00

228 lines
3.8 KiB
Python

from io import BytesIO
import mozunit
import metamerge
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
[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
[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
[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
[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
[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]
expected: FAIL
[New modified subtest]
expected:
if os == "linux": FAIL
TIMEOUT
[Current added subtest]
expected: FAIL
[Ancestor no expected new expected]
expected: FAIL
bug: 1234
[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
"""
def test_merge():
def get_manifest(str_data):
bytes_io = BytesIO(str_data.encode("utf-8"))
return metamerge.compile(bytes_io, metamerge.data_cls_getter)
ancestor_manifest = get_manifest(ancestor)
current_manifest = get_manifest(current)
new_manifest = get_manifest(new)
result = metamerge.make_changes(ancestor_manifest, current_manifest, new_manifest)
assert result == updated
if __name__ == "__main__":
mozunit.main()