Revert "git-codereview: deflake TestSyncRebase"
This reverts commit dd3919343ed6ab8cad672c16b8c2a514615d9c4e.
Change-Id: Ifa77bd8182f832c1e8553dac8f3f4a87a1db64fa
Reviewed-on: https://go-review.googlesource.com/9940
Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/git-codereview/sync_test.go b/git-codereview/sync_test.go
index 88461b3..2f7318d 100644
--- a/git-codereview/sync_test.go
+++ b/git-codereview/sync_test.go
@@ -73,10 +73,8 @@
t.Fatalf("CL hashes changed during no-op sync")
}
- // submit first two CLs - gt.serverWork does same thing gt.work does, but on server
-
+ // submit first two CLs - gt.serverWork does same thing gt.work does, but on client
gt.serverWork(t)
- gt.serverWorkUnrelated(t) // wedge in unrelated work to get different hashes
gt.serverWork(t)
testMain(t, "sync")
diff --git a/git-codereview/util_test.go b/git-codereview/util_test.go
index ea7cf8f..034d052 100644
--- a/git-codereview/util_test.go
+++ b/git-codereview/util_test.go
@@ -6,7 +6,6 @@
import (
"bytes"
- "encoding/hex"
"fmt"
"io/ioutil"
"net"
@@ -27,7 +26,6 @@
client string // client repo root
nwork int // number of calls to work method
nworkServer int // number of calls to serverWork method
- nworkOther int // number of calls to serverWorkUnrelated method
}
// resetReadOnlyFlagAll resets windows read-only flag
@@ -63,18 +61,6 @@
os.RemoveAll(gt.tmpdir)
}
-// doWork simulates commit 'n' touching 'file' in 'dir'
-func doWork(t *testing.T, n int, dir, file string) {
- write(t, dir+"/"+file, fmt.Sprintf("new content %d", n))
- trun(t, dir, "git", "add", file)
- suffix := ""
- if n > 1 {
- suffix = fmt.Sprintf(" #%d", n)
- }
- changeid := hex.EncodeToString([]byte(file))
- trun(t, dir, "git", "commit", "-m", fmt.Sprintf("msg%s\n\nChange-Id: I%d%s\n", suffix, n, changeid))
-}
-
func (gt *gitTest) work(t *testing.T) {
if gt.nwork == 0 {
trun(t, gt.client, "git", "checkout", "-b", "work")
@@ -84,23 +70,29 @@
// make local change on client
gt.nwork++
- doWork(t, gt.nwork, gt.client, "file")
+ write(t, gt.client+"/file", fmt.Sprintf("new content %d", gt.nwork))
+ trun(t, gt.client, "git", "add", "file")
+ suffix := ""
+ if gt.nwork > 1 {
+ suffix = fmt.Sprintf(" #%d", gt.nwork)
+ }
+ trun(t, gt.client, "git", "commit", "-m", fmt.Sprintf("msg%s\n\nChange-Id: I%d23456789\n", suffix, gt.nwork))
}
func (gt *gitTest) serverWork(t *testing.T) {
// make change on server
- // duplicating the sequence of changes in gt.work to simulate them
- // having gone through Gerrit and submitted with possibly
- // different commit hashes but the same content.
+ // duplicating the changes of gt.work to simulate them
+ // having gone through Gerrit and submitted with
+ // different times and commit hashes but the same content.
gt.nworkServer++
- doWork(t, gt.nworkServer, gt.server, "file")
-}
+ write(t, gt.server+"/file", fmt.Sprintf("new content %d", gt.nworkServer))
+ trun(t, gt.server, "git", "add", "file")
+ suffix := ""
+ if gt.nworkServer > 1 {
+ suffix = fmt.Sprintf(" #%d", gt.nworkServer)
+ }
+ trun(t, gt.server, "git", "commit", "-m", fmt.Sprintf("msg%s\n\nChange-Id: I%d23456789\n", suffix, gt.nworkServer))
-func (gt *gitTest) serverWorkUnrelated(t *testing.T) {
- // make unrelated change on server
- // this makes history different on client and server
- gt.nworkOther++
- doWork(t, gt.nworkOther, gt.server, "otherfile")
}
func newGitTest(t *testing.T) (gt *gitTest) {