From 3cd933dc8dc2c443e42e852a87b29686e6c7bdd8 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Fri, 19 May 2017 08:51:21 -0500 Subject: [PATCH] parallelize many cmd/dep tests --- cmd/dep/ensure_test.go | 2 ++ cmd/dep/graphviz_test.go | 14 +++++++++++--- cmd/dep/init_test.go | 6 ++++++ cmd/dep/integration_test.go | 2 ++ cmd/dep/remove_test.go | 4 ++++ cmd/dep/status_test.go | 2 ++ internal/test/test.go | 4 ++-- 7 files changed, 29 insertions(+), 5 deletions(-) diff --git a/cmd/dep/ensure_test.go b/cmd/dep/ensure_test.go index f8fdd40456..5d1a4ee232 100644 --- a/cmd/dep/ensure_test.go +++ b/cmd/dep/ensure_test.go @@ -11,6 +11,8 @@ import ( ) func TestDeduceConstraint(t *testing.T) { + t.Parallel() + sv, err := gps.NewSemverConstraint("v1.2.3") if err != nil { t.Fatal(err) diff --git a/cmd/dep/graphviz_test.go b/cmd/dep/graphviz_test.go index 37a2e03342..a7537f0074 100644 --- a/cmd/dep/graphviz_test.go +++ b/cmd/dep/graphviz_test.go @@ -11,10 +11,12 @@ import ( ) func TestEmptyProject(t *testing.T) { - g := new(graphviz).New() h := test.NewHelper(t) + h.Parallel() defer h.Cleanup() + g := new(graphviz).New() + b := g.output() want := h.GetTestFileString("graphviz/empty.dot") @@ -24,10 +26,12 @@ func TestEmptyProject(t *testing.T) { } func TestSimpleProject(t *testing.T) { - g := new(graphviz).New() h := test.NewHelper(t) + h.Parallel() defer h.Cleanup() + g := new(graphviz).New() + g.createNode("project", "", []string{"foo", "bar"}) g.createNode("foo", "master", []string{"bar"}) g.createNode("bar", "dev", []string{}) @@ -40,10 +44,12 @@ func TestSimpleProject(t *testing.T) { } func TestNoLinks(t *testing.T) { - g := new(graphviz).New() h := test.NewHelper(t) + h.Parallel() defer h.Cleanup() + g := new(graphviz).New() + g.createNode("project", "", []string{}) b := g.output() @@ -54,6 +60,8 @@ func TestNoLinks(t *testing.T) { } func TestIsPathPrefix(t *testing.T) { + t.Parallel() + tcs := []struct { path string pre string diff --git a/cmd/dep/init_test.go b/cmd/dep/init_test.go index 1b9c7b6a0d..d654be8f25 100644 --- a/cmd/dep/init_test.go +++ b/cmd/dep/init_test.go @@ -12,6 +12,8 @@ import ( ) func TestContains(t *testing.T) { + t.Parallel() + a := []string{"a", "b", "abcd"} if !contains(a, "a") { @@ -23,6 +25,8 @@ func TestContains(t *testing.T) { } func TestIsStdLib(t *testing.T) { + t.Parallel() + tests := map[string]bool{ "github.com/Sirupsen/logrus": false, "encoding/json": true, @@ -40,6 +44,8 @@ func TestIsStdLib(t *testing.T) { } func TestGetProjectPropertiesFromVersion(t *testing.T) { + t.Parallel() + wantSemver, _ := gps.NewSemverConstraint("^v1.0.0") cases := []struct { version, want gps.Constraint diff --git a/cmd/dep/integration_test.go b/cmd/dep/integration_test.go index b886596eb4..65be9e71d5 100644 --- a/cmd/dep/integration_test.go +++ b/cmd/dep/integration_test.go @@ -18,6 +18,8 @@ import ( ) func TestIntegration(t *testing.T) { + t.Parallel() + test.NeedsExternalNetwork(t) test.NeedsGit(t) diff --git a/cmd/dep/remove_test.go b/cmd/dep/remove_test.go index 881ccd946c..d97f97c640 100644 --- a/cmd/dep/remove_test.go +++ b/cmd/dep/remove_test.go @@ -12,6 +12,8 @@ import ( ) func TestRemoveErrors(t *testing.T) { + t.Parallel() + test.NeedsExternalNetwork(t) test.NeedsGit(t) @@ -27,6 +29,8 @@ func TestRemoveErrors(t *testing.T) { func removeErrors(name, wd string, externalProc bool, run test.RunFunc) func(*testing.T) { return func(t *testing.T) { + t.Parallel() + testCase := test.NewTestCase(t, name, wd) testProj := test.NewTestProject(t, testCase.InitialPath(), wd, externalProc, run) defer testProj.Cleanup() diff --git a/cmd/dep/status_test.go b/cmd/dep/status_test.go index ca54cb0b73..87c66f3021 100644 --- a/cmd/dep/status_test.go +++ b/cmd/dep/status_test.go @@ -11,6 +11,8 @@ import ( ) func TestStatusFormatVersion(t *testing.T) { + t.Parallel() + tests := map[gps.Version]string{ nil: "", gps.NewBranch("master"): "branch master", diff --git a/internal/test/test.go b/internal/test/test.go index 66a399b4e0..c2c0faa40a 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -77,8 +77,8 @@ func (h *Helper) check(err error) { } } -// parallel runs the test in parallel by calling t.Parallel. -func (h *Helper) parallel() { +// Parallel runs the test in parallel by calling t.Parallel. +func (h *Helper) Parallel() { if h.ran { h.t.Fatalf("%+v", errors.New("internal testsuite error: call to parallel after run")) }