]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: make a test more paranoid & reliable on Windows, maybe.
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 29 Feb 2012 17:53:20 +0000 (09:53 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 29 Feb 2012 17:53:20 +0000 (09:53 -0800)
Part of diagnosing issue 3050.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5707056

src/pkg/net/http/fs_test.go

index 0409008b6755bb0aaa97121a4f4424075d346488..5aa93ce58373d7437b79363e6aa5dab2b0666467 100644 (file)
@@ -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<") {