Skip to content

Commit a6f0488

Browse files
committed
fix: in a test run, errors that occur are first selected in the test case and not in the keyword definition
1 parent 47c1165 commit a6f0488

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

vscode-client/testcontrollermanager.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
22
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
33
/* eslint-disable @typescript-eslint/no-unsafe-argument */
4-
import { red, yellow } from "ansi-colors";
4+
import { red, yellow, blue } from "ansi-colors";
55
import * as vscode from "vscode";
66
import { DebugManager } from "./debugmanager";
77

@@ -281,11 +281,11 @@ export class TestControllerManager {
281281
break;
282282
}
283283
case "robotLog": {
284-
this.OnRobotLogMessageEvent(event.session.configuration.runId, event.body as RobotLogMessageEvent);
284+
this.OnRobotLogMessageEvent(event.session.configuration.runId, event.body as RobotLogMessageEvent, false);
285285
break;
286286
}
287287
case "robotMessage": {
288-
this.OnRobotLogMessageEvent(event.session.configuration.runId, event.body as RobotLogMessageEvent);
288+
this.OnRobotLogMessageEvent(event.session.configuration.runId, event.body as RobotLogMessageEvent, true);
289289
break;
290290
}
291291
}
@@ -1020,7 +1020,7 @@ export class TestControllerManager {
10201020

10211021
if (included.size === 0) return;
10221022

1023-
const run = this.testController.createTestRun(request);
1023+
const run = this.testController.createTestRun(request, undefined);
10241024
let run_started = false;
10251025

10261026
token.onCancellationRequested(async (_) => {
@@ -1225,7 +1225,7 @@ export class TestControllerManager {
12251225
if (run !== undefined) {
12261226
const item = this.findTestItemById(event.id);
12271227
if (item) {
1228-
const message = new vscode.TestMessage(event.attributes?.message ?? "");
1228+
const message = new vscode.TestMessage((event.attributes?.message ?? "").replaceAll("\n", "\r\n"));
12291229

12301230
if (event.attributes.source) {
12311231
message.location = new vscode.Location(
@@ -1268,28 +1268,11 @@ export class TestControllerManager {
12681268
{
12691269
const messages: vscode.TestMessage[] = [];
12701270

1271-
if (event.failedKeywords) {
1272-
for (const keyword of event.failedKeywords) {
1273-
const message = new vscode.TestMessage(keyword.message ?? "");
1274-
1275-
if (keyword.source) {
1276-
message.location = new vscode.Location(
1277-
vscode.Uri.file(keyword.source),
1278-
new vscode.Range(
1279-
new vscode.Position((keyword.lineno ?? 1) - 1, 0),
1280-
new vscode.Position(keyword.lineno ?? 1, 0),
1281-
),
1282-
);
1283-
}
1284-
1285-
messages.push(message);
1286-
}
1287-
}
12881271
if (
12891272
!event.attributes?.message ||
12901273
!event.failedKeywords?.find((v) => v.message === event.attributes?.message)
12911274
) {
1292-
const message = new vscode.TestMessage(event.attributes.message ?? "");
1275+
const message = new vscode.TestMessage((event.attributes.message ?? "").replaceAll("\n", "\r\n"));
12931276

12941277
if (event.attributes.source) {
12951278
message.location = new vscode.Location(
@@ -1303,6 +1286,24 @@ export class TestControllerManager {
13031286
messages.push(message);
13041287
}
13051288

1289+
if (event.failedKeywords) {
1290+
for (const keyword of event.failedKeywords.reverse()) {
1291+
const message = new vscode.TestMessage((keyword.message ?? "").replaceAll("\n", "\r\n"));
1292+
1293+
if (keyword.source) {
1294+
message.location = new vscode.Location(
1295+
vscode.Uri.file(keyword.source),
1296+
new vscode.Range(
1297+
new vscode.Position((keyword.lineno ?? 1) - 1, 0),
1298+
new vscode.Position(keyword.lineno ?? 1, 0),
1299+
),
1300+
);
1301+
}
1302+
1303+
messages.push(message);
1304+
}
1305+
}
1306+
13061307
if (!item?.canResolveChildren) {
13071308
if (event.attributes.status === "FAIL") {
13081309
run.failed(item, messages, event.attributes.elapsedtime);
@@ -1317,7 +1318,7 @@ export class TestControllerManager {
13171318
}
13181319
}
13191320

1320-
private OnRobotLogMessageEvent(runId: string | undefined, event: RobotLogMessageEvent): void {
1321+
private OnRobotLogMessageEvent(runId: string | undefined, event: RobotLogMessageEvent, isMessage: boolean): void {
13211322
if (runId === undefined) return;
13221323

13231324
const run = this.testRuns.get(runId);
@@ -1348,8 +1349,10 @@ export class TestControllerManager {
13481349
break;
13491350
}
13501351

1352+
const messageStyle = isMessage ? blue : (s: string) => s;
1353+
13511354
run.appendOutput(
1352-
`[ ${style(event.level)} ] ${event.message.replaceAll("\n", "\r\n")}` + "\r\n",
1355+
`[ ${style(event.level)} ] ${messageStyle(event.message.replaceAll("\n", "\r\n"))}` + "\r\n",
13531356
location,
13541357
event.itemId !== undefined ? this.findTestItemById(event.itemId) : undefined,
13551358
);

0 commit comments

Comments
 (0)