Exemplo n.º 1
0
def try_push(env, git_gecko, git_wpt, git_wpt_upstream, pull_request, set_pr_status,
             hg_gecko_try, mock_mach):
    pr = pull_request([(b"Test commit", {"README": b"example_change",
                                         "LICENSE": b"Some change"})])
    head_rev = pr._commits[0]["sha"]

    trypush.Mach = mock_mach
    with patch("sync.tree.is_open", Mock(return_value=True)):
        downstream.new_wpt_pr(git_gecko, git_wpt, pr)
        sync = set_pr_status(pr.number, "success")

        with SyncLock.for_process(sync.process_name) as sync_lock:
            git_wpt_upstream.head.commit = head_rev
            git_wpt.remotes.origin.fetch()
            landing.wpt_push(git_gecko, git_wpt, [head_rev], create_missing=False)

            with sync.as_mut(sync_lock):
                env.gh_wpt.get_pull(sync.pr).merged = True
                sync.data["affected-tests"] = {"Example": "affected"}
                sync.next_try_push()
                sync.data["force-metadata-ready"] = True

            try_push = sync.latest_try_push
            with try_push.as_mut(sync_lock):
                try_push.taskgroup_id = "abcdef"
    return sync.latest_try_push
Exemplo n.º 2
0
def test_landing_pr_on_central(env, git_gecko, git_wpt, git_wpt_upstream, pull_request,
                               set_pr_status, upstream_gecko_commit, mock_mach):
    # Ensure we handle the case where a PR already identical changes on central

    trypush.Mach = mock_mach

    test_changes = {"example/test.html": b"Change test\n"}
    more_changes = {"LICENSE": b"Change license\n"}

    for changes in [test_changes, more_changes]:
        pr = pull_request([(b"Test commit", changes)])
        downstream.new_wpt_pr(git_gecko, git_wpt, pr)
        downstream_sync = set_pr_status(pr.number, "success")
        head_rev = pr._commits[0]["sha"]
        git_wpt_upstream.head.commit = head_rev
        git_wpt.remotes.origin.fetch()
        landing.wpt_push(git_gecko, git_wpt, [head_rev], create_missing=False)

        with SyncLock.for_process(downstream_sync.process_name) as downstream_lock:
            with downstream_sync.as_mut(downstream_lock):
                downstream_sync.data["force-metadata-ready"] = True

    # Repeat the changes in m-c
    upstream_gecko_commit(test_changes=test_changes, bug=1234,
                          message=b"Change README")

    tree.is_open = lambda x: True
    sync = landing.update_landing(git_gecko, git_wpt)

    assert len(sync.wpt_commits) == 2
    assert len(sync.gecko_commits) == 3
    assert sync.gecko_commits[0].is_empty()
    assert sync.gecko_commits[-1].is_landing
