Add tmpdir as a parameter to the closure otherwise the subsequent
modifications to tmpdir causes only the last subdirectory to be
removed.
Additionally, add the missing argument for the t.Fatalf call.
Change-Id: I3df53f9051f7ea40cf3f846d47d9cefe445e9b9d
Reviewed-on: https://go-review.googlesource.com/32892
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
func TestLongPath(t *testing.T) {
tmpdir := newDir("TestLongPath", t)
- defer func() {
- if err := RemoveAll(tmpdir); err != nil {
+ defer func(d string) {
+ if err := RemoveAll(d); err != nil {
t.Fatalf("RemoveAll failed: %v", err)
}
- }()
+ }(tmpdir)
for len(tmpdir) < 400 {
tmpdir += "/dir3456789"
}
}
}
if err := Truncate(tmpdir+"/bar.txt", 0); err != nil {
- t.Fatalf("Truncate failed: %v")
+ t.Fatalf("Truncate failed: %v", err)
}
}
}