From: Tim King Date: Wed, 2 Dec 2020 01:55:35 +0000 (-0800) Subject: doc/go1.16: add vet release note for CL 235677 X-Git-Tag: go1.16beta1~44 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1fe891a937eae62ce396f3d7c7c6c472701acf0a;p=gostls13.git doc/go1.16: add vet release note for CL 235677 For #40700 Fixes #42895 Change-Id: I05b60f0d000512d5dddb3d61e0e695aa01943d6a Reviewed-on: https://go-review.googlesource.com/c/go/+/274617 Trust: Tim King Reviewed-by: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov --- diff --git a/doc/go1.16.html b/doc/go1.16.html index 44d9707c16..e0187effd7 100644 --- a/doc/go1.16.html +++ b/doc/go1.16.html @@ -283,12 +283,55 @@ Do not send CLs removing the interior tags from such phrases.

Vet

-

- TODO +

New warning for invalid testing.T use in +goroutines

- +

+ The vet tool now warns about invalid calls to the testing.T + method Fatal from within a goroutine created during the test. + This also warns on calls to Fatalf, FailNow, and + Skip{,f,Now} methods on testing.T tests or + testing.B benchmarks.

+

+ Calls to these methods stop the execution of the created goroutine and not + the Test* or Benchmark* function. So these are + required to be called by the goroutine + running the test or benchmark function. For example: +

+ +
+func TestFoo(t *testing.T) {
+    go func() {
+        if condition() {
+            t.Fatal("oops") // This exits the inner func instead of TestFoo.
+        }
+        ...
+    }()
+}
+
+ +

+ Code calling t.Fatal (or a similar method) from a created + goroutine should be rewritten to signal the test failure using + t.Error and exit the goroutine early using an alternative + method, such as using a return statement. The previous example + could be rewritten as: +

+ +
+func TestFoo(t *testing.T) {
+    go func() {
+        if condition() {
+            t.Error("oops")
+            return
+        }
+        ...
+    }()
+}
+
+

The vet tool now warns about amd64 assembly that clobbers the BP register (the frame pointer) without saving and restoring it,