| 1 | // Copyright 2018 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package packagestest_testscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest_test`/ |
| 6 | |
| 7 | import ( |
| 8 | "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/" |
| 9 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 10 | |
| 11 | "golang.org/x/tools/internal/packagestestscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest`/" |
| 12 | ) |
| 13 | |
| 14 | func TestGOPATHExportscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest_test`/TestGOPATHExport().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 15 | exported := packagestestscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest`/.Exportscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest`/Export().(t, packagestestscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest`/.GOPATHscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest`/GOPATH., testdatascip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest_test`/testdata.) |
| 16 | defer exported.Cleanupscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest`/Exported#Cleanup().() |
| 17 | // Check that the cfg contains all the right bits |
| 18 | var expectDir = filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(exported.Tempscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest`/Exported#Temp().(), "fake1", "src") |
| 19 | if exported.Configscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest`/Exported#Config..Dirscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/packages`/Config#Dir. != expectDir { |
| 20 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("Got working directory %v expected %v", exported.Configscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest`/Exported#Config..Dirscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/packages`/Config#Dir., expectDir) |
| 21 | } |
| 22 | checkFilesscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest_test`/checkFiles().(t, exported, []fileTestscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest_test`/fileTest#{ |
| 23 | {"golang.org/fake1", "a.go", "fake1/src/golang.org/fake1/a.go", checkLinkscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest_test`/checkLink().("testdata/a.go")}, |
| 24 | {"golang.org/fake1", "b.go", "fake1/src/golang.org/fake1/b.go", checkContentscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest_test`/checkContent().("package fake1")}, |
| 25 | {"golang.org/fake2", "other/a.go", "fake2/src/golang.org/fake2/other/a.go", checkContentscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest_test`/checkContent().("package fake2")}, |
| 26 | {"golang.org/fake2/v2", "other/a.go", "fake2_v2/src/golang.org/fake2/v2/other/a.go", checkContentscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/packagestest_test`/checkContent().("package fake2")}, |
| 27 | }) |
| 28 | } |