Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

parallelize many cmd/dep tests #608

Merged
merged 2 commits into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/dep/ensure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 11 additions & 3 deletions cmd/dep/graphviz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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{})
Expand All @@ -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()
Expand All @@ -54,6 +60,8 @@ func TestNoLinks(t *testing.T) {
}

func TestIsPathPrefix(t *testing.T) {
t.Parallel()

tcs := []struct {
path string
pre string
Expand Down
6 changes: 6 additions & 0 deletions cmd/dep/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
)

func TestContains(t *testing.T) {
t.Parallel()

a := []string{"a", "b", "abcd"}

if !contains(a, "a") {
Expand All @@ -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,
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cmd/dep/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
)

func TestIntegration(t *testing.T) {
t.Parallel()

test.NeedsExternalNetwork(t)
test.NeedsGit(t)

Expand Down
4 changes: 4 additions & 0 deletions cmd/dep/remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
)

func TestRemoveErrors(t *testing.T) {
t.Parallel()

test.NeedsExternalNetwork(t)
test.NeedsGit(t)

Expand All @@ -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, "harness_tests", wd)
testProj := test.NewTestProject(t, testCase.InitialPath(), wd, externalProc, run)
defer testProj.Cleanup()
Expand Down
2 changes: 2 additions & 0 deletions cmd/dep/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

func TestStatusFormatVersion(t *testing.T) {
t.Parallel()

tests := map[gps.Version]string{
nil: "",
gps.NewBranch("master"): "branch master",
Expand Down
4 changes: 2 additions & 2 deletions internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down