diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-06-04 23:15:33 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-06-04 23:15:33 +0000 |
commit | 5892f89fbf9417381ac68163890704fe9e7d11f7 (patch) | |
tree | 89766166feb4ceca2d983169c5360e3f6f521b12 /libgo/go/path/filepath/path_test.go | |
parent | 40196b7832598b0a0298d7a8bc5b8a4c723c80aa (diff) | |
download | gcc-5892f89fbf9417381ac68163890704fe9e7d11f7.tar.gz |
libgo: Merge from revision 18783:00cce3a34d7e of master library.
This revision was committed January 7, 2014. The next
revision deleted runtime/mfinal.c. That will be done in a
subsequent merge.
This merge changes type descriptors to add a zero field,
pointing to a zero value for that type. This is implemented
as a common variable.
* go-gcc.cc (Gcc_backend::implicit_variable): Add is_common and
alignment parameters. Permit init parameter to be NULL.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211249 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/path/filepath/path_test.go')
-rw-r--r-- | libgo/go/path/filepath/path_test.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/libgo/go/path/filepath/path_test.go b/libgo/go/path/filepath/path_test.go index 3a6e83d8fad..dc87d791037 100644 --- a/libgo/go/path/filepath/path_test.go +++ b/libgo/go/path/filepath/path_test.go @@ -5,6 +5,7 @@ package filepath_test import ( + "errors" "io/ioutil" "os" "path/filepath" @@ -461,6 +462,63 @@ func TestWalk(t *testing.T) { } } +func touch(t *testing.T, name string) { + f, err := os.Create(name) + if err != nil { + t.Fatal(err) + } + if err := f.Close(); err != nil { + t.Fatal(err) + } +} + +func TestWalkFileError(t *testing.T) { + td, err := ioutil.TempDir("", "walktest") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(td) + + touch(t, filepath.Join(td, "foo")) + touch(t, filepath.Join(td, "bar")) + dir := filepath.Join(td, "dir") + if err := os.MkdirAll(filepath.Join(td, "dir"), 0755); err != nil { + t.Fatal(err) + } + touch(t, filepath.Join(dir, "baz")) + touch(t, filepath.Join(dir, "stat-error")) + defer func() { + *filepath.LstatP = os.Lstat + }() + statErr := errors.New("some stat error") + *filepath.LstatP = func(path string) (os.FileInfo, error) { + if strings.HasSuffix(path, "stat-error") { + return nil, statErr + } + return os.Lstat(path) + } + got := map[string]error{} + err = filepath.Walk(td, func(path string, fi os.FileInfo, err error) error { + rel, _ := filepath.Rel(td, path) + got[filepath.ToSlash(rel)] = err + return nil + }) + if err != nil { + t.Errorf("Walk error: %v", err) + } + want := map[string]error{ + ".": nil, + "foo": nil, + "bar": nil, + "dir": nil, + "dir/baz": nil, + "dir/stat-error": statErr, + } + if !reflect.DeepEqual(got, want) { + t.Errorf("Walked %#v; want %#v", got, want) + } +} + var basetests = []PathTest{ {"", "."}, {".", "."}, |