From e55c00eca7e70e2d02860cda3cdc9169a88ece36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sat, 27 Aug 2016 19:21:05 +0200 Subject: [PATCH] Run the tests in parallel This saves about 1s, or 1/3 of the test runtime. The linking is still much slower, but this we can control. --- blame_test.go | 1 + blob_test.go | 1 + branch_test.go | 2 ++ cherrypick_test.go | 1 + clone_test.go | 2 ++ config_test.go | 1 + describe_test.go | 1 + diff_test.go | 4 +++- git_test.go | 2 ++ index_test.go | 7 +++++++ merge_test.go | 5 +++++ note_test.go | 4 ++++ object_test.go | 3 +++ odb_test.go | 5 ++++- patch_test.go | 1 + push_test.go | 1 + reference_test.go | 6 ++++++ remote_test.go | 7 +++++++ reset_test.go | 1 + revparse_test.go | 3 +++ status_test.go | 2 ++ submodule_test.go | 1 + tag_test.go | 5 +++++ tree_test.go | 2 ++ 24 files changed, 66 insertions(+), 2 deletions(-) diff --git a/blame_test.go b/blame_test.go index a2a4d38d..ec96af77 100644 --- a/blame_test.go +++ b/blame_test.go @@ -6,6 +6,7 @@ import ( ) func TestBlame(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/blob_test.go b/blob_test.go index 2b5ec4fd..719d185a 100644 --- a/blob_test.go +++ b/blob_test.go @@ -5,6 +5,7 @@ import ( ) func TestCreateBlobFromBuffer(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/branch_test.go b/branch_test.go index a0834a8d..01a2e28e 100644 --- a/branch_test.go +++ b/branch_test.go @@ -5,6 +5,7 @@ import ( ) func TestBranchIterator(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -27,6 +28,7 @@ func TestBranchIterator(t *testing.T) { } func TestBranchIteratorEach(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/cherrypick_test.go b/cherrypick_test.go index a3246bdd..bfa5ca8f 100644 --- a/cherrypick_test.go +++ b/cherrypick_test.go @@ -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) diff --git a/clone_test.go b/clone_test.go index a6bbf944..24c3a09d 100644 --- a/clone_test.go +++ b/clone_test.go @@ -10,6 +10,7 @@ const ( ) func TestClone(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -35,6 +36,7 @@ func TestClone(t *testing.T) { } func TestCloneWithCallback(t *testing.T) { + t.Parallel() testPayload := 0 repo := createTestRepo(t) diff --git a/config_test.go b/config_test.go index fea8d8ad..f31e73ec 100644 --- a/config_test.go +++ b/config_test.go @@ -88,6 +88,7 @@ var tests = []TestRunner{ } func TestConfigLookups(t *testing.T) { + t.Parallel() var ( err error c *Config diff --git a/describe_test.go b/describe_test.go index 25af1073..f0a45f4a 100644 --- a/describe_test.go +++ b/describe_test.go @@ -8,6 +8,7 @@ import ( ) func TestDescribeCommit(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/diff_test.go b/diff_test.go index 850ed8ee..6fbad512 100644 --- a/diff_test.go +++ b/diff_test.go @@ -7,6 +7,7 @@ import ( ) func TestFindSimilar(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -61,7 +62,7 @@ func TestFindSimilar(t *testing.T) { } func TestDiffTreeToTree(t *testing.T) { - + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -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) diff --git a/git_test.go b/git_test.go index 58caf719..bdb6837d 100644 --- a/git_test.go +++ b/git_test.go @@ -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() { @@ -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") diff --git a/index_test.go b/index_test.go index 5f6b375b..600b8b11 100644 --- a/index_test.go +++ b/index_test.go @@ -8,6 +8,7 @@ import ( ) func TestCreateRepoAndStage(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -24,6 +25,7 @@ func TestCreateRepoAndStage(t *testing.T) { } func TestIndexReadTree(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -53,6 +55,7 @@ func TestIndexReadTree(t *testing.T) { } func TestIndexWriteTreeTo(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -72,6 +75,7 @@ func TestIndexWriteTreeTo(t *testing.T) { } func TestIndexAddAndWriteTreeTo(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -106,6 +110,7 @@ func TestIndexAddAndWriteTreeTo(t *testing.T) { } func TestIndexAddAllNoCallback(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -127,6 +132,7 @@ func TestIndexAddAllNoCallback(t *testing.T) { } func TestIndexAddAllCallback(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -155,6 +161,7 @@ func TestIndexAddAllCallback(t *testing.T) { } func TestIndexOpen(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/merge_test.go b/merge_test.go index 80597273..f2c84bcb 100644 --- a/merge_test.go +++ b/merge_test.go @@ -6,6 +6,7 @@ import ( ) func TestMergeWithSelf(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -24,6 +25,7 @@ func TestMergeWithSelf(t *testing.T) { } func TestMergeAnalysisWithSelf(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -46,6 +48,7 @@ func TestMergeAnalysisWithSelf(t *testing.T) { } func TestMergeSameFile(t *testing.T) { + t.Parallel() file := MergeFileInput{ Path: "test", Mode: 33188, @@ -68,6 +71,7 @@ func TestMergeSameFile(t *testing.T) { } func TestMergeTreesWithoutAncestor(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -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) diff --git a/note_test.go b/note_test.go index 27e04be4..9f64eb8c 100644 --- a/note_test.go +++ b/note_test.go @@ -8,6 +8,7 @@ import ( ) func TestCreateNote(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -27,6 +28,7 @@ func TestCreateNote(t *testing.T) { } func TestNoteIterator(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -63,6 +65,7 @@ func TestNoteIterator(t *testing.T) { } func TestRemoveNote(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -86,6 +89,7 @@ func TestRemoveNote(t *testing.T) { } func TestDefaultNoteRef(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/object_test.go b/object_test.go index 2ae2a6a0..cb262de4 100644 --- a/object_test.go +++ b/object_test.go @@ -5,6 +5,7 @@ import ( ) func TestObjectPoymorphism(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -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) @@ -104,6 +106,7 @@ func TestObjectOwner(t *testing.T) { } func TestObjectPeel(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/odb_test.go b/odb_test.go index dfd2ad03..3d22fc98 100644 --- a/odb_test.go +++ b/odb_test.go @@ -7,6 +7,7 @@ import ( ) func TestOdbReadHeader(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -35,6 +36,7 @@ func TestOdbReadHeader(t *testing.T) { } func TestOdbStream(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -64,7 +66,7 @@ func TestOdbStream(t *testing.T) { } func TestOdbHash(t *testing.T) { - + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -92,6 +94,7 @@ Initial commit.` } func TestOdbForeach(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/patch_test.go b/patch_test.go index 2d52fb49..291c7059 100644 --- a/patch_test.go +++ b/patch_test.go @@ -6,6 +6,7 @@ import ( ) func TestPatch(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/push_test.go b/push_test.go index 8f6e8064..f3728820 100644 --- a/push_test.go +++ b/push_test.go @@ -5,6 +5,7 @@ import ( ) func TestRemotePush(t *testing.T) { + t.Parallel() repo := createBareTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/reference_test.go b/reference_test.go index 761daf86..b6721e15 100644 --- a/reference_test.go +++ b/reference_test.go @@ -8,6 +8,7 @@ import ( ) func TestRefModification(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -53,6 +54,7 @@ func TestRefModification(t *testing.T) { } func TestReferenceIterator(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -131,6 +133,7 @@ func TestReferenceIterator(t *testing.T) { } func TestReferenceOwner(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -150,6 +153,7 @@ func TestReferenceOwner(t *testing.T) { } func TestUtil(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -177,6 +181,7 @@ func TestUtil(t *testing.T) { } func TestIsNote(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -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") } diff --git a/remote_test.go b/remote_test.go index 978b803b..3d00640a 100644 --- a/remote_test.go +++ b/remote_test.go @@ -6,6 +6,7 @@ import ( ) func TestListRemotes(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -33,6 +34,7 @@ func assertHostname(cert *Certificate, valid bool, hostname string, t *testing.T } func TestCertificateCheck(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -52,6 +54,7 @@ func TestCertificateCheck(t *testing.T) { } func TestRemoteConnect(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -63,6 +66,7 @@ func TestRemoteConnect(t *testing.T) { } func TestRemoteLs(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -81,6 +85,7 @@ func TestRemoteLs(t *testing.T) { } func TestRemoteLsFiltering(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -107,6 +112,7 @@ func TestRemoteLsFiltering(t *testing.T) { } func TestRemotePruneRefs(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -129,6 +135,7 @@ func TestRemotePruneRefs(t *testing.T) { } func TestRemotePrune(t *testing.T) { + t.Parallel() remoteRepo := createTestRepo(t) defer cleanupTestRepo(t, remoteRepo) diff --git a/reset_test.go b/reset_test.go index ec578bdb..45777e46 100644 --- a/reset_test.go +++ b/reset_test.go @@ -6,6 +6,7 @@ import ( ) func TestResetToCommit(t *testing.T) { + t.Parallel() repo := createTestRepo(t) seedTestRepo(t, repo) // create commit to reset to diff --git a/revparse_test.go b/revparse_test.go index 75e9ffdf..28354343 100644 --- a/revparse_test.go +++ b/revparse_test.go @@ -5,6 +5,7 @@ import ( ) func TestRevparse(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -17,6 +18,7 @@ func TestRevparse(t *testing.T) { } func TestRevparseSingle(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -29,6 +31,7 @@ func TestRevparseSingle(t *testing.T) { } func TestRevparseExt(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/status_test.go b/status_test.go index 5b97b005..17ed94f4 100644 --- a/status_test.go +++ b/status_test.go @@ -7,6 +7,7 @@ import ( ) func TestStatusFile(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -27,6 +28,7 @@ func TestStatusFile(t *testing.T) { } func TestStatusList(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/submodule_test.go b/submodule_test.go index 43c890af..fa2e98cd 100644 --- a/submodule_test.go +++ b/submodule_test.go @@ -5,6 +5,7 @@ import ( ) func TestSubmoduleForeach(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/tag_test.go b/tag_test.go index 2fdfe00b..3404923c 100644 --- a/tag_test.go +++ b/tag_test.go @@ -7,6 +7,7 @@ import ( ) func TestCreateTag(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -26,6 +27,7 @@ func TestCreateTag(t *testing.T) { } func TestCreateTagLightweight(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -50,6 +52,7 @@ func TestCreateTagLightweight(t *testing.T) { } func TestListTags(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -79,6 +82,7 @@ func TestListTags(t *testing.T) { } func TestListTagsWithMatch(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -116,6 +120,7 @@ func TestListTagsWithMatch(t *testing.T) { } func TestTagForeach(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) diff --git a/tree_test.go b/tree_test.go index fae395a5..f5b68221 100644 --- a/tree_test.go +++ b/tree_test.go @@ -3,6 +3,7 @@ package git import "testing" func TestTreeEntryById(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -22,6 +23,7 @@ func TestTreeEntryById(t *testing.T) { } func TestTreeBuilderInsert(t *testing.T) { + t.Parallel() repo := createTestRepo(t) defer cleanupTestRepo(t, repo)