示例#1
0
def test_pr_commits_merge(env, git_wpt, git_gecko, git_wpt_upstream,
                          hg_gecko_upstream, upstream_gecko_commit):

    sync = setup_repo(env, git_wpt, git_gecko, hg_gecko_upstream,
                      upstream_gecko_commit)

    # Make changes on master
    git_wpt_upstream.branches.master.checkout()
    base = git_wpt_upstream.head.commit.hexsha
    git_commit(git_wpt_upstream, "Some other Commit",
               {"RANDOME_FILE": "Changes to this\n"})

    pr = env.gh_wpt.get_pull(sync.pr)

    # Create a ref on the upstream to simulate the pr than GH would setup
    git_wpt_upstream.create_head(
        'pr/%d' % pr['number'],
        commit=git_wpt_upstream.refs['gecko/1234'].commit.hexsha)

    # Merge our Sync PR
    git_wpt_upstream.git.merge('gecko/1234')
    pr['merge_commit_sha'] = str(git_wpt_upstream.active_branch.commit.hexsha)
    pr['base'] = {'sha': base}
    git_wpt.remotes.origin.fetch()

    with SyncLock.for_process(sync.process_name) as upstream_sync_lock:
        with sync.as_mut(upstream_sync_lock):
            upstream.update_pr(git_gecko, git_wpt, sync, "closed",
                               pr['merge_commit_sha'], pr['base']['sha'],
                               "test")
    pr_commits = sync.pr_commits

    for wpt_commit, pr_commit in zip(sync.wpt_commits._commits, pr_commits):
        assert wpt_commit.commit == pr_commit.commit
示例#2
0
def test_pr_commits_fast_forward(env, git_wpt, git_gecko, git_wpt_upstream,
                                 hg_gecko_upstream, upstream_gecko_commit):

    sync = setup_repo(env, git_wpt, git_gecko, hg_gecko_upstream,
                      upstream_gecko_commit)

    base = git_wpt_upstream.head.commit.hexsha

    pr = env.gh_wpt.get_pull(sync.pr)

    # Create a ref on the upstream to simulate the pr than GH would setup
    pr_head_commit = git_wpt_upstream.refs['gecko/1234'].commit.hexsha
    git_wpt_upstream.create_head('pr/%d' % pr['number'], commit=pr_head_commit)

    # Fast forward merge our Sync PR
    git_wpt_upstream.git.merge('gecko/1234')
    git_wpt_upstream.head.commit = pr_head_commit
    pr['merge_commit_sha'] = pr_head_commit
    pr['base'] = {'sha': base}
    git_wpt.remotes.origin.fetch()

    with SyncLock.for_process(sync.process_name) as upstream_sync_lock:
        with sync.as_mut(upstream_sync_lock):
            upstream.update_pr(git_gecko, git_wpt, sync, "closed",
                               pr['merge_commit_sha'], pr['base']['sha'],
                               "test")
    pr_commits = sync.pr_commits

    for wpt_commit, pr_commit in zip(sync.wpt_commits._commits, pr_commits):
        assert wpt_commit.commit == pr_commit.commit
示例#3
0
def test_land_pr(env, git_gecko, git_wpt, hg_gecko_upstream,
                 upstream_gecko_commit):
    bug = "1234"
    test_changes = {"README": "Change README\n"}
    rev = upstream_gecko_commit(test_changes=test_changes,
                                bug=bug,
                                message="Change README")

    update_repositories(git_gecko, git_wpt, wait_gecko_commit=rev)
    pushed, landed, failed = upstream.gecko_push(git_gecko,
                                                 git_wpt,
                                                 "autoland",
                                                 rev,
                                                 raise_on_error=True)

    syncs = upstream.UpstreamSync.for_bug(git_gecko, git_wpt, bug)
    assert syncs.keys() == ["open"]
    assert len(syncs["open"]) == 1
    sync = syncs["open"].pop()
    env.gh_wpt.get_pull(sync.pr).mergeable = True
    original_remote_branch = sync.remote_branch

    hg_gecko_upstream.bookmark("mozilla/central", "-r", rev)

    update_repositories(git_gecko, git_wpt, wait_gecko_commit=rev)
    pushed, landed, failed = upstream.gecko_push(git_gecko,
                                                 git_wpt,
                                                 "mozilla-central",
                                                 rev,
                                                 raise_on_error=True)

    syncs = upstream.UpstreamSync.for_bug(git_gecko, git_wpt, bug)
    assert syncs == {"wpt-merged": {sync}}
    assert sync.gecko_landed()
    assert sync.status == "wpt-merged"
    assert original_remote_branch not in git_wpt.remotes.origin.refs
    pr = env.gh_wpt.get_pull(sync.pr)
    assert pr.merged

    with SyncLock.for_process(sync.process_name) as lock:
        with sync.as_mut(lock):
            upstream.update_pr(git_gecko, git_wpt, sync, "closed",
                               pr["merge_commit_sha"], '',
                               pr["merged_by"]["login"])

    user = env.config["web-platform-tests"]["github"]["user"]
    assert ("Upstream PR merged by %s" %
            user) in env.bz.output.getvalue().strip().split('\n')