test/integration: do not depend on real packages in testing
Tests involving vendoring assumed that the source code of
github.com/rogpeppe/godef and github.com/ramya-rao-a/go-outline
is already checked out under GOPATH or toolsGopath.
Since we install tools in modules mode, that is no longer true.
This CL removes the assumption but adds a test fixture 'vendoring'
that contains a vendor directory.
Update golang/vscode-go#6
Change-Id: Id0e07ee3bd6a689c73652b306e7f6b3ed705bf72
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/244771
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/test/fixtures/vendoring/main.go b/test/fixtures/vendoring/main.go
new file mode 100644
index 0000000..85b606a
--- /dev/null
+++ b/test/fixtures/vendoring/main.go
@@ -0,0 +1,11 @@
+package main
+
+import (
+ "fmt"
+
+ "example.com/vendorpls"
+)
+
+func main() {
+ fmt.Prinln(vendorpls.F())
+}
diff --git a/test/fixtures/vendoring/vendor/example.com/vendorpls/lib.go b/test/fixtures/vendoring/vendor/example.com/vendorpls/lib.go
new file mode 100644
index 0000000..2993afc
--- /dev/null
+++ b/test/fixtures/vendoring/vendor/example.com/vendorpls/lib.go
@@ -0,0 +1,9 @@
+package vendorpls
+
+func F() string {
+ return "vendor please"
+}
+
+func SomethingStrange() {
+
+}
\ No newline at end of file
diff --git a/test/integration/extension.test.ts b/test/integration/extension.test.ts
index 269e6e8..93063f7 100644
--- a/test/integration/extension.test.ts
+++ b/test/integration/extension.test.ts
@@ -634,21 +634,13 @@
});
test('Replace vendor packages with relative path', async () => {
- // This test needs a go project that has vendor folder and vendor packages
- // Since the Go extension takes a dependency on the godef tool at github.com/rogpeppe/godef
- // which has vendor packages, we are using it here to test the "replace vendor packages with relative path" feature.
- // If the extension ever stops depending on godef tool or if godef ever stops having vendor packages, then this test
- // will fail and will have to be replaced with any other go project with vendor packages
-
const vendorSupport = await isVendorSupported();
- const filePath = path.join(toolsGopath, 'src', 'github.com', 'rogpeppe', 'godef', 'go', 'ast', 'ast.go');
+ const filePath = path.join(fixturePath, 'vendoring', 'main.go');
const workDir = path.dirname(filePath);
const vendorPkgsFullPath = [
- 'github.com/rogpeppe/godef/vendor/9fans.net/go/acme',
- 'github.com/rogpeppe/godef/vendor/9fans.net/go/plan9',
- 'github.com/rogpeppe/godef/vendor/9fans.net/go/plan9/client'
+ 'test/testfixture/vendoring/vendor/example.com/vendorpls',
];
- const vendorPkgsRelativePath = ['9fans.net/go/acme', '9fans.net/go/plan9', '9fans.net/go/plan9/client'];
+ const vendorPkgsRelativePath = ['example.com/vendorpls'];
const gopkgsPromise = getAllPackages(workDir).then((pkgMap) => {
const pkgs = Array.from(pkgMap.keys()).filter((p) => {
@@ -702,18 +694,10 @@
});
test('Vendor pkgs from other projects should not be allowed to import', async () => {
- // This test needs a go project that has vendor folder and vendor packages
- // Since the Go extension takes a dependency on the godef tool at github.com/rogpeppe/godef
- // which has vendor packages, we are using it here to test the "replace vendor packages with relative path" feature.
- // If the extension ever stops depending on godef tool or if godef ever stops having vendor packages, then this test
- // will fail and will have to be replaced with any other go project with vendor packages
-
const vendorSupport = await isVendorSupported();
- const filePath = path.join(toolsGopath, 'src', 'github.com', 'ramya-rao-a', 'go-outline', 'main.go');
+ const filePath = path.join(fixturePath, 'baseTest', 'test.go');
const vendorPkgs = [
- 'github.com/rogpeppe/godef/vendor/9fans.net/go/acme',
- 'github.com/rogpeppe/godef/vendor/9fans.net/go/plan9',
- 'github.com/rogpeppe/godef/vendor/9fans.net/go/plan9/client'
+ 'test/testfixture/vendoring/vendor/example.com/vendorpls',
];
const gopkgsPromise = new Promise<void>((resolve, reject) => {
@@ -757,13 +741,7 @@
});
test('Workspace Symbols', () => {
- // This test needs a go project that has vendor folder and vendor packages
- // Since the Go extension takes a dependency on the godef tool at github.com/rogpeppe/godef
- // which has vendor packages, we are using it here to test the "replace vendor packages with relative path" feature.
- // If the extension ever stops depending on godef tool or if godef ever stops having vendor packages, then this test
- // will fail and will have to be replaced with any other go project with vendor packages
-
- const workspacePath = path.join(toolsGopath, 'src', 'github.com', 'rogpeppe', 'godef');
+ const workspacePath = path.join(fixturePath, 'vendoring');
const configWithoutIgnoringFolders = Object.create(vscode.workspace.getConfiguration('go'), {
gotoSymbol: {
value: {
@@ -795,16 +773,16 @@
const withoutIgnoringFolders = getWorkspaceSymbols(
workspacePath,
- 'WinInfo',
+ 'SomethingStr',
dummyCancellationSource.token,
configWithoutIgnoringFolders
).then((results) => {
- assert.equal(results[0].name, 'WinInfo');
- assert.equal(results[0].path, path.join(workspacePath, 'vendor/9fans.net/go/acme/acme.go'));
+ assert.equal(results[0].name, 'SomethingStrange');
+ assert.equal(results[0].path, path.join(workspacePath, 'vendor/example.com/vendorpls/lib.go'));
});
const withIgnoringFolders = getWorkspaceSymbols(
workspacePath,
- 'WinInfo',
+ 'SomethingStr',
dummyCancellationSource.token,
configWithIgnoringFolders
).then((results) => {