}
func TestDeflateInflate(t *testing.T) {
+ t.Parallel()
for i, h := range deflateInflateTests {
testToFromWithLimit(t, h.in, fmt.Sprintf("#%d", i), [11]int{})
}
}
func TestDeflateInflateString(t *testing.T) {
+ t.Parallel()
if testing.Short() && testenv.Builder() == "" {
t.Skip("skipping in short mode")
}
}
func TestWriterReset(t *testing.T) {
+ t.Parallel()
for level := 0; level <= 9; level++ {
if testing.Short() && level > 1 {
break
// compressor.encSpeed method (0, 16, 128), as well as near maxStoreBlockSize
// (65535).
func TestBestSpeed(t *testing.T) {
+ t.Parallel()
abc := make([]byte, 128)
for i := range abc {
abc[i] = byte(i)
}
func TestWriterPersistentError(t *testing.T) {
+ t.Parallel()
d, err := ioutil.ReadFile("../testdata/Mark.Twain-Tom.Sawyer.txt")
if err != nil {
t.Fatalf("ReadFile: %v", err)
}
func TestBestSpeedMatch(t *testing.T) {
+ t.Parallel()
cases := []struct {
previous, current []byte
t, s, want int32
}
func TestBestSpeedMaxMatchOffset(t *testing.T) {
+ t.Parallel()
const abc, xyz = "abcdefgh", "stuvwxyz"
for _, matchBefore := range []bool{false, true} {
for _, extra := range []int{0, inputMargin - 1, inputMargin, inputMargin + 1, 2 * inputMargin} {
//
// See https://github.com/google/go-github/pull/317 for background.
func TestReaderEarlyEOF(t *testing.T) {
+ t.Parallel()
testSizes := []int{
1, 2, 3, 4, 5, 6, 7, 8,
100, 1000, 10000, 100000,
// Test if errors from the underlying writer is passed upwards.
func TestWriteError(t *testing.T) {
+ t.Parallel()
buf := new(bytes.Buffer)
n := 65536
if !testing.Short() {
// Test if two runs produce identical results
// even when writing different sizes to the Writer.
func TestDeterministic(t *testing.T) {
+ t.Parallel()
for i := 0; i <= 9; i++ {
t.Run(fmt.Sprint("L", i), func(t *testing.T) { testDeterministic(i, t) })
}
}
func testDeterministic(i int, t *testing.T) {
+ t.Parallel()
// Test so much we cross a good number of block boundaries.
var length = maxStoreBlockSize*30 + 500
if testing.Short() {
"path/filepath"
"strconv"
"strings"
+ "sync"
"testing"
"time"
)
}
}
+var (
+ didParMu sync.Mutex
+ didPar = map[*testing.T]bool{}
+)
+
+// setParallel calls t.Parallel once. If you call it twice, it would
+// panic.
+func setParallel(t *testing.T) {
+ didParMu.Lock()
+ v := didPar[t]
+ didPar[t] = true
+ didParMu.Unlock()
+ if !v {
+ t.Parallel()
+ }
+}
+
func runClientTestForVersion(t *testing.T, template *clientTest, prefix, option string) {
+ setParallel(t)
+
test := *template
test.name = prefix + test.name
if len(test.command) == 0 {
}
func TestHandshakeRace(t *testing.T) {
+ t.Parallel()
// This test races a Read and Write to try and complete a handshake in
// order to provide some evidence that there are no races or deadlocks
// in the handshake locking.
}
func runServerTestForVersion(t *testing.T, template *serverTest, prefix, option string) {
+ setParallel(t)
test := *template
test.name = prefix + test.name
if len(test.command) == 0 {
-----END EC PRIVATE KEY-----`
func TestClientAuth(t *testing.T) {
+ setParallel(t)
var certPath, keyPath, ecdsaCertPath, ecdsaKeyPath string
if *update {
}
func TestX509KeyPair(t *testing.T) {
+ t.Parallel()
var pem []byte
for _, test := range keyPairTests {
pem = []byte(test.cert + test.key)
}
func TestStringBytes(t *testing.T) {
+ t.Parallel()
// Test that encodeState.stringBytes and encodeState.string use the same encoding.
var r []rune
for i := '\u0000'; i <= unicode.MaxRune; i++ {
}
func TestMarshalFloat(t *testing.T) {
+ t.Parallel()
nfail := 0
test := func(f float64, bits int) {
vf := interface{}(f)
}
func TestIndentBig(t *testing.T) {
+ t.Parallel()
initBig()
var buf bytes.Buffer
if err := Indent(&buf, jsonBig, "", "\t"); err != nil {
}
func TestFiles(t *testing.T) {
+ t.Parallel()
for _, e := range data {
source := filepath.Join(dataDir, e.source)
golden := filepath.Join(dataDir, e.golden)
- check(t, source, golden, e.mode)
- // TODO(gri) check that golden is idempotent
- //check(t, golden, golden, e.mode)
+ mode := e.mode
+ t.Run(e.source, func(t *testing.T) {
+ t.Parallel()
+ check(t, source, golden, mode)
+ // TODO(gri) check that golden is idempotent
+ //check(t, golden, golden, e.mode)
+ })
}
}
// even if the position information of comments introducing newlines
// is incorrect.
func TestBadComments(t *testing.T) {
+ t.Parallel()
const src = `
// first comment - text and position changed by test
package p
}
func TestBaseIndent(t *testing.T) {
+ t.Parallel()
// The testfile must not contain multi-line raw strings since those
// are not indented (because their values must not change) and make
// this test fail.
panic(err) // error in test
}
- var buf bytes.Buffer
for indent := 0; indent < 4; indent++ {
- buf.Reset()
- (&Config{Tabwidth: tabwidth, Indent: indent}).Fprint(&buf, fset, file)
- // all code must be indented by at least 'indent' tabs
- lines := bytes.Split(buf.Bytes(), []byte{'\n'})
- for i, line := range lines {
- if len(line) == 0 {
- continue // empty lines don't have indentation
- }
- n := 0
- for j, b := range line {
- if b != '\t' {
- // end of indentation
- n = j
- break
+ indent := indent
+ t.Run(fmt.Sprint(indent), func(t *testing.T) {
+ t.Parallel()
+ var buf bytes.Buffer
+ (&Config{Tabwidth: tabwidth, Indent: indent}).Fprint(&buf, fset, file)
+ // all code must be indented by at least 'indent' tabs
+ lines := bytes.Split(buf.Bytes(), []byte{'\n'})
+ for i, line := range lines {
+ if len(line) == 0 {
+ continue // empty lines don't have indentation
+ }
+ n := 0
+ for j, b := range line {
+ if b != '\t' {
+ // end of indentation
+ n = j
+ break
+ }
+ }
+ if n < indent {
+ t.Errorf("line %d: got only %d tabs; want at least %d: %q", i, n, indent, line)
}
}
- if n < indent {
- t.Errorf("line %d: got only %d tabs; want at least %d: %q", i, n, indent, line)
- }
- }
+ })
}
}
// Test whether the printer stops writing after the first error
func TestWriteErrors(t *testing.T) {
+ t.Parallel()
const filename = "printer.go"
src, err := ioutil.ReadFile(filename)
if err != nil {
}
func TestWithSimulated(t *testing.T) {
+ t.Parallel()
msg := "Test 123"
var transport []string
for _, n := range []string{"unix", "unixgram", "udp", "tcp"} {
}
func TestWrite(t *testing.T) {
+ t.Parallel()
tests := []struct {
pri Priority
pre string
}
func testMultipart(t *testing.T, r io.Reader, onlyNewlines bool) {
+ t.Parallel()
reader := NewReader(r, "MyBoundary")
buf := new(bytes.Buffer)
}
func TestParseAllSizes(t *testing.T) {
+ t.Parallel()
const maxSize = 5 << 10
var buf bytes.Buffer
body := strings.Repeat("a", maxSize)
)
func TestCgoCrashHandler(t *testing.T) {
+ t.Parallel()
testCrashHandler(t, true)
}
func TestCgoSignalDeadlock(t *testing.T) {
+ t.Parallel()
if testing.Short() && runtime.GOOS == "windows" {
t.Skip("Skipping in short mode") // takes up to 64 seconds
}
}
func TestCgoTraceback(t *testing.T) {
+ t.Parallel()
got := runTestProg(t, "testprogcgo", "CgoTraceback")
want := "OK\n"
if got != want {
}
func TestCgoCallbackGC(t *testing.T) {
+ t.Parallel()
switch runtime.GOOS {
case "plan9", "windows":
t.Skipf("no pthreads on %s", runtime.GOOS)
}
func TestCgoExternalThreadPanic(t *testing.T) {
+ t.Parallel()
if runtime.GOOS == "plan9" {
t.Skipf("no pthreads on %s", runtime.GOOS)
}
}
func TestCgoExternalThreadSIGPROF(t *testing.T) {
+ t.Parallel()
// issue 9456.
switch runtime.GOOS {
case "plan9", "windows":
}
func TestCgoExternalThreadSignal(t *testing.T) {
+ t.Parallel()
// issue 10139
switch runtime.GOOS {
case "plan9", "windows":
}
func TestCgoExecSignalMask(t *testing.T) {
+ t.Parallel()
// Test issue 13164.
switch runtime.GOOS {
case "windows", "plan9":
}
func TestEnsureDropM(t *testing.T) {
+ t.Parallel()
// Test for issue 13881.
switch runtime.GOOS {
case "windows", "plan9":
// Test that the program that doesn't need any cgo pointer checking
// takes about the same amount of time with it as without it.
func TestCgoCheckBytes(t *testing.T) {
+ t.Parallel()
// Make sure we don't count the build time as part of the run time.
testenv.MustHaveGoBuild(t)
exe, err := buildTestProg(t, "testprogcgo")
}
func TestCgoPanicDeadlock(t *testing.T) {
+ t.Parallel()
// test issue 14432
got := runTestProg(t, "testprogcgo", "CgoPanicDeadlock")
want := "panic: cgo error\n\n"
}
func TestCgoCCodeSIGPROF(t *testing.T) {
+ t.Parallel()
got := runTestProg(t, "testprogcgo", "CgoCCodeSIGPROF")
want := "OK\n"
if got != want {
}
func TestCgoCrashTraceback(t *testing.T) {
+ t.Parallel()
if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
}
}
func TestCgoTracebackContext(t *testing.T) {
+ t.Parallel()
got := runTestProg(t, "testprogcgo", "TracebackContext")
want := "OK\n"
if got != want {
}
func testCgoPprof(t *testing.T, buildArg, runArg string) {
+ t.Parallel()
if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
}
}
func TestRaceSignal(t *testing.T) {
+ t.Parallel()
if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
}
}
func TestNetpollDeadlock(t *testing.T) {
+ t.Parallel()
output := runTestProg(t, "testprognet", "NetpollDeadlock")
want := "done\n"
if !strings.HasSuffix(output, want) {
}
func TestPanicTraceback(t *testing.T) {
+ t.Parallel()
output := runTestProg(t, "testprog", "PanicTraceback")
want := "panic: hello"
if !strings.HasPrefix(output, want) {
checkStaleRuntime(t)
+ t.Parallel()
+
dir, err := ioutil.TempDir("", "go-build")
if err != nil {
t.Fatalf("failed to create temp directory: %v", err)
}
func testConcurrentReadsAfterGrowth(t *testing.T, useReflect bool) {
+ t.Parallel()
if runtime.GOMAXPROCS(-1) == 1 {
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(16))
}
// TestMemmoveOverflow maps 3GB of memory and calls memmove on
// the corresponding slice.
func TestMemmoveOverflow(t *testing.T) {
+ t.Parallel()
// Create a temporary file.
tmp, err := ioutil.TempFile("", "go-memmovetest")
if err != nil {
)
func TestMemmove(t *testing.T) {
+ t.Parallel()
size := 256
if testing.Short() {
size = 128 + 16
}
func TestMemmoveAlias(t *testing.T) {
+ t.Parallel()
size := 256
if testing.Short() {
size = 128 + 16
}
func TestMemmoveLarge0x180000(t *testing.T) {
+ t.Parallel()
if race.Enabled {
t.Skip("skipping large memmove test under race detector")
}
}
func TestMemmoveOverlapLarge0x120000(t *testing.T) {
+ t.Parallel()
if race.Enabled {
t.Skip("skipping large memmove test under race detector")
}
`
func TestGdbPython(t *testing.T) {
+ t.Parallel()
checkGdbEnvironment(t)
checkGdbVersion(t)
checkGdbPython(t)
// TestGdbBacktrace tests that gdb can unwind the stack correctly
// using only the DWARF debug info.
func TestGdbBacktrace(t *testing.T) {
+ t.Parallel()
checkGdbEnvironment(t)
checkGdbVersion(t)