Skip to content

Commit 16a0550

Browse files
committed
Fix "Run Tests Multiple Times" on Linux
When we process the `...args` passed to the 'run multiple' commands we're only checking if the argument is an object before deeming it a TestItem. On linux VS Code is passing an event object like `{ preserveFocus: true }`, which is being treated as a TestItem and causing the command to error out.
1 parent 6c55d30 commit 16a0550

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/commands/testMultipleTimes.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ export async function runTestMultipleTimes(
5151
}
5252
const token = new vscode.CancellationTokenSource();
5353
const testExplorer = currentFolder.testExplorer;
54+
const request = new vscode.TestRunRequest(tests);
5455
const runner = new TestRunner(
5556
kind,
56-
new vscode.TestRunRequest(tests),
57+
request,
5758
currentFolder,
5859
testExplorer.controller,
5960
token.token
@@ -127,7 +128,9 @@ export function extractTestItemsAndCount(
127128
result.count = arg ?? undefined;
128129
return result;
129130
} else if (typeof arg === "object") {
130-
result.testItems.push(arg);
131+
if (arg.hasOwnProperty("id") && arg.hasOwnProperty("uri")) {
132+
result.testItems.push(arg);
133+
}
131134
return result;
132135
} else {
133136
throw new Error(`Unexpected argument ${arg} at index ${index}`);

test/integration-tests/testexplorer/TestExplorerIntegration.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ suite("Test Explorer Suite", function () {
614614
await vscode.commands.executeCommand(
615615
Commands.RUN_TESTS_MULTIPLE_TIMES,
616616
testItems[0],
617+
{ preserveFocus: true }, // a trailing argument included on Linux
617618
numIterations
618619
);
619620

0 commit comments

Comments
 (0)