Exemplo n.º 3
0
def test_land_commit(env, git_gecko, git_wpt, git_wpt_upstream, pull_request, set_pr_status,
                     hg_gecko_try, mock_mach, mock_tasks):
    pr = pull_request([(b"Test commit", {"README": b"example_change"})])
    head_rev = pr._commits[0]["sha"]

    trypush.Mach = mock_mach

    downstream.new_wpt_pr(git_gecko, git_wpt, pr)
    downstream_sync = set_pr_status(pr.number, "success")

    git_wpt_upstream.head.commit = head_rev
    git_wpt.remotes.origin.fetch()
    landing.wpt_push(git_gecko, git_wpt, [head_rev], create_missing=False)

    with SyncLock.for_process(downstream_sync.process_name) as downstream_lock:
        with downstream_sync.as_mut(downstream_lock):
            downstream_sync.data["force-metadata-ready"] = True

    tree.is_open = lambda x: True
    sync = landing.update_landing(git_gecko, git_wpt)

    assert ("Setting bug %s add_blocks %s" % (sync.bug, downstream_sync.bug)
            in env.bz.output.getvalue())

    try_push = sync.latest_try_push
    with SyncLock.for_process(sync.process_name) as lock:
        with sync.as_mut(lock), try_push.as_mut(lock):
            try_push.taskgroup_id = "abcdef"
            with patch.object(try_push, "download_logs", Mock(return_value=[])):
                with patch.object(tc.TaskGroup, "tasks",
                                  property(Mock(return_value=mock_tasks(completed=["foo"])))):
                    landing.try_push_complete(git_gecko, git_wpt, try_push, sync)

    assert "Pushed to try (stability)" in env.bz.output.getvalue()
    assert try_push.status == "complete"
    assert sync.status == "open"

    try_push = sync.latest_try_push
    with SyncLock.for_process(sync.process_name) as lock:
        with sync.as_mut(lock), try_push.as_mut(lock):
            try_push.taskgroup_id = "abcdef2"
            with patch.object(try_push, "download_logs", Mock(return_value=[])):
                with patch.object(tc.TaskGroup, "tasks",
                                  property(Mock(return_value=mock_tasks(completed=["foo"])))):
                    landing.try_push_complete(git_gecko, git_wpt, try_push, sync)

    new_head = git_gecko.remotes.mozilla.refs["bookmarks/mozilla/autoland"].commit
    assert "Update web-platform-tests to %s" % head_rev in new_head.message
    assert (new_head.tree["testing/web-platform/tests/README"].data_stream.read() ==
            b"example_change")
    sync_point = landing.load_sync_point(git_gecko, git_wpt)
    assert sync_point["upstream"] == head_rev
    # Update central to contain the landing
    git_gecko.refs["mozilla/bookmarks/mozilla/central"].commit = new_head
    with patch("sync.landing.start_next_landing") as start_next_landing:
        landing.gecko_push(git_gecko, git_wpt, "mozilla-central",
                           git_gecko.cinnabar.git2hg(new_head))
        assert start_next_landing.call_count == 1
    assert sync.status == "complete"
Exemplo n.º 4
0
def test_upstream_commit(env, git_gecko, git_wpt, git_wpt_upstream, pull_request):
    pr = pull_request([(b"Test commit", {"README": b"example_change"})])
    head_rev = pr._commits[0]["sha"]
    git_wpt_upstream.head.commit = head_rev
    git_wpt.remotes.origin.fetch()
    landing.wpt_push(git_gecko, git_wpt, [head_rev], create_missing=False)
    assert sync_commit.WptCommit(git_wpt_upstream,
                                 git_wpt_upstream.head.commit).pr() == pr["number"]
Exemplo n.º 5
0
def test_land_try(env, git_gecko, git_wpt, git_wpt_upstream, pull_request,
                  set_pr_status, hg_gecko_try, mock_mach):
    pr = pull_request([(b"Test commit", {
        "README": b"example_change",
        "resources/testdriver_vendor.js": b"Some change"
    })])
    head_rev = pr._commits[0]["sha"]

    trypush.Mach = mock_mach
    downstream.new_wpt_pr(git_gecko, git_wpt, pr)
    sync = set_pr_status(pr.number, "success")

    git_wpt_upstream.head.commit = head_rev
    git_wpt.remotes.origin.fetch()
    landing.wpt_push(git_gecko, git_wpt, [head_rev], create_missing=False)

    with SyncLock.for_process(sync.process_name) as downstream_lock:
        with sync.as_mut(downstream_lock):
            sync.data["force-metadata-ready"] = True

    tree.is_open = lambda x: True
    landing_sync = landing.update_landing(git_gecko, git_wpt)

    assert landing_sync is not None
    with SyncLock("landing", None) as lock:
        with landing_sync.as_mut(lock):
            worktree = landing_sync.gecko_worktree.get()
            # Check that files we shouldn't move aren't
            assert not os.path.exists(
                os.path.join(worktree.working_dir,
                             env.config["gecko"]["path"]["wpt"], ".git"))
            with open(
                    os.path.join(worktree.working_dir,
                                 env.config["gecko"]["path"]["wpt"],
                                 "resources/testdriver_vendor.js"), "rb") as f:
                assert f.read() == b"Initial testdriver_vendor\n"

    try_push = sync.latest_try_push
    assert try_push is None
    mach_command = mock_mach.get_log()[-1]
    assert mach_command["command"] == "mach"
    assert mach_command["args"] == ("try", "fuzzy", "-q",
                                    "web-platform-tests !ccov !shippable",
                                    "-q",
                                    "web-platform-tests linux-32 shippable",
                                    "-q",
                                    "web-platform-tests mac !debug shippable",
                                    "--disable-target-task-filter",
                                    "--artifact")
