]> Cypherpunks repositories - gostls13.git/commit
context: clean up test files
authorSameer Ajmani <sameer@google.com>
Wed, 29 Mar 2023 21:47:50 +0000 (17:47 -0400)
committerSameer Ajmani <sameer@golang.org>
Wed, 5 Apr 2023 17:18:14 +0000 (17:18 +0000)
commite7d59ed204bbb0e70fe1898abb1b82fdf7c25a1f
tree0d3eece7d7fe53dc1aa27ce1c1d52a002c0c7d58
parent0d719823af1343f9921ee0293596f09e36ced0e4
context: clean up test files

Tests in package context cannot depend directly on package testing due to an import cycle.
We resolved this by having test functions in package context_test (x_test.go) forward to
test functions in package context (context_test.go). This is fragile, since it's easy
to add a test to context_test.go and forget to add the forwarding function, and tests
written in this way cannot easily use testing package features like t.Run for subtests.

It turns out that only four test functions actually use unexported members of package
context. This CL moves all except those four to x_test.go and makes them regular tests.
It also updates TestCause to use t.Run and t.Parallel to parallelize its test cases.
It also adds documentation indicating when tests should be added to each file.

Change-Id: Ic60bae32a7a44e07831b5388c9af219d53ba9af3
Reviewed-on: https://go-review.googlesource.com/c/go/+/480375
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Sameer Ajmani <sameer@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
src/context/context_test.go
src/context/example_test.go
src/context/x_test.go