Skip to content

Commit f21bff8

Browse files
committed
add test frameworks traits to VSCode Copilot Chat
1 parent 72e28d9 commit f21bff8

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

Extension/src/LanguageServer/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ export interface ChatContextResult {
553553
compiler: string;
554554
targetPlatform: string;
555555
targetArchitecture: string;
556+
testFrameworks: string[];
556557
}
557558

558559
export interface FileContextResult {

Extension/src/LanguageServer/lmTool.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
235235
contextString += `The project targets the ${chatContext.targetArchitecture} architecture. `;
236236
telemetryProperties["targetArchitecture"] = chatContext.targetArchitecture;
237237
}
238-
238+
if (chatContext.testFrameworks) {
239+
contextString += `The project uses the following C++ test frameworks: ${chatContext.testFrameworks.join(', ')} . `;
240+
telemetryProperties["testFrameworks"] = chatContext.testFrameworks.join(',');
241+
}
239242
return contextString;
240243
}
241244
catch {

Extension/test/scenarios/SingleRootProject/tests/lmTool.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,17 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
130130
});
131131

132132
const arrangeChatContextFromCppTools = ({ chatContextFromCppTools, isCpp, isHeaderFile }:
133-
{ chatContextFromCppTools?: ChatContextResult; isCpp?: boolean; isHeaderFile?: boolean } =
134-
{ chatContextFromCppTools: undefined, isCpp: undefined, isHeaderFile: false }
133+
{ chatContextFromCppTools?: ChatContextResult; isCpp?: boolean; isHeaderFile?: boolean } =
134+
{ chatContextFromCppTools: undefined, isCpp: undefined, isHeaderFile: false }
135135
) => {
136136
activeClientStub.getChatContext.resolves(chatContextFromCppTools);
137137
sinon.stub(util, 'isCpp').returns(isCpp ?? true);
138138
sinon.stub(util, 'isHeaderFile').returns(isHeaderFile ?? false);
139139
};
140140

141141
const arrangeProjectContextFromCppTools = ({ projectContextFromCppTools, isCpp, isHeaderFile }:
142-
{ projectContextFromCppTools?: ProjectContextResult; isCpp?: boolean; isHeaderFile?: boolean } =
143-
{ projectContextFromCppTools: undefined, isCpp: undefined, isHeaderFile: false }
142+
{ projectContextFromCppTools?: ProjectContextResult; isCpp?: boolean; isHeaderFile?: boolean } =
143+
{ projectContextFromCppTools: undefined, isCpp: undefined, isHeaderFile: false }
144144
) => {
145145
activeClientStub.getProjectContext.resolves(projectContextFromCppTools);
146146
sinon.stub(util, 'isCpp').returns(isCpp ?? true);
@@ -154,7 +154,8 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
154154
standardVersion: 'c++20',
155155
compiler: 'msvc',
156156
targetPlatform: 'windows',
157-
targetArchitecture: 'x64'
157+
targetArchitecture: 'x64',
158+
testFrameworks: ['gtest', 'catch2']
158159
}
159160
});
160161

@@ -166,12 +167,13 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
166167
"compiler": 'MSVC',
167168
"standardVersion": 'C++20',
168169
"targetPlatform": 'Windows',
169-
"targetArchitecture": 'x64'
170+
"targetArchitecture": 'x64',
171+
'testFrameworks': 'gtest,catch2'
170172
})));
171173
ok(result, 'result should not be undefined');
172174
const text = result.content[0] as vscode.LanguageModelTextPart;
173175
ok(text, 'result should contain a text part');
174-
ok(text.value === 'The user is working on a C++ project. The project uses language version C++20. The project compiles using the MSVC compiler. The project targets the Windows platform. The project targets the x64 architecture. ');
176+
ok(text.value === 'The user is working on a C++ project. The project uses language version C++20. The project compiles using the MSVC compiler. The project targets the Windows platform. The project targets the x64 architecture. The project uses the following C++ test frameworks: gtest, catch2 .');
175177
});
176178

177179
const testGetProjectContext = async ({

0 commit comments

Comments
 (0)