Skip to content

Commit

Permalink
add support for multi-file test suite
Browse files Browse the repository at this point in the history
When collecting tests or evaluating whether a symbol is a test for CodeLens, check if testify was imported by any file of the directory (which is the go package).

Not sure whether this is the optimal / recommended way of dealing with this, but here goes.

Fixes #1130

Change-Id: I4e66f0d319604a7300116240c24b60dcdd37bf81
GitHub-Last-Rev: efc72ad
GitHub-Pull-Request: #2314
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/415894
TryBot-Result: kokoro <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
Run-TryBot: Hyang-Ah Hana Kim <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
  • Loading branch information
nirhaas authored and hyangah committed Jul 12, 2022
1 parent 05edb9c commit e63f1ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/goDocumentSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ async function listImports(
]
};
const resp = await languageClient?.sendRequest(ExecuteCommandRequest.type, params);
return resp.Imports;
return resp.PackageImports;
}
3 changes: 3 additions & 0 deletions src/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ export async function getTestFunctions(
return;
}
const children = symbol.children;

// With gopls dymbol provider symbols, the symbols have the imports of all
// the package, so suite tests from all files will be found.
const testify = importsTestify(symbols);
return children.filter(
(sym) =>
Expand Down

0 comments on commit e63f1ad

Please sign in to comment.