From 42fed841d3735658d738aff34e135f8e461012dd Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Tue, 14 Jan 2014 11:42:03 -0700 Subject: [PATCH] Fix "foo: no such file or directory" test failure, and normalize creation of custom error to always depend on if os.IsNotExist(err) so we don't hide other errors that might crop up in these tests Docker-DCO-1.1-Signed-off-by: Andrew Page (github: tianon) Docker-DCO-1.1-Signed-off-by: Tianon Gravi (github: crosbymichael) --- buildfile.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/buildfile.go b/buildfile.go index 6b568d7563..2b6d40c15d 100644 --- a/buildfile.go +++ b/buildfile.go @@ -288,6 +288,9 @@ func (b *buildFile) CmdVolume(args string) error { func (b *buildFile) checkPathForAddition(orig string) error { origPath := path.Join(b.contextPath, orig) if p, err := filepath.EvalSymlinks(origPath); err != nil { + if os.IsNotExist(err) { + return fmt.Errorf("%s: no such file or directory", orig) + } return err } else { origPath = p @@ -297,7 +300,10 @@ func (b *buildFile) checkPathForAddition(orig string) error { } _, err := os.Stat(origPath) if err != nil { - return fmt.Errorf("%s: no such file or directory", orig) + if os.IsNotExist(err) { + return fmt.Errorf("%s: no such file or directory", orig) + } + return err } return nil } @@ -313,7 +319,10 @@ func (b *buildFile) addContext(container *Container, orig, dest string) error { } fi, err := os.Stat(origPath) if err != nil { - return fmt.Errorf("%s: no such file or directory", orig) + if os.IsNotExist(err) { + return fmt.Errorf("%s: no such file or directory", orig) + } + return err } if fi.IsDir() { if err := archive.CopyWithTar(origPath, destPath); err != nil {