Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Bug Fixes:
- Fix issue with switching to presets during Quick Start. [#4409](https://github.com/microsoft/vscode-cmake-tools/issues/4409)
- Fix bug that shows empty lines in Pinned Commands view. [#4406](https://github.com/microsoft/vscode-cmake-tools/issues/4406)
- Fix Compiler Warnings not shown in Problems Window [#4567]https://github.com/microsoft/vscode-cmake-tools/issues/4567
- Fix bug in which clicking "Run Test" for filtered tests executed all tests instead [#4501](https://github.com/microsoft/vscode-cmake-tools/pull/4501) [@hippo91](https://github.com/hippo91)

## 1.20.53

Expand Down
25 changes: 23 additions & 2 deletions src/ctest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1077,8 +1077,29 @@ export class CTestDriver implements vscode.Disposable {
return;
}

const requestedTests = request.include || this.testItemCollectionToArray(testExplorer.items);
const tests = this.uniqueTests(requestedTests);
// Helper to collect all leaf tests from a list of test items (suites or tests)
function flattenTests(items: readonly vscode.TestItem[]): vscode.TestItem[] {
const result: vscode.TestItem[] = [];
function collect(item: vscode.TestItem) {
if (item.children.size === 0) {
result.push(item);
} else {
item.children.forEach(collect);
}
}
items.forEach(collect);
return result;
}

// Expand suites in include and exclude to all their leaf tests
const requestedTests = request.include
? flattenTests(request.include)
: this.testItemCollectionToArray(testExplorer.items).flatMap(item => flattenTests([item]));
const excludeTests = request.exclude ? flattenTests(request.exclude) : [];
const excludeSet = new Set(excludeTests.map(item => item.id));

const filteredRequestedTests = requestedTests.filter(test => !excludeSet.has(test.id));
const tests = this.uniqueTests(filteredRequestedTests);

if (!await this.checkTestPreset(tests)) {
return;
Expand Down