make all tests run in parallel

The subtests were almost all marked as parallel, but that's not enough.
That only makes the subtests run in parallel with other subtests within
the same tests, not with any other test.

Since none of the tests make use of globals nor require the entire
program to themselves, properly run all the tests in parallel.

Speeds up 'go test' on my 8-core laptop from an average of ~130s to an
average of ~50s. Many tests hit timeouts and have sleeps, so we want to
avoid running those sequentially whenever possible.
This commit is contained in:
Daniel Martí 2019-02-21 13:55:21 +01:00
parent 5ca52f3e1b
commit da4f783362
2 changed files with 36 additions and 2 deletions

View File

@ -21,10 +21,10 @@ const (
) )
func TestMouseClickXY(t *testing.T) { func TestMouseClickXY(t *testing.T) {
var err error
t.Parallel() t.Parallel()
var err error
c := testAllocate(t, "input.html") c := testAllocate(t, "input.html")
defer c.Release() defer c.Release()
@ -78,6 +78,8 @@ func TestMouseClickXY(t *testing.T) {
} }
func TestMouseClickNode(t *testing.T) { func TestMouseClickNode(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel, exp string sel, exp string
opt MouseOption opt MouseOption
@ -128,6 +130,8 @@ func TestMouseClickNode(t *testing.T) {
} }
func TestMouseClickOffscreenNode(t *testing.T) { func TestMouseClickOffscreenNode(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
exp int exp int
@ -186,6 +190,8 @@ func TestMouseClickOffscreenNode(t *testing.T) {
} }
func TestKeyAction(t *testing.T) { func TestKeyAction(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel, exp string sel, exp string
by QueryOption by QueryOption
@ -238,6 +244,8 @@ func TestKeyAction(t *testing.T) {
} }
func TestKeyActionNode(t *testing.T) { func TestKeyActionNode(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel, exp string sel, exp string
by QueryOption by QueryOption

View File

@ -190,6 +190,8 @@ func TestText(t *testing.T) {
} }
func TestClear(t *testing.T) { func TestClear(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -244,6 +246,8 @@ func TestClear(t *testing.T) {
} }
func TestReset(t *testing.T) { func TestReset(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -315,6 +319,8 @@ func TestValue(t *testing.T) {
} }
func TestSetValue(t *testing.T) { func TestSetValue(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -442,6 +448,8 @@ func TestAttributesAll(t *testing.T) {
} }
func TestSetAttributes(t *testing.T) { func TestSetAttributes(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -547,6 +555,8 @@ func TestAttributeValue(t *testing.T) {
} }
func TestSetAttributeValue(t *testing.T) { func TestSetAttributeValue(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -589,6 +599,8 @@ func TestSetAttributeValue(t *testing.T) {
} }
func TestRemoveAttribute(t *testing.T) { func TestRemoveAttribute(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -626,6 +638,8 @@ func TestRemoveAttribute(t *testing.T) {
} }
func TestClick(t *testing.T) { func TestClick(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -666,6 +680,8 @@ func TestClick(t *testing.T) {
} }
func TestDoubleClick(t *testing.T) { func TestDoubleClick(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -703,6 +719,8 @@ func TestDoubleClick(t *testing.T) {
} }
func TestSendKeys(t *testing.T) { func TestSendKeys(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -773,6 +791,8 @@ func TestScreenshot(t *testing.T) {
} }
func TestSubmit(t *testing.T) { func TestSubmit(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -813,6 +833,8 @@ func TestSubmit(t *testing.T) {
} }
func TestComputedStyle(t *testing.T) { func TestComputedStyle(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -870,6 +892,8 @@ func TestComputedStyle(t *testing.T) {
} }
func TestMatchedStyle(t *testing.T) { func TestMatchedStyle(t *testing.T) {
t.Parallel()
tests := []struct { tests := []struct {
sel string sel string
by QueryOption by QueryOption
@ -952,6 +976,8 @@ func TestFileUpload(t *testing.T) {
for i, test := range tests { for i, test := range tests {
t.Run(fmt.Sprintf("test %d", i), func(t *testing.T) { t.Run(fmt.Sprintf("test %d", i), func(t *testing.T) {
t.Parallel()
c := testAllocate(t, "") c := testAllocate(t, "")
defer c.Release() defer c.Release()