"fmt"
"io/ioutil"
. "os"
+ "path/filepath"
"runtime"
"strings"
"testing"
)
func TestRemoveAll(t *testing.T) {
- tmpDir := TempDir()
- // Work directory.
- file := "file"
- path := tmpDir + "/_TestRemoveAll_"
- fpath := path + "/file"
- dpath := path + "/dir"
+ tmpDir, err := ioutil.TempDir("", "TestRemoveAll-")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer RemoveAll(tmpDir)
+
+ file := filepath.Join(tmpDir, "file")
+ path := filepath.Join(tmpDir, "_TestRemoveAll_")
+ fpath := filepath.Join(path, "file")
+ dpath := filepath.Join(path, "dir")
// Make a regular file and remove
fd, err := Create(file)
t.Skip("skipping in short mode")
}
- tmpDir := TempDir()
- // Work directory.
- path := tmpDir + "/_TestRemoveAllLarge_"
+ tmpDir, err := ioutil.TempDir("", "TestRemoveAll-")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer RemoveAll(tmpDir)
+
+ path := filepath.Join(tmpDir, "_TestRemoveAllLarge_")
// Make directory with 1000 files and remove.
if err := MkdirAll(path, 0777); err != nil {
if err != nil {
t.Fatalf("Could not create TempDir: %s", err)
}
+ defer RemoveAll(startPath)
+
err = Chdir(startPath)
if err != nil {
t.Fatalf("Could not chdir %s: %s", startPath, err)
if err != nil {
t.Fatalf("Could not create TempDir: %s", err)
}
+ defer RemoveAll(tempDir)
+
err = Chdir(tempDir)
if err != nil {
t.Fatalf("Could not chdir to tempdir: %s", err)