mirror of
https://github.com/golang/go.git
synced 2026-02-06 18:00:01 +00:00
go/build: don't invoke go command when setting UseAllFiles
Fixes #68556 Change-Id: I36b08577243a6b3a13b3adef116411d73a2d3428 Reviewed-on: https://go-review.googlesource.com/c/go/+/700337 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
f2e7fa6d31
commit
9972154461
2 changed files with 12 additions and 1 deletions
|
|
@ -1139,7 +1139,7 @@ func (ctxt *Context) importGo(p *Package, path, srcDir string, mode ImportMode)
|
|||
// we must not being doing special things like AllowBinary or IgnoreVendor,
|
||||
// and all the file system callbacks must be nil (we're meant to use the local file system).
|
||||
if mode&AllowBinary != 0 || mode&IgnoreVendor != 0 ||
|
||||
ctxt.JoinPath != nil || ctxt.SplitPathList != nil || ctxt.IsAbsPath != nil || ctxt.IsDir != nil || ctxt.HasSubdir != nil || ctxt.ReadDir != nil || ctxt.OpenFile != nil || !slices.Equal(ctxt.ToolTags, defaultToolTags) || !slices.Equal(ctxt.ReleaseTags, defaultReleaseTags) {
|
||||
ctxt.JoinPath != nil || ctxt.SplitPathList != nil || ctxt.IsAbsPath != nil || ctxt.IsDir != nil || ctxt.HasSubdir != nil || ctxt.ReadDir != nil || ctxt.OpenFile != nil || !slices.Equal(ctxt.ToolTags, defaultToolTags) || !slices.Equal(ctxt.ReleaseTags, defaultReleaseTags) || ctxt.UseAllFiles {
|
||||
return errNoModules
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -828,3 +828,14 @@ func TestDirectives(t *testing.T) {
|
|||
check("XTestDirectives", p.XTestDirectives,
|
||||
`[{"//go:xtest1" "testdata/directives/c_test.go:1:1"} {"//go:xtest2" "testdata/directives/d_test.go:1:1"} {"//go:xtest3" "testdata/directives/d_test.go:2:1"}]`)
|
||||
}
|
||||
|
||||
// TestContextImportGoWithUseAllFiles ensures that when Context.UseAllFiles is set,
|
||||
// that the Go command is not invoked
|
||||
func TestContextImportGoWithUseAllFiles(t *testing.T) {
|
||||
ctxt := &Context{UseAllFiles: true}
|
||||
p := &Package{}
|
||||
got := ctxt.importGo(p, "some/package", ".", 0)
|
||||
if got != errNoModules {
|
||||
t.Fatalf("Error mismatch:\n\tGot: %v\n\tWant: %v", got, errNoModules)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue