]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: in tests, add sync before closing file in copyFile helper
authorMichael Matloob <matloob@golang.org>
Thu, 20 Feb 2020 17:53:32 +0000 (12:53 -0500)
committerMichael Matloob <matloob@golang.org>
Thu, 20 Feb 2020 19:33:59 +0000 (19:33 +0000)
An experiment to see if this helps flakiness go away in
TestExecutableGOROOT.

Updates #37306

Change-Id: I2f4f63bdb507359ca07267d86cdb41fe4968f151
Reviewed-on: https://go-review.googlesource.com/c/go/+/220317
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/go_test.go

index 9da94360f9ffb9ff6287d0c9ca77ea29aff5b170..8926482b05060b355d42f55a593659550b5fedc1 100644 (file)
@@ -2454,11 +2454,15 @@ func copyFile(src, dst string, perm os.FileMode) error {
        }
 
        _, err = io.Copy(df, sf)
-       err2 := df.Close()
+       err2 := df.Sync()
+       err3 := df.Close()
        if err != nil {
                return err
        }
-       return err2
+       if err2 != nil {
+               return err2
+       }
+       return err3
 }
 
 // TestExecutableGOROOT verifies that the cmd/go binary itself uses