From: Brad Fitzpatrick Date: Wed, 29 Feb 2012 17:53:20 +0000 (-0800) Subject: net/http: make a test more paranoid & reliable on Windows, maybe. X-Git-Tag: weekly.2012-03-04~88 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3684ae9da0ad00db01596393f2ac992fa3b0b05f;p=gostls13.git net/http: make a test more paranoid & reliable on Windows, maybe. Part of diagnosing issue 3050. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5707056 --- diff --git a/src/pkg/net/http/fs_test.go b/src/pkg/net/http/fs_test.go index 0409008b67..5aa93ce583 100644 --- a/src/pkg/net/http/fs_test.go +++ b/src/pkg/net/http/fs_test.go @@ -152,12 +152,19 @@ func TestFileServerCleans(t *testing.T) { } } +func mustRemoveAll(dir string) { + err := os.RemoveAll(dir) + if err != nil { + panic(err) + } +} + func TestFileServerImplicitLeadingSlash(t *testing.T) { tempDir, err := ioutil.TempDir("", "") if err != nil { t.Fatalf("TempDir: %v", err) } - defer os.RemoveAll(tempDir) + defer mustRemoveAll(tempDir) if err := ioutil.WriteFile(filepath.Join(tempDir, "foo.txt"), []byte("Hello world"), 0644); err != nil { t.Fatalf("WriteFile: %v", err) } @@ -172,6 +179,7 @@ func TestFileServerImplicitLeadingSlash(t *testing.T) { if err != nil { t.Fatalf("ReadAll %s: %v", suffix, err) } + res.Body.Close() return string(b) } if s := get("/bar/"); !strings.Contains(s, ">foo.txt<") {