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
8 changes: 8 additions & 0 deletions .github/workflows/job-compile-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ jobs:
run: yarn test
working-directory: Extension

# These tests don't require the binary.
# On Linux, it is failing (before the tests actually run) with: Test run terminated with signal SIGSEGV.
# But it works on Linux during the E2E test.
- name: Run SingleRootProject tests
if: ${{ inputs.platform != 'linux' }}
run: yarn test --scenario=SingleRootProject --skipCheckBinaries
working-directory: Extension

# NOTE : We can't run the test that require the native binary files
# yet -- there will be an update soon that allows the tester to
# acquire them on-the-fly
Expand Down
3 changes: 3 additions & 0 deletions Extension/.scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ export async function checkDTS() {
}

export async function checkBinaries() {
if ($switches.includes('--skipCheckBinaries')) {
return false;
}
let failing = false;
failing = !await assertAnyFile(['bin/cpptools.exe', 'bin/cpptools']) && (quiet || warn(`The native binary files are not present. You should either build or install the native binaries\n\n.`)) || failing;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as sinon from 'sinon';
import * as vscode from 'vscode';
import * as util from '../../../../src/common';
import { DefaultClient, GetIncludesResult } from '../../../../src/LanguageServer/client';
import { ClientCollection } from '../../../../src/LanguageServer/clientCollection';
import { CopilotApi, CopilotTrait } from '../../../../src/LanguageServer/copilotProviders';
import * as extension from '../../../../src/LanguageServer/extension';
import * as lmTool from '../../../../src/LanguageServer/lmTool';
Expand All @@ -19,18 +20,19 @@ import * as telemetry from '../../../../src/telemetry';
describe('copilotProviders Tests', () => {
let moduleUnderTest: any;
let mockCopilotApi: sinon.SinonStubbedInstance<CopilotApi>;
let getActiveClientStub: sinon.SinonStub;
let getClientsStub: sinon.SinonStub;
let activeClientStub: sinon.SinonStubbedInstance<DefaultClient>;
let vscodeGetExtensionsStub: sinon.SinonStub;
let callbackPromise: Promise<{ entries: vscode.Uri[]; traits?: CopilotTrait[] }> | undefined;
let vscodeExtension: vscode.Extension<unknown>;
let telemetryStub: sinon.SinonStub;

const includedFiles = process.platform === 'win32' ?
const includedFiles: string[] = 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';
const rootUri: vscode.Uri = vscode.Uri.file(process.platform === 'win32' ? 'C:\\src\\my_project' : '/home/src/my_project');
const expectedInclude: string = process.platform === 'win32' ? 'file:///c%3A/src/my_project/foo.h' : 'file:///home/src/my_project/foo.h';
const sourceFileUri: vscode.Uri = vscode.Uri.file(process.platform === 'win32' ? 'file:///c%3A/src/my_project/foo.cpp' : 'file:///home/src/my_project/foo.cpp');

beforeEach(() => {
proxyquire.noPreserveCache(); // Tells proxyquire to not fetch the module from cache
Expand Down Expand Up @@ -70,7 +72,9 @@ describe('copilotProviders Tests', () => {
};

activeClientStub = sinon.createStubInstance(DefaultClient);
getActiveClientStub = sinon.stub(extension, 'getActiveClient').returns(activeClientStub);
const clientsStub = sinon.createStubInstance(ClientCollection);
getClientsStub = sinon.stub(extension, 'getClients').returns(clientsStub);
clientsStub.getClientFor.returns(activeClientStub);
activeClientStub.getIncludes.resolves({ includedFiles: [] });
telemetryStub = sinon.stub(telemetry, 'logCopilotEvent').returns();
});
Expand All @@ -90,7 +94,7 @@ describe('copilotProviders Tests', () => {
if (_providerId.languageId === 'cpp') {
const tokenSource = new vscode.CancellationTokenSource();
try {
callbackPromise = callback(vscode.Uri.parse('file:///test-extension-path'), { flags: flags ?? {} }, tokenSource.token);
callbackPromise = callback(sourceFileUri, { flags: flags ?? {} }, tokenSource.token);
} finally {
tokenSource.dispose();
}
Expand Down Expand Up @@ -129,7 +133,7 @@ describe('copilotProviders Tests', () => {

ok(vscodeGetExtensionsStub.calledOnce, 'vscode.extensions.getExtension should be called once');
ok(mockCopilotApi.registerRelatedFilesProvider.calledWithMatch(sinon.match({ extensionId: 'test-extension-id', languageId: sinon.match.in(['c', 'cpp', 'cuda-cpp']) })), 'registerRelatedFilesProvider should be called with the correct providerId and languageId');
ok(getActiveClientStub.callCount !== 0, 'getActiveClient should be called');
ok(getClientsStub.callCount !== 0, 'getClients should be called');
ok(callbackPromise, 'callbackPromise should be defined');
ok(result, 'result should be defined');
ok(result.entries.length === 1, 'result.entries should have 1 included file');
Expand Down
Loading