]> Cypherpunks repositories - gostls13.git/commitdiff
net: don't ignore errors in TestUnixUnlink
authorqmuntal <quimmuntal@gmail.com>
Thu, 8 Jan 2026 09:25:44 +0000 (10:25 +0100)
committerQuim Muntal <quimmuntal@gmail.com>
Mon, 12 Jan 2026 19:53:00 +0000 (11:53 -0800)
TestUnixUnlink calls some functions and methods that can fail, but it
ignores the returned errors. This test is flaky on Windows, and those
errors should be checked to help diagnose the problem.

Updates #75282
Updates #76582
Updates #77038

Change-Id: Ia868762a4c0b94a7255d57add63777568caa6cd2
Reviewed-on: https://go-review.googlesource.com/c/go/+/734720
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/net/unixsock_test.go

index f6c5679f4291b35d1977533eac221cbba9d1fe55..3e4a14b2550644a6525e9e186328a166e1759f46 100644 (file)
@@ -375,6 +375,17 @@ func TestUnixUnlink(t *testing.T) {
                }
                return l.(*UnixListener)
        }
+       fileListener := func(t *testing.T, l *UnixListener) (*os.File, Listener) {
+               f, err := l.File()
+               if err != nil {
+                       t.Fatal(err)
+               }
+               ln, err := FileListener(f)
+               if err != nil {
+                       t.Fatal(err)
+               }
+               return f, ln
+       }
        checkExists := func(t *testing.T, desc string) {
                if _, err := os.Stat(name); err != nil {
                        t.Fatalf("unix socket does not exist %s: %v", desc, err)
@@ -397,8 +408,7 @@ func TestUnixUnlink(t *testing.T) {
        // FileListener should not.
        t.Run("FileListener", func(t *testing.T) {
                l := listen(t)
-               f, _ := l.File()
-               l1, _ := FileListener(f)
+               f, l1 := fileListener(t, l)
                checkExists(t, "after FileListener")
                f.Close()
                checkExists(t, "after File close")
@@ -444,8 +454,7 @@ func TestUnixUnlink(t *testing.T) {
 
        t.Run("FileListener/SetUnlinkOnClose(true)", func(t *testing.T) {
                l := listen(t)
-               f, _ := l.File()
-               l1, _ := FileListener(f)
+               f, l1 := fileListener(t, l)
                checkExists(t, "after FileListener")
                l1.(*UnixListener).SetUnlinkOnClose(true)
                f.Close()
@@ -457,8 +466,7 @@ func TestUnixUnlink(t *testing.T) {
 
        t.Run("FileListener/SetUnlinkOnClose(false)", func(t *testing.T) {
                l := listen(t)
-               f, _ := l.File()
-               l1, _ := FileListener(f)
+               f, l1 := fileListener(t, l)
                checkExists(t, "after FileListener")
                l1.(*UnixListener).SetUnlinkOnClose(false)
                f.Close()