Commit 2cc0f220 authored by Mikio Hara's avatar Mikio Hara Committed by Andrew Gerrand

Revert "cmd/build: reject non-existant directories in ImportDir"

This reverts commit 7af2ce3f.

The commit had a wrong prefix in the description line, probably
misreconginized something. As a result it broke golang.org/x/tools/godoc
and golang.org/x/tools/cmd/godoc like the following:

--- FAIL: TestCLI (10.90s)
--- FAIL: TestWeb (13.74s)
FAIL
FAIL        golang.org/x/tools/cmd/godoc    36.428s
--- FAIL: TestCommandLine (0.00s)
FAIL
FAIL        golang.org/x/tools/godoc        0.068s

Change-Id: I362a862a4ded8592dec7488a28e7a256adee148f
Reviewed-on: https://go-review.googlesource.com/23076
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: default avatarAndrew Gerrand <adg@golang.org>
parent be5782c3
...@@ -403,11 +403,7 @@ func (p *Package) IsCommand() bool { ...@@ -403,11 +403,7 @@ func (p *Package) IsCommand() bool {
// ImportDir is like Import but processes the Go package found in // ImportDir is like Import but processes the Go package found in
// the named directory. // the named directory.
func (ctxt *Context) ImportDir(dir string, mode ImportMode) (*Package, error) { func (ctxt *Context) ImportDir(dir string, mode ImportMode) (*Package, error) {
p, err := ctxt.Import(".", dir, mode) return ctxt.Import(".", dir, mode)
if err == nil && !ctxt.isDir(p.Dir) {
err = fmt.Errorf("%q is not a directory", p.Dir)
}
return p, err
} }
// NoGoError is the error used by Import to describe a directory // NoGoError is the error used by Import to describe a directory
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package build package build
import ( import (
"fmt"
"internal/testenv" "internal/testenv"
"io" "io"
"os" "os"
...@@ -346,13 +345,3 @@ func TestImportVendorParentFailure(t *testing.T) { ...@@ -346,13 +345,3 @@ func TestImportVendorParentFailure(t *testing.T) {
t.Fatalf("error on failed import does not mention GOROOT/src/vendor directory:\n%s", e) t.Fatalf("error on failed import does not mention GOROOT/src/vendor directory:\n%s", e)
} }
} }
// Issue 3248
func TestBogusDirectory(t *testing.T) {
const dir = "/foo/bar/baz/gopher"
_, err := ImportDir(dir, FindOnly)
want := fmt.Sprintf("%q is not a directory", filepath.FromSlash(dir))
if err == nil || err.Error() != want {
t.Errorf("got error %q, want %q", err, want)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment