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

Support CTest labels #3243

Merged
merged 5 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2574,7 +2574,7 @@
"@types/rimraf": "^3.0.0",
"@types/sinon": "~9.0.10",
"@types/tmp": "^0.2.0",
"@types/vscode": "1.60.0",
"@types/vscode": "1.63.0",
"@types/which": "~2.0.0",
"@types/xml2js": "^0.4.8",
"@types/uuid": "~8.3.3",
Expand Down
32 changes: 25 additions & 7 deletions src/ctest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ interface CTestInfo {
backtrace: number;
command: string[];
name: string;
properties: { name: string; value: string }[];
properties: { name: string; value: string | string[] }[];
xisui-MSFT marked this conversation as resolved.
Show resolved Hide resolved
}[];
version: { major: number; minor: number };
}
Expand Down Expand Up @@ -552,18 +552,36 @@ export class CTestDriver implements vscode.Disposable {
this.tests = JSON.parse(result.stdout) ?? undefined;
if (this.tests && this.tests.kind === 'ctestInfo') {
this.tests.tests.forEach(test => {
let testItem: vscode.TestItem;
if (test.backtrace !== undefined && this.tests!.backtraceGraph.nodes[test.backtrace] !== undefined) {
const testDefFile = this.tests!.backtraceGraph.files[this.tests!.backtraceGraph.nodes[test.backtrace].file];
const testDefLine = this.tests!.backtraceGraph.nodes[test.backtrace].line;
const testItem = initializedTestExplorer.createTestItem(test.name, test.name, vscode.Uri.file(testDefFile));
testItem = initializedTestExplorer.createTestItem(test.name, test.name, vscode.Uri.file(testDefFile));
if (testDefLine !== undefined) {
testItem.range = new vscode.Range(new vscode.Position(testDefLine - 1, 0), new vscode.Position(testDefLine - 1, 0));
}
testExplorerRoot.children.add(testItem);
} else {
const testItem = initializedTestExplorer.createTestItem(test.name, test.name);
testExplorerRoot.children.add(testItem);
testItem = initializedTestExplorer.createTestItem(test.name, test.name);
}

const testTags: vscode.TestTag[] = [];
if (test.properties) {
for (const property of test.properties) {
if (property.name === "LABELS") {
if (util.isString(property.value)) {
testTags.push(new vscode.TestTag(property.value));
} else {
testTags.push(...property.value.map(v => new vscode.TestTag(v)));
}
}
}
}

if (testTags.length !== 0) {
testItem.tags = [...testItem.tags, ...testTags];
}

testExplorerRoot.children.add(testItem);
});
};
}
Expand All @@ -587,7 +605,7 @@ export class CTestDriver implements vscode.Disposable {
/**
* Filters out duplicate tests, i.e., both the parent and child are requested
*/
private uniqueTests(tests: vscode.TestItem[]): vscode.TestItem[] {
private uniqueTests(tests: readonly vscode.TestItem[]): vscode.TestItem[] {
const parents = new Set<string>();
tests.forEach(t => {
if (!t.parent) {
Expand Down Expand Up @@ -902,7 +920,7 @@ export class CTestDriver implements vscode.Disposable {
*/
private ensureTestExplorerInitialized(): vscode.TestController {
if (!testExplorer) {
testExplorer = vscode.tests.createTestController('cmakeToolsCTest', 'CTest');
testExplorer = vscode.tests.createTestController('cmake-tools.CTest', 'CTest');

// Cast to any since this is not supported yet in the API we use.
(testExplorer as any).refreshHandler = () => vscode.commands.executeCommand('cmake.refreshTestsAll');
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@
resolved "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc"
integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==

"@types/vscode@1.60.0":
version "1.60.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.60.0.tgz#9330c317691b4f53441a18b598768faeeb71618a"
integrity sha512-wZt3VTmzYrgZ0l/3QmEbCq4KAJ71K3/hmMQ/nfpv84oH8e81KKwPEoQ5v8dNCxfHFVJ1JabHKmCvqdYOoVm1Ow==
"@types/vscode@1.63.0":
version "1.63.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.63.0.tgz#3bddb5b79a93e8fcdd420bb00f7066658c79c70c"
integrity sha512-iePu1axOi5WSThV6l2TYcciBIpAlMarjBC8H0y8L8ocsZLxh7MttzwFU3pjoItF5fRVGxHS0Hsvje9jO3yJsfw==

"@types/which@~2.0.0":
version "2.0.1"
Expand Down
Loading