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

Sends test result messages over to extension host. Fixes regression. #173044

Merged
merged 1 commit into from Feb 1, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vs/workbench/api/browser/mainThreadTesting.ts
Expand Up @@ -45,7 +45,7 @@ export class MainThreadTesting extends Disposable implements MainThreadTestingSh

this._register(resultService.onResultsChanged(evt => {
const results = 'completed' in evt ? evt.completed : ('inserted' in evt ? evt.inserted : undefined);
const serialized = results?.toJSON();
const serialized = results?.toJSONWithMessages();
if (serialized) {
this.proxy.$publishTestResults([serialized]);
}
Expand Down
25 changes: 25 additions & 0 deletions src/vs/workbench/contrib/testing/common/testResult.ts
Expand Up @@ -86,6 +86,11 @@ export interface ITestResult {
* in the workspace.
*/
toJSON(): ISerializedTestResults | undefined;

/**
* Serializes the test result, includes messages. Used to send the test states to the extension host.
*/
toJSONWithMessages(): ISerializedTestResults | undefined;
}

export const resultItemParents = function* (results: ITestResult, item: TestResultItem) {
Expand Down Expand Up @@ -501,6 +506,10 @@ export class LiveTestResult implements ITestResult {
return this.completedAt && this.persist ? this.doSerialize.value : undefined;
}

public toJSONWithMessages(): ISerializedTestResults | undefined {
return this.completedAt && this.persist ? this.doSerializeWithMessages.value : undefined;
}

/**
* Updates all tests in the collection to the given state.
*/
Expand Down Expand Up @@ -585,6 +594,15 @@ export class LiveTestResult implements ITestResult {
request: this.request,
items: [...this.testById.values()].map(TestResultItem.serializeWithoutMessages),
}));

private readonly doSerializeWithMessages = new Lazy((): ISerializedTestResults => ({
id: this.id,
completedAt: this.completedAt!,
tasks: this.tasks.map(t => ({ id: t.id, name: t.name })),
name: this.name,
request: this.request,
items: [...this.testById.values()].map(TestResultItem.serialize),
}));
}

/**
Expand Down Expand Up @@ -682,4 +700,11 @@ export class HydratedTestResult implements ITestResult {
public toJSON(): ISerializedTestResults | undefined {
return this.persist ? this.serialized : undefined;
}

/**
* @inheritdoc
*/
public toJSONWithMessages(): ISerializedTestResults | undefined {
return this.toJSON();
}
}