Commit 3585f215 authored by Russ Cox's avatar Russ Cox

cmd/go: fix error for go run with files in different directories

Fixes #9853.

Change-Id: Ic4803aa499ca20215085a87bad649014984d84c8
Reviewed-on: https://go-review.googlesource.com/12149Reviewed-by: default avatarRob Pike <r@golang.org>
parent 687925ff
......@@ -712,6 +712,9 @@ func goFilesPackage(gofiles []string) *Package {
fatalf("%s is a directory, should be a Go file", file)
}
dir1, _ := filepath.Split(file)
if dir1 == "" {
dir1 = "."
}
if dir == "" {
dir = dir1
} else if dir != dir1 {
......
......@@ -2055,3 +2055,13 @@ func TestIssue10193(t *testing.T) {
tg.runFail("get", "code.google.com/p/rsc-svn")
tg.grepStderr("is shutting down", "missed warning about code.google.com")
}
func TestGoRunDirs(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.cd("testdata/rundir")
tg.runFail("run", "x.go", "sub/sub.go")
tg.grepStderr("named files must all be in one directory; have . and sub/", "wrong output")
tg.runFail("run", "sub/sub.go", "x.go")
tg.grepStderr("named files must all be in one directory; have sub/ and .", "wrong output")
}
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