From da4f7833623ad2751b731ae64eba0d07f98a647d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 21 Feb 2019 13:55:21 +0100 Subject: [PATCH] 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. --- input_test.go | 12 ++++++++++-- query_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/input_test.go b/input_test.go index d7697da..0f4c15e 100644 --- a/input_test.go +++ b/input_test.go @@ -21,10 +21,10 @@ const ( ) func TestMouseClickXY(t *testing.T) { - var err error - t.Parallel() + var err error + c := testAllocate(t, "input.html") defer c.Release() @@ -78,6 +78,8 @@ func TestMouseClickXY(t *testing.T) { } func TestMouseClickNode(t *testing.T) { + t.Parallel() + tests := []struct { sel, exp string opt MouseOption @@ -128,6 +130,8 @@ func TestMouseClickNode(t *testing.T) { } func TestMouseClickOffscreenNode(t *testing.T) { + t.Parallel() + tests := []struct { sel string exp int @@ -186,6 +190,8 @@ func TestMouseClickOffscreenNode(t *testing.T) { } func TestKeyAction(t *testing.T) { + t.Parallel() + tests := []struct { sel, exp string by QueryOption @@ -238,6 +244,8 @@ func TestKeyAction(t *testing.T) { } func TestKeyActionNode(t *testing.T) { + t.Parallel() + tests := []struct { sel, exp string by QueryOption diff --git a/query_test.go b/query_test.go index 645e62a..7e4af11 100644 --- a/query_test.go +++ b/query_test.go @@ -190,6 +190,8 @@ func TestText(t *testing.T) { } func TestClear(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -244,6 +246,8 @@ func TestClear(t *testing.T) { } func TestReset(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -315,6 +319,8 @@ func TestValue(t *testing.T) { } func TestSetValue(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -442,6 +448,8 @@ func TestAttributesAll(t *testing.T) { } func TestSetAttributes(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -547,6 +555,8 @@ func TestAttributeValue(t *testing.T) { } func TestSetAttributeValue(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -589,6 +599,8 @@ func TestSetAttributeValue(t *testing.T) { } func TestRemoveAttribute(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -626,6 +638,8 @@ func TestRemoveAttribute(t *testing.T) { } func TestClick(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -666,6 +680,8 @@ func TestClick(t *testing.T) { } func TestDoubleClick(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -703,6 +719,8 @@ func TestDoubleClick(t *testing.T) { } func TestSendKeys(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -773,6 +791,8 @@ func TestScreenshot(t *testing.T) { } func TestSubmit(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -813,6 +833,8 @@ func TestSubmit(t *testing.T) { } func TestComputedStyle(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -870,6 +892,8 @@ func TestComputedStyle(t *testing.T) { } func TestMatchedStyle(t *testing.T) { + t.Parallel() + tests := []struct { sel string by QueryOption @@ -952,6 +976,8 @@ func TestFileUpload(t *testing.T) { for i, test := range tests { t.Run(fmt.Sprintf("test %d", i), func(t *testing.T) { + t.Parallel() + c := testAllocate(t, "") defer c.Release()