Skip to content

Commit

Permalink
Run the tests in parallel
Browse files Browse the repository at this point in the history
This saves about 1s, or 1/3 of the test runtime. The linking is still
much slower, but this we can control.
  • Loading branch information
carlosmn committed Aug 27, 2016
1 parent 1670c49 commit e55c00e
Show file tree
Hide file tree
Showing 24 changed files with 66 additions and 2 deletions.
1 change: 1 addition & 0 deletions blame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
)

func TestBlame(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
1 change: 1 addition & 0 deletions blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
)

func TestCreateBlobFromBuffer(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
2 changes: 2 additions & 0 deletions branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
)

func TestBranchIterator(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand All @@ -27,6 +28,7 @@ func TestBranchIterator(t *testing.T) {
}

func TestBranchIteratorEach(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
1 change: 1 addition & 0 deletions cherrypick_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func readReadme(t *testing.T, repo *Repository) string {
}

func TestCherrypick(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
2 changes: 2 additions & 0 deletions clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (
)

func TestClone(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand All @@ -35,6 +36,7 @@ func TestClone(t *testing.T) {
}

func TestCloneWithCallback(t *testing.T) {
t.Parallel()
testPayload := 0

repo := createTestRepo(t)
Expand Down
1 change: 1 addition & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var tests = []TestRunner{
}

func TestConfigLookups(t *testing.T) {
t.Parallel()
var (
err error
c *Config
Expand Down
1 change: 1 addition & 0 deletions describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestDescribeCommit(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
4 changes: 3 additions & 1 deletion diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

func TestFindSimilar(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -61,7 +62,7 @@ func TestFindSimilar(t *testing.T) {
}

func TestDiffTreeToTree(t *testing.T) {

t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -189,6 +190,7 @@ func createTestTrees(t *testing.T, repo *Repository) (originalTree *Tree, newTre
}

func TestDiffBlobs(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
2 changes: 2 additions & 0 deletions git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func updateReadme(t *testing.T, repo *Repository, content string) (*Oid, *Oid) {
}

func TestOidZero(t *testing.T) {
t.Parallel()
var zeroId Oid

if !zeroId.IsZero() {
Expand All @@ -117,6 +118,7 @@ func TestOidZero(t *testing.T) {
}

func TestEmptyOid(t *testing.T) {
t.Parallel()
_, err := NewOid("")
if err == nil || !IsErrorCode(err, ErrGeneric) {
t.Fatal("Should have returned invalid error")
Expand Down
7 changes: 7 additions & 0 deletions index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestCreateRepoAndStage(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand All @@ -24,6 +25,7 @@ func TestCreateRepoAndStage(t *testing.T) {
}

func TestIndexReadTree(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -53,6 +55,7 @@ func TestIndexReadTree(t *testing.T) {
}

func TestIndexWriteTreeTo(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand All @@ -72,6 +75,7 @@ func TestIndexWriteTreeTo(t *testing.T) {
}

func TestIndexAddAndWriteTreeTo(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -106,6 +110,7 @@ func TestIndexAddAndWriteTreeTo(t *testing.T) {
}

func TestIndexAddAllNoCallback(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand All @@ -127,6 +132,7 @@ func TestIndexAddAllNoCallback(t *testing.T) {
}

func TestIndexAddAllCallback(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -155,6 +161,7 @@ func TestIndexAddAllCallback(t *testing.T) {
}

func TestIndexOpen(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
5 changes: 5 additions & 0 deletions merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
)

func TestMergeWithSelf(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand All @@ -24,6 +25,7 @@ func TestMergeWithSelf(t *testing.T) {
}

func TestMergeAnalysisWithSelf(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand All @@ -46,6 +48,7 @@ func TestMergeAnalysisWithSelf(t *testing.T) {
}

func TestMergeSameFile(t *testing.T) {
t.Parallel()
file := MergeFileInput{
Path: "test",
Mode: 33188,
Expand All @@ -68,6 +71,7 @@ func TestMergeSameFile(t *testing.T) {

}
func TestMergeTreesWithoutAncestor(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -125,6 +129,7 @@ func appendCommit(t *testing.T, repo *Repository) (*Oid, *Oid) {
}

func TestMergeBase(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
4 changes: 4 additions & 0 deletions note_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestCreateNote(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand All @@ -27,6 +28,7 @@ func TestCreateNote(t *testing.T) {
}

func TestNoteIterator(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -63,6 +65,7 @@ func TestNoteIterator(t *testing.T) {
}

func TestRemoveNote(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand All @@ -86,6 +89,7 @@ func TestRemoveNote(t *testing.T) {
}

func TestDefaultNoteRef(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
3 changes: 3 additions & 0 deletions object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
)

func TestObjectPoymorphism(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -88,6 +89,7 @@ func checkOwner(t *testing.T, repo *Repository, obj Object) {
}

func TestObjectOwner(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand All @@ -104,6 +106,7 @@ func TestObjectOwner(t *testing.T) {
}

func TestObjectPeel(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
5 changes: 4 additions & 1 deletion odb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

func TestOdbReadHeader(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -35,6 +36,7 @@ func TestOdbReadHeader(t *testing.T) {
}

func TestOdbStream(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -64,7 +66,7 @@ func TestOdbStream(t *testing.T) {
}

func TestOdbHash(t *testing.T) {

t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -92,6 +94,7 @@ Initial commit.`
}

func TestOdbForeach(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
1 change: 1 addition & 0 deletions patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
)

func TestPatch(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
1 change: 1 addition & 0 deletions push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
)

func TestRemotePush(t *testing.T) {
t.Parallel()
repo := createBareTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down
6 changes: 6 additions & 0 deletions reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestRefModification(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -53,6 +54,7 @@ func TestRefModification(t *testing.T) {
}

func TestReferenceIterator(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -131,6 +133,7 @@ func TestReferenceIterator(t *testing.T) {
}

func TestReferenceOwner(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand All @@ -150,6 +153,7 @@ func TestReferenceOwner(t *testing.T) {
}

func TestUtil(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -177,6 +181,7 @@ func TestUtil(t *testing.T) {
}

func TestIsNote(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)

Expand Down Expand Up @@ -210,6 +215,7 @@ func TestIsNote(t *testing.T) {
}

func TestReferenceIsValidName(t *testing.T) {
t.Parallel()
if !ReferenceIsValidName("HEAD") {
t.Errorf("HEAD should be a valid reference name")
}
Expand Down
Loading

0 comments on commit e55c00e

Please sign in to comment.