Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
spebl committed Oct 22, 2024
2 parents 9376135 + 1f7f2f7 commit ba5f149
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"Snippets"
],
"enabledApiProposals": [
"terminalDataWriteEvent",
"lmTools"
"terminalDataWriteEvent"
],
"capabilities": {
"untrustedWorkspaces": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ describe('registerRelatedFilesProvider', () => {
let callbackPromise: Promise<{ entries: vscode.Uri[]; traits?: CopilotTrait[] }> | undefined;
let vscodeExtension: vscode.Extension<unknown>;

const includedFiles = process.platform === 'win32' ?
['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] :
['/system/include/vector', '/system/include/string', '/home/src/my_project/foo.h'];
const rootUri = vscode.Uri.file(process.platform === 'win32' ? 'C:\\src\\my_project' : '/home/src/my_project');
const expectedInclude = process.platform === 'win32' ? 'file:///c%3A/src/my_project/foo.h' : 'file:///home/src/my_project/foo.h';

beforeEach(() => {
proxyquire.noPreserveCache(); // Tells proxyquire to not fetch the module from cache
// Ensures that each test has a freshly loaded instance of moduleUnderTest
Expand Down Expand Up @@ -105,9 +111,9 @@ describe('registerRelatedFilesProvider', () => {
it('should not add #cpp traits when ChatContext isn\'t available.', async () => {
arrange({
vscodeExtension: vscodeExtension,
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
getIncludeFiles: { includedFiles },
chatContext: undefined,
rootUri: vscode.Uri.file('C:\\src\\my_project'),
rootUri,
flags: { copilotcppTraits: true }
});
await moduleUnderTest.registerRelatedFilesProvider();
Expand All @@ -120,22 +126,22 @@ describe('registerRelatedFilesProvider', () => {
ok(callbackPromise, 'callbackPromise should be defined');
ok(result, 'result should be defined');
ok(result.entries.length === 1, 'result.entries should have 1 included file');
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
ok(result.traits === undefined, 'result.traits should be undefined');
});

it('should not add #cpp traits when copilotcppTraits flag is false.', async () => {
arrange({
vscodeExtension: vscodeExtension,
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
getIncludeFiles: { includedFiles },
chatContext: {
language: 'c++',
standardVersion: 'c++20',
compiler: 'msvc',
targetPlatform: 'windows',
targetArchitecture: 'x64'
},
rootUri: vscode.Uri.file('C:\\src\\my_project'),
rootUri,
flags: { copilotcppTraits: false }
});
await moduleUnderTest.registerRelatedFilesProvider();
Expand All @@ -148,22 +154,22 @@ describe('registerRelatedFilesProvider', () => {
ok(callbackPromise, 'callbackPromise should be defined');
ok(result, 'result should be defined');
ok(result.entries.length === 1, 'result.entries should have 1 included file');
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
ok(result.traits === undefined, 'result.traits should be undefined');
});

it('should add #cpp traits when copilotcppTraits flag is true.', async () => {
arrange({
vscodeExtension: vscodeExtension,
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
getIncludeFiles: { includedFiles },
chatContext: {
language: 'c++',
standardVersion: 'c++20',
compiler: 'msvc',
targetPlatform: 'windows',
targetArchitecture: 'x64'
},
rootUri: vscode.Uri.file('C:\\src\\my_project'),
rootUri,
flags: { copilotcppTraits: true }
});
await moduleUnderTest.registerRelatedFilesProvider();
Expand All @@ -177,7 +183,7 @@ describe('registerRelatedFilesProvider', () => {
ok(callbackPromise, 'callbackPromise should be defined');
ok(result, 'result should be defined');
ok(result.entries.length === 1, 'result.entries should have 1 included file');
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
ok(result.traits, 'result.traits should be defined');
ok(result.traits.length === 5, 'result.traits should have 5 traits');
ok(result.traits[0].name === 'language', 'result.traits[0].name should be "language"');
Expand Down Expand Up @@ -206,15 +212,15 @@ describe('registerRelatedFilesProvider', () => {
const excludeTraits = ['compiler', 'targetPlatform'];
arrange({
vscodeExtension: vscodeExtension,
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
getIncludeFiles: { includedFiles },
chatContext: {
language: 'c++',
standardVersion: 'c++20',
compiler: 'msvc',
targetPlatform: 'windows',
targetArchitecture: 'x64'
},
rootUri: vscode.Uri.file('C:\\src\\my_project'),
rootUri,
flags: { copilotcppTraits: true, copilotcppExcludeTraits: excludeTraits }
});
await moduleUnderTest.registerRelatedFilesProvider();
Expand All @@ -228,7 +234,7 @@ describe('registerRelatedFilesProvider', () => {
ok(callbackPromise, 'callbackPromise should be defined');
ok(result, 'result should be defined');
ok(result.entries.length === 1, 'result.entries should have 1 included file');
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
ok(result.traits, 'result.traits should be defined');
ok(result.traits.length === 3, 'result.traits should have 3 traits');
ok(result.traits.filter(trait => excludeTraits.includes(trait.name)).length === 0, 'result.traits should not include excluded traits');
Expand Down

0 comments on commit ba5f149

Please sign in to comment.