Exemplo n.º 6
0
def test_land_commit(env, git_gecko, git_wpt, git_wpt_upstream, pull_request,
                     set_pr_status, hg_gecko_try, mock_mach, mock_tasks):
    pr = pull_request([("Test commit", {"README": "example_change"})])
    head_rev = pr._commits[0]["sha"]

    trypush.Mach = mock_mach

    downstream.new_wpt_pr(git_gecko, git_wpt, pr)
    downstream_sync = set_pr_status(pr, "success")

    git_wpt_upstream.head.commit = head_rev
    git_wpt.remotes.origin.fetch()
    landing.wpt_push(git_gecko, git_wpt, [head_rev], create_missing=False)

    downstream_sync.data["force-metadata-ready"] = True

    tree.is_open = lambda x: True
    sync = landing.update_landing(git_gecko, git_wpt)

    # Set the landing sync point to current central
    sync.last_sync_point(git_gecko, "mozilla-central",
                         env.config["gecko"]["refs"]["central"])

    try_push = sync.latest_try_push
    try_push.taskgroup_id = "abcdef"
    with patch.object(try_push, "download_logs", Mock(return_value=[])):
        with patch.object(
                tc.TaskGroup, "tasks",
                property(Mock(return_value=mock_tasks(completed=["foo"])))):
            landing.try_push_complete(git_gecko, git_wpt, try_push, sync)

    assert sync.status == "open"
    new_head = git_gecko.remotes.mozilla.refs[
        "bookmarks/mozilla/inbound"].commit
    assert "Update web-platform-tests to %s" % head_rev in new_head.message
    assert new_head.tree["testing/web-platform/tests/README"].data_stream.read(
    ) == "example_change"
    sync_point = landing.load_sync_point(git_gecko, git_wpt)
    assert sync_point["local"] == new_head.parents[0].hexsha
    assert sync_point["upstream"] == head_rev
    # Update central to contain the landing
    git_gecko.refs["mozilla/bookmarks/mozilla/central"].commit = new_head
    with patch("sync.landing.tasks.land.apply_async") as mock_apply:
        landing.gecko_push(git_gecko, git_wpt, "mozilla-central",
                           git_gecko.cinnabar.git2hg(new_head))
        assert mock_apply.call_count == 1
    assert sync.status == "complete"
Exemplo n.º 7
0
def test_landing_metadata(env, git_gecko, git_wpt, git_wpt_upstream,
                          pull_request, set_pr_status, hg_gecko_try,
                          mock_mach):
    from conftest import create_file_data, gecko_changes

    trypush.Mach = mock_mach

    pr = pull_request([("Test commit", {
        "example/test1.html": "example_change"
    })])
    head_rev = pr._commits[0]["sha"]

    downstream.new_wpt_pr(git_gecko, git_wpt, pr)
    downstream_sync = set_pr_status(pr, "success")

    # Create a metadata commit
    with SyncLock.for_process(downstream_sync.process_name) as downstream_lock:
        with downstream_sync.as_mut(downstream_lock):
            git_work = downstream_sync.gecko_worktree.get()

            changes = gecko_changes(env,
                                    meta_changes={
                                        "example/test1.html":
                                        "[test1.html]\n  expected: FAIL"
                                    })
            file_data, _ = create_file_data(changes, git_work.working_dir)
            downstream_sync.ensure_metadata_commit()
            git_work.index.add(file_data)
            downstream_sync._commit_metadata()

            assert downstream_sync.metadata_commit is not None
            downstream_sync.data["force-metadata-ready"] = True

    git_wpt_upstream.head.commit = head_rev
    git_wpt.remotes.origin.fetch()

    landing.wpt_push(git_gecko, git_wpt, [head_rev], create_missing=False)

    tree.is_open = lambda x: True
    landing_sync = landing.update_landing(git_gecko, git_wpt)

    assert len(landing_sync.gecko_commits) == 3
    assert landing_sync.gecko_commits[-1].metadata["wpt-type"] == "landing"
    assert landing_sync.gecko_commits[-2].metadata["wpt-type"] == "metadata"
    for item in file_data:
        assert item in landing_sync.gecko_commits[-2].commit.stats.files
