This commit is contained in:
andreeis 2020-04-17 13:20:25 -07:00
Родитель 376c34fdd7
Коммит 04e4324285
3 изменённых файлов: 19 добавлений и 2 удалений

Просмотреть файл

@ -400,6 +400,16 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
this._statusMessage.set(localize('ready.status', 'Ready'));
}
async isNinjaInstalled() : Promise<boolean> {
const drv = await this._cmakeDriver;
if (drv) {
return await drv.testHaveCommand('ninja') || drv.testHaveCommand('ninja-build');
}
return false;
}
async setKit(kit: Kit|null) {
this._activeKit = kit;
if (kit) {

Просмотреть файл

@ -526,7 +526,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
}
private async testHaveCommand(program: string, args: string[] = ['--version']): Promise<boolean> {
public async testHaveCommand(program: string, args: string[] = ['--version']): Promise<boolean> {
const child = this.executeCommand(program, args, undefined, {silent: true});
try {
const result = await child.result;

Просмотреть файл

@ -319,8 +319,15 @@ KITS_BY_PLATFORM[workername].forEach(buildSystem => {
this.timeout(BUILD_TIMEOUT);
context.testEnv.config.updatePartial({preferredGenerators: []});
expect(await context.cmt.build()).to.eql(0);
const result = await context.testEnv.result.getResultAsJson();
expect(result['cmake-generator']).to.match(buildSystem.expectedDefaultGenerator);
// "Ninja" and "Unix Makefiles" are always the default preferred generators
// if no other overriding property is set.
// The extension verifies for each if they are present (installed)
// and starts with "Ninja".
const isNinjaInstalled = await context.cmt.isNinjaInstalled();
expect(result['cmake-generator']).to.eql(isNinjaInstalled ? "Ninja" : "Unix Makefiles");
expect(context.testEnv.errorMessagesQueue.length)
.to.eql(0, 'Wrong message ' + context.testEnv.errorMessagesQueue[0]);
});