diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-03-30 21:27:11 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-03-30 21:27:11 +0000 |
commit | 456fba2651cfb0cb67e44b8354668a0b3f5f5182 (patch) | |
tree | 9a0dfa827abe382ac0f44768e5365b87f00ac0a9 /libgo/go/path/filepath/path_test.go | |
parent | e0be8a5c203451b47fd3da59b0e0f56cc3d42f22 (diff) | |
download | gcc-456fba2651cfb0cb67e44b8354668a0b3f5f5182.tar.gz |
libgo: Update to weekly.2012-03-13.
From-SVN: r186023
Diffstat (limited to 'libgo/go/path/filepath/path_test.go')
-rw-r--r-- | libgo/go/path/filepath/path_test.go | 79 |
1 files changed, 55 insertions, 24 deletions
diff --git a/libgo/go/path/filepath/path_test.go b/libgo/go/path/filepath/path_test.go index 93cca1e4c2b..87cb5e55308 100644 --- a/libgo/go/path/filepath/path_test.go +++ b/libgo/go/path/filepath/path_test.go @@ -10,6 +10,7 @@ import ( "path/filepath" "reflect" "runtime" + "strings" "testing" ) @@ -439,7 +440,7 @@ func TestBase(t *testing.T) { tests := basetests if runtime.GOOS == "windows" { // make unix tests work on windows - for i, _ := range tests { + for i := range tests { tests[i].result = filepath.Clean(tests[i].result) } // add windows specific tests @@ -482,7 +483,7 @@ func TestDir(t *testing.T) { tests := dirtests if runtime.GOOS == "windows" { // make unix tests work on windows - for i, _ := range tests { + for i := range tests { tests[i].result = filepath.Clean(tests[i].result) } // add windows specific tests @@ -620,6 +621,12 @@ func TestEvalSymlinks(t *testing.T) { if d.path == d.dest { // will test only real files and directories tests = append(tests, d) + // test "canonical" names + d2 := EvalSymlinksTest{ + path: strings.ToUpper(d.path), + dest: d.dest, + } + tests = append(tests, d2) } } } else { @@ -641,35 +648,61 @@ func TestEvalSymlinks(t *testing.T) { } } -/* These tests do not work in the gccgo test environment. +// Test directories relative to temporary directory. +// The tests are run in absTestDirs[0]. +var absTestDirs = []string{ + "a", + "a/b", + "a/b/c", +} -// Test paths relative to $GOROOT/src -var abstests = []string{ - "../AUTHORS", - "pkg/../../AUTHORS", - "Make.inc", - "pkg/math", +// Test paths relative to temporary directory. $ expands to the directory. +// The tests are run in absTestDirs[0]. +// We create absTestDirs first. +var absTests = []string{ ".", - "$GOROOT/src/Make.inc", - "$GOROOT/src/../src/Make.inc", - "$GOROOT/misc/cgo", - "$GOROOT", + "b", + "../a", + "../a/b", + "../a/b/./c/../../.././a", + "$", + "$/.", + "$/a/../a/b", + "$/a/b/c/../../.././a", } func TestAbs(t *testing.T) { - t.Logf("test needs to be rewritten; disabled") - return - oldwd, err := os.Getwd() if err != nil { - t.Fatal("Getwd failed: " + err.Error()) + t.Fatal("Getwd failed: ", err) } defer os.Chdir(oldwd) - goroot := os.Getenv("GOROOT") - cwd := filepath.Join(goroot, "src") - os.Chdir(cwd) - for _, path := range abstests { - path = strings.Replace(path, "$GOROOT", goroot, -1) + + root, err := ioutil.TempDir("", "TestAbs") + if err != nil { + t.Fatal("TempDir failed: ", err) + } + defer os.RemoveAll(root) + + err = os.Chdir(root) + if err != nil { + t.Fatal("chdir failed: ", err) + } + + for _, dir := range absTestDirs { + err = os.Mkdir(dir, 0777) + if err != nil { + t.Fatal("Mkdir failed: ", err) + } + } + + err = os.Chdir(absTestDirs[0]) + if err != nil { + t.Fatal("chdir failed: ", err) + } + + for _, path := range absTests { + path = strings.Replace(path, "$", root, -1) info, err := os.Stat(path) if err != nil { t.Errorf("%s: %s", path, err) @@ -694,8 +727,6 @@ func TestAbs(t *testing.T) { } } -*/ - type RelTests struct { root, path, want string } |