Exemplo n.º 8
0
def test_land_try(env, git_gecko, git_wpt, git_wpt_upstream, pull_request,
                  set_pr_status, hg_gecko_try, mock_mach):
    pr = pull_request([("Test commit", {
        "README": "example_change",
        "LICENSE": "Some change"
    })])
    head_rev = pr._commits[0]["sha"]

    trypush.Mach = mock_mach
    downstream.new_wpt_pr(git_gecko, git_wpt, pr)
    sync = set_pr_status(pr, "success")

    git_wpt_upstream.head.commit = head_rev
    git_wpt.remotes.origin.fetch()
    landing.wpt_push(git_gecko, git_wpt, [head_rev], create_missing=False)

    sync.data["force-metadata-ready"] = True

    tree.is_open = lambda x: True
    landing_sync = landing.update_landing(git_gecko, git_wpt)

    assert landing_sync is not None
    worktree = landing_sync.gecko_worktree.get()
    # Check that files we shouldn't move aren't
    assert not os.path.exists(
        os.path.join(worktree.working_dir, env.config["gecko"]["path"]["wpt"],
                     ".git"))
    with open(
            os.path.join(worktree.working_dir,
                         env.config["gecko"]["path"]["wpt"], "LICENSE")) as f:
        assert f.read() == "Initial license\n"

    try_push = sync.latest_try_push
    assert try_push is not None
    assert try_push.status == "open"
    assert try_push.stability is False
    mach_command = mock_mach.get_log()[-1]
    assert mach_command["command"] == "mach"
    assert mach_command["args"] == ("try", "fuzzy", "-q",
                                    "web-platform-tests !pgo !ccov !msvc",
                                    "--artifact")
Exemplo n.º 9
0
def try_push(env, git_gecko, git_wpt, git_wpt_upstream, pull_request,
             set_pr_status, hg_gecko_try, mock_mach):
    pr = pull_request([("Test commit", {
        "README": "example_change",
        "LICENSE": "Some change"
    })])
    head_rev = pr._commits[0]["sha"]

    trypush.Mach = mock_mach
    downstream.new_wpt_pr(git_gecko, git_wpt, pr)
    sync = set_pr_status(pr, "success")

    git_wpt_upstream.head.commit = head_rev
    git_wpt.remotes.origin.fetch()
    landing.wpt_push(git_gecko, git_wpt, [head_rev], create_missing=False)

    sync.data["force-metadata-ready"] = True

    tree.is_open = lambda x: True
    sync.latest_try_push.taskgroup_id = "abcdef"
    return sync.latest_try_push
Exemplo n.º 10
0
def test_landable_skipped(env, git_gecko, git_wpt, git_wpt_upstream, pull_request, set_pr_status,
                          mock_mach):
    prev_wpt_head = git_wpt_upstream.head.commit
    pr = pull_request([(b"Test commit", {"README": b"example_change"})])
    head_rev = pr._commits[0]["sha"]

    trypush.Mach = mock_mach

    downstream.new_wpt_pr(git_gecko, git_wpt, pr)
    downstream_sync = set_pr_status(pr.number, "success")

    with SyncLock.for_process(downstream_sync.process_name) as downstream_lock:
        with downstream_sync.as_mut(downstream_lock):
            downstream_sync.skip = True

    git_wpt_upstream.head.commit = head_rev
    git_wpt.remotes.origin.fetch()
    landing.wpt_push(git_gecko, git_wpt, [head_rev], create_missing=False)

    wpt_head, landable_commits = landing.landable_commits(git_gecko, git_wpt, prev_wpt_head.hexsha)
    assert len(landable_commits) == 1
    assert landable_commits[0][0] == pr.number
    assert landable_commits[0][1] == downstream_sync