diff options
author | Russ Cox <rsc@golang.org> | 2019-05-15 20:49:39 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2019-05-22 12:54:00 +0000 |
commit | 06b0babf3138d189f6e741561f77ac6146696377 (patch) | |
tree | 04cda16449e7f9dfdd9e14926ef78e4e0d61be78 /src/mime | |
parent | b0e238add5dc8ab80b4eade78ca047f074658dcd (diff) | |
download | go-06b0babf3138d189f6e741561f77ac6146696377.tar.gz go-06b0babf3138d189f6e741561f77ac6146696377.zip |
all: shorten some tests
Shorten some of the longest tests that run during all.bash.
Removes 7r 50u 21s from all.bash.
After this change, all.bash is under 5 minutes again on my laptop.
For #26473.
Change-Id: Ie0460aa935808d65460408feaed210fbaa1d5d79
Reviewed-on: https://go-review.googlesource.com/c/go/+/177559
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/mime')
-rw-r--r-- | src/mime/multipart/formdata_test.go | 9 | ||||
-rw-r--r-- | src/mime/multipart/multipart_test.go | 5 | ||||
-rw-r--r-- | src/mime/quotedprintable/reader_test.go | 13 |
3 files changed, 24 insertions, 3 deletions
diff --git a/src/mime/multipart/formdata_test.go b/src/mime/multipart/formdata_test.go index 105a82c417..7d756c8c24 100644 --- a/src/mime/multipart/formdata_test.go +++ b/src/mime/multipart/formdata_test.go @@ -176,7 +176,11 @@ func (r *failOnReadAfterErrorReader) Read(p []byte) (n int, err error) { // TestReadForm_NonFileMaxMemory asserts that the ReadForm maxMemory limit is applied // while processing non-file form data as well as file form data. func TestReadForm_NonFileMaxMemory(t *testing.T) { - largeTextValue := strings.Repeat("1", (10<<20)+25) + n := 10<<20 + 25 + if testing.Short() { + n = 10<<10 + 25 + } + largeTextValue := strings.Repeat("1", n) message := `--MyBoundary Content-Disposition: form-data; name="largetext" @@ -196,6 +200,9 @@ Content-Disposition: form-data; name="largetext" } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + if tc.maxMemory == 0 && testing.Short() { + t.Skip("skipping in -short mode") + } b := strings.NewReader(testBody) r := NewReader(b, boundary) f, err := r.ReadForm(tc.maxMemory) diff --git a/src/mime/multipart/multipart_test.go b/src/mime/multipart/multipart_test.go index 5a8102b822..5dc74b5ffe 100644 --- a/src/mime/multipart/multipart_test.go +++ b/src/mime/multipart/multipart_test.go @@ -832,7 +832,10 @@ func partsFromReader(r *Reader) ([]headerBody, error) { func TestParseAllSizes(t *testing.T) { t.Parallel() - const maxSize = 5 << 10 + maxSize := 5 << 10 + if testing.Short() { + maxSize = 512 + } var buf bytes.Buffer body := strings.Repeat("a", maxSize) bodyb := []byte(body) diff --git a/src/mime/quotedprintable/reader_test.go b/src/mime/quotedprintable/reader_test.go index f870bdaa8d..48a7ff6495 100644 --- a/src/mime/quotedprintable/reader_test.go +++ b/src/mime/quotedprintable/reader_test.go @@ -116,7 +116,11 @@ func TestExhaustive(t *testing.T) { var buf bytes.Buffer res := make(map[string]int) - everySequence("", "0A \r\n=", 6, func(s string) { + n := 6 + if testing.Short() { + n = 4 + } + everySequence("", "0A \r\n=", n, func(s string) { if strings.HasSuffix(s, "=") || strings.Contains(s, "==") { return } @@ -200,6 +204,13 @@ func TestExhaustive(t *testing.T) { invalid bytes after =: 3949 quotedprintable: invalid hex byte 0x0d: 2048 unexpected EOF: 194` + if testing.Short() { + want = `OK: 896 +invalid bytes after =: 100 +quotedprintable: invalid hex byte 0x0d: 26 +unexpected EOF: 3` + } + if got != want { t.Errorf("Got:\n%s\nWant:\n%s", got, want) } |