Пример #1
0
def test_no_update():
    m = manifest.Manifest("")

    s1 = SourceFileWithTest("test1", "0" * 40, item.TestharnessTest)
    s2 = SourceFileWithTest("test2", "0" * 40, item.TestharnessTest)

    tree, sourcefile_mock = tree_and_sourcefile_mocks(
        (item, None, True) for item in [s1, s2])
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        m.update(tree)

    test1 = s1.manifest_items()[1][0]
    test2 = s2.manifest_items()[1][0]

    assert list(m) == [("testharness", test1.path, {test1}),
                       ("testharness", test2.path, {test2})]

    s1_1 = SourceFileWithTest("test1", "1" * 40, item.ManualTest)

    tree, sourcefile_mock = tree_and_sourcefile_mocks([(s1_1, None, True),
                                                       (s2, None, False)])
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        m.update(tree)

    test1_1 = s1_1.manifest_items()[1][0]

    assert list(m) == [("manual", test1_1.path, {test1_1}),
                       ("testharness", test2.path, {test2})]
Пример #2
0
def test_update_from_json_modified():
    # Create the original manifest
    m = manifest.Manifest("")
    s1 = SourceFileWithTest("test1", "0" * 40, item.TestharnessTest)
    tree, sourcefile_mock = tree_and_sourcefile_mocks([(s1, None, True)])
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        m.update(tree)
    json_str = m.to_json()

    # Reload it from JSON
    m = manifest.Manifest.from_json("/", json_str)

    # Update it with timeout="long"
    s2 = SourceFileWithTest("test1",
                            "1" * 40,
                            item.TestharnessTest,
                            timeout="long")
    tree, sourcefile_mock = tree_and_sourcefile_mocks([(s2, None, True)])
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        m.update(tree)
    json_str = m.to_json()
    assert json_str == {
        'items': {
            'testharness': {
                'test1': ["1" * 40, (None, {
                    'timeout': 'long'
                })]
            }
        },
        'url_base': '/',
        'version': 8
    }
Пример #3
0
def test_manifest_to_json(s):
    m = manifest.Manifest("")

    tree, sourcefile_mock = tree_and_sourcefile_mocks(
        (item, None, True) for item in s)
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        assert m.update(tree) is True

    json_str = m.to_json()
    loaded = manifest.Manifest.from_json("/", json_str)

    assert list(loaded) == list(m)

    assert loaded.to_json() == json_str
Пример #4
0
def test_manifest_idempotent(s):
    m = manifest.Manifest("")

    tree, sourcefile_mock = tree_and_sourcefile_mocks(
        (item, None, True) for item in s)
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        assert m.update(tree) is True

    m1 = list(m)

    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        assert m.update(tree) is False

    assert list(m) == m1
Пример #5
0
def test_no_update_delete():
    m = manifest.Manifest("")

    s1 = SourceFileWithTest("test1", "0" * 40, item.TestharnessTest)
    s2 = SourceFileWithTest("test2", "0" * 40, item.TestharnessTest)

    tree, sourcefile_mock = tree_and_sourcefile_mocks([(s1, None, True),
                                                       (s2, None, True)])
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        m.update(tree)

    test1 = s1.manifest_items()[1][0]

    tree, sourcefile_mock = tree_and_sourcefile_mocks([(s1, None, False)])
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        m.update(tree)

    assert list(m) == [("testharness", test1.path, {test1})]
Пример #6
0
def test_update_from_json():
    m = manifest.Manifest("")

    s1 = SourceFileWithTest("test1", "0" * 40, item.TestharnessTest)
    s2 = SourceFileWithTest("test2", "0" * 40, item.TestharnessTest)

    tree, sourcefile_mock = tree_and_sourcefile_mocks([(s1, None, True),
                                                       (s2, None, True)])
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        m.update(tree)

    json_str = m.to_json()
    m = manifest.Manifest.from_json("/", json_str)

    tree, sourcefile_mock = tree_and_sourcefile_mocks([(s1, None, True)])
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        m.update(tree)

    test1 = s1.manifest_items()[1][0]

    assert list(m) == [("testharness", test1.path, {test1})]
Пример #7
0
def test_iterpath():
    m = manifest.Manifest("")

    sources = [
        SourceFileWithTest("test1",
                           "0" * 40,
                           item.RefTest,
                           references=[("/test1-ref", "==")]),
        SourceFileWithTests("test2", "1" * 40, item.TestharnessTest,
                            [("test2-1.html", {}), ("test2-2.html", {})]),
        SourceFileWithTest("test3", "0" * 40, item.TestharnessTest)
    ]
    tree, sourcefile_mock = tree_and_sourcefile_mocks(
        (item, None, True) for item in sources)
    assert len(tree) == len(sources)
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        m.update(tree)

    assert {item.url
            for item in m.iterpath("test2")
            } == {"/test2-1.html", "/test2-2.html"}
    assert set(m.iterpath("missing")) == set()
Пример #8
0
def test_reftest_computation_chain():
    m = manifest.Manifest("")

    s1 = SourceFileWithTest("test1",
                            "0" * 40,
                            item.RefTest,
                            references=[("/test2", "==")])
    s2 = SourceFileWithTest("test2",
                            "0" * 40,
                            item.RefTest,
                            references=[("/test3", "==")])

    tree, sourcefile_mock = tree_and_sourcefile_mocks([(s1, None, True),
                                                       (s2, None, True)])
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        m.update(tree)

    test1 = s1.manifest_items()[1][0]
    test2 = s2.manifest_items()[1][0]

    assert list(m) == [("reftest", test1.path, {test1}),
                       ("reftest", test2.path, {test2})]
Пример #9
0
def test_manifest_to_json_forwardslash():
    m = manifest.Manifest("")

    s = SourceFileWithTest("a" + os.path.sep + "b", "0" * 40,
                           item.TestharnessTest)

    tree, sourcefile_mock = tree_and_sourcefile_mocks([(s, None, True)])
    with mock.patch("tools.manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        assert m.update(tree) is True

    assert m.to_json() == {
        'version': 8,
        'url_base': '/',
        'items': {
            'testharness': {
                'a': {
                    'b':
                    ['0000000000000000000000000000000000000000', (None, {})]
                }
            },
        }
    }