1
0
mirror of https://github.com/golang/go synced 2024-09-25 15:10:11 -06:00

io/ioutil: use filepath.Join, handle trailing / in $TMPDIR

R=niemeyer
CC=golang-dev
https://golang.org/cl/4256057
This commit is contained in:
Russ Cox 2011-03-06 21:52:37 -05:00
parent 94401f524e
commit 2b4a9603d3

View File

@ -7,6 +7,7 @@ package ioutil_test
import (
. "io/ioutil"
"os"
"path/filepath"
"regexp"
"testing"
)
@ -25,7 +26,7 @@ func TestTempFile(t *testing.T) {
if f != nil {
f.Close()
os.Remove(f.Name())
re := regexp.MustCompile("^" + regexp.QuoteMeta(dir) + "/ioutil_test[0-9]+$")
re := regexp.MustCompile("^" + regexp.QuoteMeta(filepath.Join(dir, "ioutil_test")) + "[0-9]+$")
if !re.MatchString(f.Name()) {
t.Errorf("TempFile(`"+dir+"`, `ioutil_test`) created bad name %s", f.Name())
}
@ -45,7 +46,7 @@ func TestTempDir(t *testing.T) {
}
if name != "" {
os.Remove(name)
re := regexp.MustCompile("^" + regexp.QuoteMeta(dir) + "/ioutil_test[0-9]+$")
re := regexp.MustCompile("^" + regexp.QuoteMeta(filepath.Join(dir, "ioutil_test")) + "[0-9]+$")
if !re.MatchString(name) {
t.Errorf("TempDir(`"+dir+"`, `ioutil_test`) created bad name %s", name)
}