Skip to content
Permalink
Browse files

Speed up testing by running tests in parallel

  • Loading branch information...
erikdubbelboer committed Oct 15, 2019
1 parent 352ec7c commit c3d82ca3a430260ff1795abfeac9e8396ed6f6fe
Showing with 622 additions and 2 deletions.
  1. +4 −0 allocation_test.go
  2. +30 −0 args_test.go
  3. +8 −0 bytesconv_32_test.go
  4. +8 −0 bytesconv_64_test.go
  5. +18 −0 bytesconv_test.go
  6. +74 −2 client_test.go
  7. +16 −0 compress_test.go
  8. +24 −0 cookie_test.go
  9. +32 −0 fs_test.go
  10. +4 −0 header_regression_test.go
  11. +114 −0 header_test.go
  12. +138 −0 http_test.go
  13. +4 −0 peripconn_test.go
  14. +110 −0 server_test.go
  15. +4 −0 stream_test.go
  16. +20 −0 uri_test.go
  17. +2 −0 uri_windows_test.go
  18. +4 −0 userdata_test.go
  19. +8 −0 workerpool_test.go
@@ -9,6 +9,8 @@ import (
)

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

s := &Server{
Handler: func(ctx *RequestCtx) {
},
@@ -70,6 +72,8 @@ func TestAllocationClient(t *testing.T) {
}

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

uri := []byte("http://username:password@example.com/some/path?foo=bar#test")

n := testing.AllocsPerRun(100, func() {
@@ -13,6 +13,8 @@ import (
)

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

testDecodeArgAppend(t, "", "")
testDecodeArgAppend(t, "foobar", "foobar")
testDecodeArgAppend(t, "тест", "тест")
@@ -34,6 +36,8 @@ func testDecodeArgAppend(t *testing.T, s, expectedResult string) {
}

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

var a Args
a.Add("foo", "bar")
a.Add("foo", "baz")
@@ -144,6 +148,8 @@ func testArgsAcquireRelease(t *testing.T) {
}

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

var a Args
a.Parse("foo=123&bar=121&foo=321&foo=&barz=sdf")

@@ -170,6 +176,8 @@ func TestArgsPeekMulti(t *testing.T) {
}

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

testArgsEscape(t, "foo", "bar", "foo=bar")

// Test all characters
@@ -193,6 +201,8 @@ func testArgsEscape(t *testing.T, k, v, expectedS string) {
}

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

testPathEscape(t, "/foo/bar")
testPathEscape(t, "")
testPathEscape(t, "/")
@@ -217,6 +227,8 @@ func testPathEscape(t *testing.T, s string) {
}

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

s := "foo=bar&baz=123&aaa=bbb"

var a Args
@@ -237,6 +249,8 @@ func TestArgsWriteTo(t *testing.T) {
}

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

testArgsGetBool(t, "", false)
testArgsGetBool(t, "0", false)
testArgsGetBool(t, "n", false)
@@ -260,6 +274,8 @@ func testArgsGetBool(t *testing.T, value string, expectedResult bool) {
}

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

var a Args
a.SetUint("foo", 123)
a.SetUint("bar", 0)
@@ -293,6 +309,8 @@ func TestArgsUint(t *testing.T) {
}

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

var a Args

// empty args
@@ -334,6 +352,8 @@ func testCopyTo(t *testing.T, a *Args) {
}

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

var a Args
a.Set("foo", "bar")

@@ -353,6 +373,8 @@ func TestArgsVisitAll(t *testing.T) {
}

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

var a Args
a.Set("foo", "bar")
a.Set("aa", "bbb")
@@ -370,6 +392,8 @@ func TestArgsStringCompose(t *testing.T) {
}

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

var a Args

testArgsString(t, &a, "")
@@ -390,6 +414,8 @@ func testArgsString(t *testing.T, a *Args, s string) {
}

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

var a Args

if len(a.Peek("foo")) > 0 {
@@ -455,6 +481,8 @@ func TestArgsSetGetDel(t *testing.T) {
}

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

var a Args

// empty args
@@ -501,6 +529,8 @@ func TestArgsParse(t *testing.T) {
}

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

var a Args

// single arg
@@ -7,13 +7,17 @@ import (
)

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

testWriteHexInt(t, 0, "0")
testWriteHexInt(t, 1, "1")
testWriteHexInt(t, 0x123, "123")
testWriteHexInt(t, 0x7fffffff, "7fffffff")
}

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

testAppendUint(t, 0)
testAppendUint(t, 123)
testAppendUint(t, 0x7fffffff)
@@ -24,6 +28,8 @@ func TestAppendUint(t *testing.T) {
}

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

testReadHexIntSuccess(t, "0", 0)
testReadHexIntSuccess(t, "fF", 0xff)
testReadHexIntSuccess(t, "00abc", 0xabc)
@@ -33,6 +39,8 @@ func TestReadHexIntSuccess(t *testing.T) {
}

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

testParseUintSuccess(t, "0", 0)
testParseUintSuccess(t, "123", 123)
testParseUintSuccess(t, "123456789", 123456789)
@@ -7,13 +7,17 @@ import (
)

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

testWriteHexInt(t, 0, "0")
testWriteHexInt(t, 1, "1")
testWriteHexInt(t, 0x123, "123")
testWriteHexInt(t, 0x7fffffffffffffff, "7fffffffffffffff")
}

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

testAppendUint(t, 0)
testAppendUint(t, 123)
testAppendUint(t, 0x7fffffffffffffff)
@@ -24,6 +28,8 @@ func TestAppendUint(t *testing.T) {
}

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

testReadHexIntSuccess(t, "0", 0)
testReadHexIntSuccess(t, "fF", 0xff)
testReadHexIntSuccess(t, "00abc", 0xabc)
@@ -34,6 +40,8 @@ func TestReadHexIntSuccess(t *testing.T) {
}

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

testParseUintSuccess(t, "0", 0)
testParseUintSuccess(t, "123", 123)
testParseUintSuccess(t, "1234567890", 1234567890)
@@ -12,6 +12,8 @@ import (
)

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

testAppendHTMLEscape(t, "", "")
testAppendHTMLEscape(t, "<", "&lt;")
testAppendHTMLEscape(t, "a", "a")
@@ -27,6 +29,8 @@ func testAppendHTMLEscape(t *testing.T, s, expectedS string) {
}

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

testParseIPv4(t, "0.0.0.0", true)
testParseIPv4(t, "255.255.255.255", true)
testParseIPv4(t, "123.45.67.89", true)
@@ -58,6 +62,8 @@ func testParseIPv4(t *testing.T, ipStr string, isValid bool) {
}

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

testAppendIPv4(t, "0.0.0.0", true)
testAppendIPv4(t, "127.0.0.1", true)
testAppendIPv4(t, "8.8.8.8", true)
@@ -109,6 +115,8 @@ func testWriteHexInt(t *testing.T, n int, expectedS string) {
}

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

testReadHexIntError(t, "")
testReadHexIntError(t, "ZZZ")
testReadHexIntError(t, "-123")
@@ -140,6 +148,8 @@ func testReadHexIntSuccess(t *testing.T, s string, expectedN int) {
}

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

d := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
s := string(AppendHTTPDate(nil, d))
expectedS := "Tue, 10 Nov 2009 23:00:00 GMT"
@@ -159,6 +169,8 @@ func TestAppendHTTPDate(t *testing.T) {
}

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

// empty string
testParseUintError(t, "")

@@ -180,6 +192,8 @@ func TestParseUintError(t *testing.T) {
}

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

testParseUfloatSuccess(t, "0", 0)
testParseUfloatSuccess(t, "1.", 1.)
testParseUfloatSuccess(t, ".1", 0.1)
@@ -191,6 +205,8 @@ func TestParseUfloatSuccess(t *testing.T) {
}

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

// empty num
testParseUfloatError(t, "")

@@ -262,6 +278,8 @@ func testParseUintSuccess(t *testing.T, s string, expectedN int) {
}

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

testAppendUnquotedArg(t, "", "")
testAppendUnquotedArg(t, "abc", "abc")
testAppendUnquotedArg(t, "тест.abc", "тест.abc")

0 comments on commit c3d82ca

Please sign in to comment.
You can’t perform that action at this time.