Skip to content

Commit

Permalink
tests/thirdparty: use shallow clone (#224)
Browse files Browse the repository at this point in the history
When trying to add a test case from the standard library, cloning golang/go
was taking forever. This PR switches to a shallow clone.
  • Loading branch information
mmcloughlin authored Nov 8, 2021
1 parent f355d27 commit 1de006d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions tests/thirdparty/packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,18 @@ func (t *PackageTest) Run() {

// checkout the code at the specified version.
func (t *PackageTest) checkout() {
// Clone repo.
dst := filepath.Join(t.WorkDir, t.Name())
test.Exec(t.T, "git", "clone", "--quiet", t.Repository.CloneURL(), dst)
t.repopath = dst

// Checkout specific version.
// Determine the version we want to checkout.
version := t.Version
if t.Latest {
t.Log("using latest version")
return
version = t.DefaultBranch
}
test.Exec(t.T, "git", "-C", t.repopath, "checkout", "--quiet", t.Version)

// Clone. Use a shallow clone to speed up large repositories.
t.repopath = filepath.Join(t.WorkDir, t.Name())
test.Exec(t.T, "git", "init", t.repopath)
test.Exec(t.T, "git", "-C", t.repopath, "remote", "add", "origin", t.Repository.CloneURL())
test.Exec(t.T, "git", "-C", t.repopath, "fetch", "--depth=1", "origin", version)
test.Exec(t.T, "git", "-C", t.repopath, "checkout", "FETCH_HEAD")
}

func (t *PackageTest) steps() {
Expand Down

0 comments on commit 1de006d

Please sign in to comment.