Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: allow invalidateTestResults to take an array #183569

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/vs/workbench/api/common/extHostTesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ export class ExtHostTesting implements ExtHostTestingShape {
createTestRun: (request, name, persist = true) => {
return this.runTracker.createTestRun(controllerId, collection, request, name, persist);
},
invalidateTestResults: item => {
invalidateTestResults: items => {
checkProposedApiEnabled(extension, 'testInvalidateResults');
const id = item ? TestId.fromExtHostTestItem(item, controllerId).toString() : controllerId;
return this.proxy.$markTestRetired(id);
for (const item of items instanceof Array ? items : [items]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been doing Array.isArray(arr) for ages. Is items instanceof Array better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iirc Array.isArray(arr) works if the array is coming from a different origin. I generally like instanceof Array since it's simpler and more consistent 🤷

Probably the nice way to do this now would be checking if the object has [Symbol.iterator], but we don't yet take Iterables into any methods in extension host APIs.

const id = item ? TestId.fromExtHostTestItem(item, controllerId).toString() : controllerId;
this.proxy.$markTestRetired(id);
}
},
set resolveHandler(fn) {
collection.resolveHandler = fn;
Expand Down
2 changes: 1 addition & 1 deletion src/vscode-dts/vscode.proposed.testInvalidateResults.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ declare module 'vscode' {
*
* @param item Item to mark as outdated. If undefined, all the controller's items are marked outdated.
*/
invalidateTestResults(item?: TestItem): void;
invalidateTestResults(items?: TestItem | readonly TestItem[]): void;
}
}