mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 18:19:12 +01:00
testing: default failure message to the test location if not already set
Fixes #131898
This commit is contained in:
@@ -14,7 +14,7 @@ import { MarshalledId } from 'vs/base/common/marshalling';
|
||||
import { deepFreeze } from 'vs/base/common/objects';
|
||||
import { isDefined } from 'vs/base/common/types';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { ExtHostTestingShape, MainContext, MainThreadTestingShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostTestingShape, ILocationDto, MainContext, MainThreadTestingShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { InvalidTestItemError, TestItemImpl, TestItemRootImpl } from 'vs/workbench/api/common/extHostTestingPrivateApi';
|
||||
@@ -340,6 +340,21 @@ class TestRunTracker extends Disposable {
|
||||
fn(test, ...args);
|
||||
};
|
||||
|
||||
const appendMessages = (test: vscode.TestItem, messages: vscode.TestMessage | readonly vscode.TestMessage[]) => {
|
||||
const converted = messages instanceof Array
|
||||
? messages.map(Convert.TestMessage.from)
|
||||
: [Convert.TestMessage.from(messages)];
|
||||
|
||||
if (test.uri && test.range) {
|
||||
const defaultLocation: ILocationDto = { range: Convert.Range.from(test.range), uri: test.uri };
|
||||
for (const message of converted) {
|
||||
message.location = message.location || defaultLocation;
|
||||
}
|
||||
}
|
||||
|
||||
this.proxy.$appendTestMessagesInRun(runId, taskId, TestId.fromExtHostTestItem(test, ctrlId).toString(), converted);
|
||||
};
|
||||
|
||||
let ended = false;
|
||||
const run: vscode.TestRun = {
|
||||
isPersisted: this.dto.isPersisted,
|
||||
@@ -362,13 +377,11 @@ class TestRunTracker extends Disposable {
|
||||
this.proxy.$updateTestStateInRun(runId, taskId, TestId.fromExtHostTestItem(test, ctrlId).toString(), TestResultState.Running);
|
||||
}),
|
||||
errored: guardTestMutation((test, messages, duration) => {
|
||||
this.proxy.$appendTestMessagesInRun(runId, taskId, TestId.fromExtHostTestItem(test, ctrlId).toString(),
|
||||
messages instanceof Array ? messages.map(Convert.TestMessage.from) : [Convert.TestMessage.from(messages)]);
|
||||
appendMessages(test, messages);
|
||||
this.proxy.$updateTestStateInRun(runId, taskId, TestId.fromExtHostTestItem(test, ctrlId).toString(), TestResultState.Errored, duration);
|
||||
}),
|
||||
failed: guardTestMutation((test, messages, duration) => {
|
||||
this.proxy.$appendTestMessagesInRun(runId, taskId, TestId.fromExtHostTestItem(test, ctrlId).toString(),
|
||||
messages instanceof Array ? messages.map(Convert.TestMessage.from) : [Convert.TestMessage.from(messages)]);
|
||||
appendMessages(test, messages);
|
||||
this.proxy.$updateTestStateInRun(runId, taskId, TestId.fromExtHostTestItem(test, ctrlId).toString(), TestResultState.Failed, duration);
|
||||
}),
|
||||
passed: guardTestMutation((test, duration) => {
|
||||
|
||||
Reference in New Issue
Block a user