Commit 52a9210a authored by Michael Matloob's avatar Michael Matloob

cmd/go: convert import comment tests to script framework

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I30230ca3b4d8b037ea861db952b89e706ed8706d
Reviewed-on: https://go-review.googlesource.com/c/go/+/213425
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
parent 7340d15c
...@@ -1041,37 +1041,6 @@ func TestInternalCache(t *testing.T) { ...@@ -1041,37 +1041,6 @@ func TestInternalCache(t *testing.T) {
tg.grepStderr("internal", "did not fail to build p") tg.grepStderr("internal", "did not fail to build p")
} }
func TestImportCommandMatch(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata/importcom"))
tg.run("build", "./testdata/importcom/works.go")
}
func TestImportCommentMismatch(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata/importcom"))
tg.runFail("build", "./testdata/importcom/wrongplace.go")
tg.grepStderr(`wrongplace expects import "my/x"`, "go build did not mention incorrect import")
}
func TestImportCommentSyntaxError(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata/importcom"))
tg.runFail("build", "./testdata/importcom/bad.go")
tg.grepStderr("cannot parse import comment", "go build did not mention syntax error")
}
func TestImportCommentConflict(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata/importcom"))
tg.runFail("build", "./testdata/importcom/conflict.go")
tg.grepStderr("found import comments", "go build did not mention comment conflict")
}
// cmd/go: custom import path checking should not apply to Go packages without import comment. // cmd/go: custom import path checking should not apply to Go packages without import comment.
func TestIssue10952(t *testing.T) { func TestIssue10952(t *testing.T) {
testenv.MustHaveExternalNetwork(t) testenv.MustHaveExternalNetwork(t)
......
package x // important! not an import comment
// TODO: add a go.mod file and test with GO111MODULE explicitly on and off.
// We only report the 'expects import' error when modules are disabled.
// Do we report comment parse errors or conflicts in module mode? We shouldn't.
# Import comment matches
go build -n works.go
# Import comment mismatch
! go build -n wrongplace.go
stderr 'wrongplace expects import "my/x"'
# Import comment syntax error
! go build -n bad.go
stderr 'cannot parse import comment'
# Import comment conflict
! go build -n conflict.go
stderr 'found import comments'
-- bad.go --
package p
import "bad"
-- conflict.go --
package p
import "conflict"
-- works.go --
package p
import _ "works/x"
-- wrongplace.go --
package p
import "wrongplace"
-- bad/bad.go --
package bad // import
-- conflict/a.go --
package conflict // import "a"
-- conflict/b.go --
package conflict /* import "b" */
-- works/x/x.go --
package x // import "works/x"
-- works/x/x1.go --
package x // important! not an import comment
-- wrongplace/x.go --
package x // import "my/x"
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