I ran into a problem when trying to debug a test on a remote host using vscode. I discussed the details of the issue in the code section, Problem debugging test on remote host.
The issue revolves around the fact that the vs-cmake-tool extension to vscode expects the file containing the symbol table to be defined in the first element of the COMMAND field. I had to make the first command be a script to set up the remote host to run the executable. When I try to debug the test, it fails . It looks at the script to get the symbol table which fails.
In vs-cmake-tool the definition of testProgram happens here in ctests.ts:
private testProgram(testName: string): string {
if (this.tests) {
for (const test of this.tests.tests) {
if (test.name === testName) {
return test.command[0];
}
}
} else if (this.legacyTests) {
for (const test of this.legacyTests) {
if (test.name === testName) {
return test.name;
}
}
}
return '';
It really is the best choice to assign testProgram to command[0] with the information that is available from CMake.
It would be nice to add a new field to add_test that allows it to specifically provide the program to use to gather the symbol table.
I would like to add a PROGRAM and ARGS field to add_test(). This would allow vs-cmake-tools to define it’s testProgram as PROGRAM if it exists. Otherwise, go ahead and use command[0]. I have no experience with typescript. I believe the vs-cmake-tools code would look like this:
private testProgram(testName: string): string {
if (this.tests) {
for (const test of this.tests.tests) {
if (test.name === testName) {
const property = test?.properties
.find(prop => prop.name === 'PROGRAM');
if (typeof (property?.value) === 'string') {
return property.value;
}
return test.command[0];
}
}
} else if (this.legacyTests) {
for (const test of this.legacyTests) {
if (test.name === testName) {
return test.name;
}
}
}
return '';
}
We have a similar issue for vs-cmake-tools defintion of testArgs. It has to parse COMMAND and it assumes the args are all the values after the first element of COMMAND. Adding an ARGS field to add_test() allows testArgs to be set independent of COMMAND.
I have made changes to cmAddTestCommand.cxx to provide these extra properties. The changes really have no impact on cmake directly. They just carry these properties along and make them available to tools like vs-cmake-tools that might be able to make use of them. I created tests for these changes as well. All the other 680 tests pass with these changes in place.
I tried to upload a diff between my local branch and the master commit hash 69949719c8b0c419ef435e28c02507cc0a4806f4. But I am too new. So I can’t upload. I’ll spare you pasting it into this topic unless there is interest.
Does adding PROGRAM and ARGS fields to add_test() seem like a reasonable feature to be added?
Thanks
Chris