diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2019-12-10 10:59:01 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-12-10 12:35:10 +0100 |
| commit | 4538d6d746f2dc7443cb25940513ef23dbb275f0 (patch) | |
| tree | 7f6e3ccbe559cf8de8a4aa60fbb444006532158a /pkg | |
| parent | e068fcf62261c6ecd6416418c7adcba000213072 (diff) | |
pkg/bisect: add test for #1527
Update #1527
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/bisect/bisect_test.go | 26 | ||||
| -rw-r--r-- | pkg/vcs/git_repo_test.go | 7 | ||||
| -rw-r--r-- | pkg/vcs/git_test_util.go (renamed from pkg/vcs/test_util.go) | 38 |
3 files changed, 49 insertions, 22 deletions
diff --git a/pkg/bisect/bisect_test.go b/pkg/bisect/bisect_test.go index 56e5e5ccb..701b35edc 100644 --- a/pkg/bisect/bisect_test.go +++ b/pkg/bisect/bisect_test.go @@ -74,7 +74,18 @@ func runBisection(t *testing.T, test BisectionTest) (*Result, error) { } for rv := 4; rv < 10; rv++ { for i := 0; i < 6; i++ { - repo.CommitChange(fmt.Sprintf("%v", rv*100+i)) + if rv == 7 && i == 0 { + // Create a slightly special commit graph here (for #1527): + // Commit 650 is part of 700 release, but it does not have + // 600 (the previous release) in parents, instead it's based + // on the previous-previous release 500. + repo.Git("checkout", "v5.0") + com := repo.CommitChange("650") + repo.Git("checkout", "master") + repo.Git("merge", "-m", "700", com.Hash) + } else { + repo.CommitChange(fmt.Sprintf("%v", rv*100+i)) + } if i == 0 { repo.SetTag(fmt.Sprintf("v%v.0", rv)) } @@ -168,7 +179,7 @@ func TestBisectionResults(t *testing.T) { startCommit: 802, brokenStart: 500, brokenEnd: 700, - commitLen: 14, + commitLen: 15, culprit: 605, }, // Tests that bisection returns the correct fix commit. @@ -296,6 +307,17 @@ func TestBisectionResults(t *testing.T) { culprit: 900, isRelease: true, }, + { + name: "cause-not-in-previous-release", + startCommit: 905, + culprit: 650, + commitLen: 1, + expectRep: true, + sameBinaryStart: 500, + sameBinaryEnd: 650, + // This should be (see #1527): + // noopChange: true, + }, } for _, test := range tests { test := test diff --git a/pkg/vcs/git_repo_test.go b/pkg/vcs/git_repo_test.go index e1d317ea2..ffdba7f9d 100644 --- a/pkg/vcs/git_repo_test.go +++ b/pkg/vcs/git_repo_test.go @@ -410,3 +410,10 @@ func TestBisect(t *testing.T) { } } } + +type testWriter testing.T + +func (t *testWriter) Write(data []byte) (int, error) { + (*testing.T)(t).Log(string(data)) + return len(data), nil +} diff --git a/pkg/vcs/test_util.go b/pkg/vcs/git_test_util.go index 148360a08..86713bac0 100644 --- a/pkg/vcs/test_util.go +++ b/pkg/vcs/git_test_util.go @@ -16,13 +16,6 @@ const ( extractFixTagsEmail = `"syzbot" <syzbot@my.mail.com>` ) -type testWriter testing.T - -func (t *testWriter) Write(data []byte) (int, error) { - (*testing.T)(t).Log(string(data)) - return len(data), nil -} - type TestRepo struct { t *testing.T Dir string @@ -31,7 +24,7 @@ type TestRepo struct { repo *git } -func (repo *TestRepo) git(args ...string) { +func (repo *TestRepo) Git(args ...string) { if _, err := osutil.RunCmd(time.Minute, repo.Dir, "git", args...); err != nil { repo.t.Fatal(err) } @@ -51,9 +44,9 @@ func MakeTestRepo(t *testing.T, dir string) *TestRepo { Commits: make(map[string]map[string]*Commit), repo: newGit(dir, ignoreCC), } - repo.git("init") - repo.git("config", "--add", "user.email", userEmail) - repo.git("config", "--add", "user.name", userName) + repo.Git("init") + repo.Git("config", "--add", "user.email", userEmail) + repo.Git("config", "--add", "user.name", userName) return repo } @@ -63,8 +56,8 @@ func (repo *TestRepo) CommitFileChange(branch, change string) { if err := osutil.WriteFile(file, []byte(id)); err != nil { repo.t.Fatal(err) } - repo.git("add", file) - repo.git("commit", "-m", id) + repo.Git("add", file) + repo.Git("commit", "-m", id) if repo.Commits[branch] == nil { repo.Commits[branch] = make(map[string]*Commit) } @@ -75,12 +68,17 @@ func (repo *TestRepo) CommitFileChange(branch, change string) { repo.Commits[branch][change] = com } -func (repo *TestRepo) CommitChange(description string) { - repo.git("commit", "--allow-empty", "-m", description) +func (repo *TestRepo) CommitChange(description string) *Commit { + repo.Git("commit", "--allow-empty", "-m", description) + com, err := repo.repo.HeadCommit() + if err != nil { + repo.t.Fatal(err) + } + return com } func (repo *TestRepo) SetTag(tag string) { - repo.git("tag", tag) + repo.Git("tag", tag) } func (repo *TestRepo) SupportsBisection() bool { @@ -93,14 +91,14 @@ func (repo *TestRepo) SupportsBisection() bool { func CreateTestRepo(t *testing.T, baseDir, name string) *TestRepo { repo := MakeTestRepo(t, filepath.Join(baseDir, name)) - repo.git("checkout", "-b", "master") + repo.Git("checkout", "-b", "master") repo.CommitFileChange("master", "0") for _, branch := range []string{"branch1", "branch2"} { - repo.git("checkout", "-b", branch, "master") + repo.Git("checkout", "-b", branch, "master") repo.CommitFileChange(branch, "0") repo.CommitFileChange(branch, "1") } - repo.git("checkout", "master") + repo.Git("checkout", "master") repo.CommitFileChange("master", "1") return repo } @@ -120,6 +118,6 @@ func CloneTestRepo(t *testing.T, baseDir string, name string, originRepo *TestRe Commits: make(map[string]map[string]*Commit), repo: newGit(dir, ignoreCC), } - repo.git("clone", originRepo.Dir, repo.Dir) + repo.Git("clone", originRepo.Dir, repo.Dir) return repo } |
