Fix tests and enable Windows CI (#2295)
This commit is contained in:
Родитель
2c181deca4
Коммит
2b91e8517c
|
@ -0,0 +1,33 @@
|
|||
name: CI (Windows)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node.js environment
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14'
|
||||
# Set this option if you want the action to check for the latest available version that satisfies the version spec
|
||||
check-latest: true
|
||||
|
||||
- name: Build the extension and run tests
|
||||
run: pwsh -NonInteractive -NoProfile -NoLogo scripts/ci.ps1
|
||||
|
||||
- name: Upload test logs if tests failed
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v2.2.4
|
||||
with:
|
||||
name: TestLogs
|
||||
path: test/**/log.txt
|
||||
if-no-files-found: warn
|
|
@ -4,7 +4,8 @@ dist/
|
|||
node_modules/
|
||||
out/
|
||||
test/fakebin/
|
||||
test/unit-tests/driver/workspace/test_project/bin/
|
||||
test/**/log.txt
|
||||
test/**/bin
|
||||
vscode-extensions-localization-export/
|
||||
vscode-translations-import/
|
||||
jobs/loc/LCL
|
||||
|
@ -18,6 +19,7 @@ test.txt
|
|||
*.backup
|
||||
*.db*
|
||||
*.vsix
|
||||
**/.vscode/CMakeTools
|
||||
**/nls.*.json
|
||||
**/*.nls.json
|
||||
**/*.nls.*.json
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"HasVs": "true"
|
||||
"TEST_FILTER": ".*"
|
||||
},
|
||||
"preLaunchTask": "Pretest"
|
||||
},
|
||||
|
@ -66,27 +66,11 @@
|
|||
"${workspaceFolder}/out/test/extension-tests/successful-build/test/*"
|
||||
],
|
||||
"preLaunchTask": "Pretest",
|
||||
"windows": {
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"HasVs": "true"
|
||||
}
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"TEST_FILTER": ".*"
|
||||
},
|
||||
"linux": {
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"HasVs": "false"
|
||||
}
|
||||
},
|
||||
"osx": {
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"HasVs": "false"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Launch Extension Tests (single-root-UI)",
|
||||
|
@ -108,27 +92,11 @@
|
|||
"${workspaceFolder}/out/test/extension-tests/single-root-UI/test/*"
|
||||
],
|
||||
"preLaunchTask": "Pretest",
|
||||
"windows": {
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"HasVs": "true"
|
||||
}
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"TEST_FILTER": ".*"
|
||||
},
|
||||
"linux": {
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"HasVs": "false"
|
||||
}
|
||||
},
|
||||
"osx": {
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"HasVs": "false"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Launch Extension Tests (multi-root-UI)",
|
||||
|
@ -150,27 +118,11 @@
|
|||
"${workspaceFolder}/out/test/extension-tests/multi-root-UI/test/*"
|
||||
],
|
||||
"preLaunchTask": "Pretest",
|
||||
"windows": {
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"HasVs": "true"
|
||||
}
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"TEST_FILTER": ".*"
|
||||
},
|
||||
"linux": {
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"HasVs": "false"
|
||||
}
|
||||
},
|
||||
"osx": {
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"HasVs": "false"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
|
@ -189,7 +141,11 @@
|
|||
"tsconfig-paths/register",
|
||||
"${workspaceFolder}/test/backend-unit-tests/**/*.test.ts"
|
||||
],
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Launch Smoke Tests",
|
||||
|
|
|
@ -8,5 +8,9 @@
|
|||
},
|
||||
"typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version
|
||||
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
|
||||
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false
|
||||
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
|
||||
"cmake.sourceDirectory": "${workspaceFolder}/test/fakeOutputGenerator",
|
||||
"cmake.buildDirectory": "${workspaceFolder}/test/fakeOutputGenerator/build",
|
||||
"cmake.installPrefix": "${workspaceFolder}/test/fakebin",
|
||||
"cmake.generator": "Ninja",
|
||||
}
|
|
@ -2044,7 +2044,7 @@
|
|||
"typescript": "^4.1.5",
|
||||
"vsce": "^1.95.0",
|
||||
"vscode-nls-dev": "^3.3.2",
|
||||
"vscode-test": "^1.5.2",
|
||||
"vscode-test": "^1.6.1",
|
||||
"webpack": "^5.38.1",
|
||||
"webpack-cli": "^4.5.0"
|
||||
},
|
||||
|
|
|
@ -1,23 +1,5 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]
|
||||
param(
|
||||
# Run the named tests
|
||||
[string[]]
|
||||
$Test,
|
||||
# Build the docs only
|
||||
[switch]
|
||||
$Docs,
|
||||
# Target directory to copy documentation tree
|
||||
[string]
|
||||
$DocDestination,
|
||||
# Skip running tests
|
||||
[switch]
|
||||
$NoTest,
|
||||
# Only run the smoke tests
|
||||
[switch]
|
||||
$OnlySmoke,
|
||||
# Only run the unit tests
|
||||
[switch]
|
||||
$OnlyUnit
|
||||
)
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
|
@ -96,6 +78,11 @@ Invoke-ChronicCommand "yarn lint" $yarn run lint
|
|||
# Run tests
|
||||
Invoke-TestPreparation -CMakePath $cmake_binary
|
||||
|
||||
# A bug in yarn causes the contents of the NOTICE file to be inlined into an environment variable
|
||||
# which causes msbuild to crash in some tests. Just remove it to avoid the problem.
|
||||
# https://github.com/yarnpkg/yarn/issues/7783
|
||||
Remove-Item NOTICE.txt
|
||||
|
||||
Invoke-ChronicCommand "yarn backendTests" $yarn run backendTests
|
||||
Invoke-ChronicCommand "yarn pretest" $yarn run pretest
|
||||
Invoke-ChronicCommand "yarn smokeTests" $yarn run smokeTests
|
||||
|
|
|
@ -101,7 +101,7 @@ function Invoke-ChronicCommand {
|
|||
|
||||
$msg = "==> $Description"
|
||||
Write-Host $msg
|
||||
Write-Debug "About to execute $_Command_"
|
||||
Write-Host " > $_Command_"
|
||||
$closure = @{}
|
||||
$measurement = Measure-Command {
|
||||
$result = Invoke-ExternalCommand -PassThruExitCode @_Command_
|
||||
|
@ -182,12 +182,14 @@ function Invoke-TestPreparation {
|
|||
$repo_dir = Split-Path $PSScriptRoot -Parent
|
||||
$fakebin_src = Join-Path $repo_dir "test/fakeOutputGenerator"
|
||||
$fakebin_build = Join-Path $fakebin_src "build"
|
||||
$fakebin_install = Join-Path $repo_dir "test/fakebin"
|
||||
$fakebin_install = $fakebin_install -replace '\\', '/'
|
||||
if (Test-Path $fakebin_build) {
|
||||
Write-Verbose "Removing fakeOutputGenerator build dir: $fakebin_build"
|
||||
Remove-Item $fakebin_build -Recurse
|
||||
}
|
||||
|
||||
Invoke-ChronicCommand "Configuring test utilities" $CMakePath "-H$fakebin_src" "-B$fakebin_build"
|
||||
Invoke-ChronicCommand "Configuring test utilities" $CMakePath "-H$fakebin_src" "-B$fakebin_build" "-DCMAKE_INSTALL_PREFIX:STRING=$fakebin_install"
|
||||
Invoke-ChronicCommand "Building test utilities" $CMakePath --build $fakebin_build
|
||||
|
||||
$fakebin_dest = Join-Path $repo_dir "test/fakebin"
|
||||
|
@ -195,20 +197,7 @@ function Invoke-TestPreparation {
|
|||
Write-Verbose "Removing fakebin executable directory: $fakebin_dest"
|
||||
Remove-Item $fakebin_dest -Recurse
|
||||
}
|
||||
New-Item $fakebin_dest -ItemType Directory -Force | Out-Null
|
||||
|
||||
$ext = if ($PSVersionTable.Platform -eq "Unix") { "" } else { ".exe" }
|
||||
$in_binary = (Get-ChildItem $fakebin_build -Recurse -Filter "FakeOutputGenerator$ext").FullName
|
||||
|
||||
$cfg_dir = Join-Path -Path $fakebin_src -ChildPath "configfiles"
|
||||
$targets = Get-ChildItem -Path $cfg_dir -File | ForEach-Object { $_.BaseName }
|
||||
|
||||
foreach ($target in $targets) {
|
||||
Copy-Item $in_binary "$fakebin_dest/$target$ext"
|
||||
}
|
||||
|
||||
Copy-Item $cfg_dir/* -Destination $fakebin_dest -Recurse
|
||||
|
||||
Invoke-ChronicCommand "Installing test utilities" $CMakePath --install $fakebin_build --config Debug
|
||||
}
|
||||
|
||||
function Get-RemoteFile ($Url, $Path) {
|
||||
|
|
|
@ -19,8 +19,7 @@ import { ExecutionOptions, ExecutionResult } from './api';
|
|||
import * as codemodel_api from '@cmt/drivers/codemodel-driver-interface';
|
||||
import { BadHomeDirectoryError } from '@cmt/drivers/cms-client';
|
||||
import { CMakeServerClientDriver, NoGeneratorError } from '@cmt/drivers/cms-driver';
|
||||
import { CTestDriver } from './ctest';
|
||||
import { BasicTestResults } from './ctest';
|
||||
import { CTestDriver, BasicTestResults } from './ctest';
|
||||
import { CMakeBuildConsumer } from './diagnostics/build';
|
||||
import { CMakeOutputConsumer } from './diagnostics/cmake';
|
||||
import { populateCollection } from './diagnostics/util';
|
||||
|
@ -997,7 +996,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
await this.workspaceContext.state.setActiveKitName(kit.name);
|
||||
this._statusMessage.set(localize('ready.status', 'Ready'));
|
||||
} catch (error: any) {
|
||||
void vscode.window.showErrorMessage(localize('unable.to.set.kit', 'Unable to set kit "{0}".', error));
|
||||
void vscode.window.showErrorMessage(localize('unable.to.set.kit', 'Unable to set kit "{0}".', error.message));
|
||||
this._statusMessage.set(localize('error.on.switch.status', 'Error on switch of kit ({0})', error.message));
|
||||
this._cmakeDriver = Promise.resolve(null);
|
||||
this._activeKit = null;
|
||||
|
@ -1156,31 +1155,30 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
} else if (this.workspaceContext.config.copyCompileCommands) {
|
||||
// single file with known path
|
||||
const compdb_path = path.join(await this.binaryDir, 'compile_commands.json');
|
||||
if (await fs.exists(compdb_path)) {
|
||||
compdb_paths.push(compdb_path);
|
||||
|
||||
if (this.workspaceContext.config.copyCompileCommands) {
|
||||
// Now try to copy the compdb to the user-requested path
|
||||
const copy_dest = this.workspaceContext.config.copyCompileCommands;
|
||||
const expanded_dest = await expandString(copy_dest, opts);
|
||||
const pardir = path.dirname(expanded_dest);
|
||||
// Now try to copy the compdb to the user-requested path
|
||||
const copy_dest = this.workspaceContext.config.copyCompileCommands;
|
||||
const expanded_dest = await expandString(copy_dest, opts);
|
||||
const pardir = path.dirname(expanded_dest);
|
||||
try {
|
||||
log.debug(localize('copy.compile.commands', 'Copying compile_commands.json from {0} to {1}', compdb_path, expanded_dest));
|
||||
await fs.mkdir_p(pardir);
|
||||
try {
|
||||
await fs.mkdir_p(pardir);
|
||||
try {
|
||||
await fs.copyFile(compdb_path, expanded_dest);
|
||||
} catch (e: any) {
|
||||
// Just display the error. It's the best we can do.
|
||||
void vscode.window.showErrorMessage(localize('failed.to.copy', 'Failed to copy "{0}" to "{1}": {2}', compdb_path, expanded_dest, e.toString()));
|
||||
}
|
||||
await fs.copyFile(compdb_path, expanded_dest);
|
||||
} catch (e: any) {
|
||||
void vscode.window.showErrorMessage(localize('failed.to.create.parent.directory',
|
||||
'Tried to copy "{0}" to "{1}", but failed to create the parent directory "{2}": {3}',
|
||||
compdb_path, expanded_dest, pardir, e.toString()));
|
||||
// Just display the error. It's the best we can do.
|
||||
void vscode.window.showErrorMessage(localize('failed.to.copy', 'Failed to copy "{0}" to "{1}": {2}', compdb_path, expanded_dest, e.toString()));
|
||||
}
|
||||
} catch (e: any) {
|
||||
void vscode.window.showErrorMessage(localize('failed.to.create.parent.directory',
|
||||
'Tried to copy "{0}" to "{1}", but failed to create the parent directory "{2}": {3}',
|
||||
compdb_path, expanded_dest, pardir, e.toString()));
|
||||
}
|
||||
} else {
|
||||
log.debug(localize('cannot.copy.compile.commands', 'Cannot copy compile_commands.json because it does not exist at {0}', compdb_path));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1362,9 +1360,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
* Wraps pre/post configure logic around an actual configure function
|
||||
* @param cb The actual configure callback. Called to do the configure
|
||||
*/
|
||||
private async _doConfigure(type: ConfigureType,
|
||||
progress: ProgressHandle,
|
||||
cb: (consumer: CMakeOutputConsumer) => Promise<number>): Promise<number> {
|
||||
private async _doConfigure(type: ConfigureType, progress: ProgressHandle, cb: (consumer: CMakeOutputConsumer) => Promise<number>): Promise<number> {
|
||||
progress.report({ message: localize('saving.open.files', 'Saving open files') });
|
||||
if (!await this.maybeAutoSaveAll(type === ConfigureType.ShowCommandOnly)) {
|
||||
return -1;
|
||||
|
|
|
@ -127,7 +127,11 @@ export class CMakeFileApiDriver extends CMakeDriver {
|
|||
if (cacheExists && this.config.configureOnOpen !== false) {
|
||||
// No need to remove the other CMake files for the generator change to work properly
|
||||
log.info(localize('removing', 'Removing {0}', this.cachePath));
|
||||
await fs.unlink(this.cachePath);
|
||||
try {
|
||||
await fs.unlink(this.cachePath);
|
||||
} catch {
|
||||
log.warning(localize('unlink.failed', 'Failed to remove cache file {0}', this.cachePath));
|
||||
}
|
||||
}
|
||||
|
||||
this._generatorInformation = this.generator;
|
||||
|
|
|
@ -404,7 +404,11 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
const cmake_files = path.join(build_dir, 'CMakeFiles');
|
||||
if (await fs.exists(cache)) {
|
||||
log.info(localize('removing', 'Removing {0}', cache));
|
||||
await fs.unlink(cache);
|
||||
try {
|
||||
await fs.unlink(cache);
|
||||
} catch {
|
||||
log.error(localize('unlink.failed', 'Failed to remove cache file {0}', this.cachePath));
|
||||
}
|
||||
}
|
||||
if (await fs.exists(cmake_files)) {
|
||||
log.info(localize('removing', 'Removing {0}', cmake_files));
|
||||
|
@ -610,16 +614,8 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
return cb();
|
||||
}
|
||||
|
||||
private async _refreshExpansions(showCommandOnly?: boolean) {
|
||||
if (!showCommandOnly) {
|
||||
log.debug('Run _refreshExpansions');
|
||||
}
|
||||
|
||||
private async _refreshExpansions() {
|
||||
return this.doRefreshExpansions(async () => {
|
||||
if (!showCommandOnly) {
|
||||
log.debug('Run _refreshExpansions cb');
|
||||
}
|
||||
|
||||
this._sourceDirectory = await util.normalizeAndVerifySourceDir(await expand.expandString(this.config.sourceDirectory, CMakeDriver.sourceDirExpansionOptions(this.workspaceFolder)));
|
||||
|
||||
const opts = this.expansionOptions;
|
||||
|
@ -633,11 +629,6 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
this._installDir = util.lightNormalizePath(await expand.expandString(installPrefix, opts));
|
||||
}
|
||||
}
|
||||
|
||||
const copyCompileCommands = this.config.copyCompileCommands;
|
||||
if (copyCompileCommands) {
|
||||
this._copyCompileCommandsPath = util.lightNormalizePath(await expand.expandString(copyCompileCommands, opts));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -665,14 +656,6 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
}
|
||||
private _installDir: string | null = null;
|
||||
|
||||
/**
|
||||
* Path to copy compile_commands.json to
|
||||
*/
|
||||
get copyCompileCommandsPath(): string | null {
|
||||
return this._copyCompileCommandsPath;
|
||||
}
|
||||
private _copyCompileCommandsPath: string | null = null;
|
||||
|
||||
/**
|
||||
* @brief Get the path to the CMakeCache file in the build directory
|
||||
*/
|
||||
|
@ -780,11 +763,11 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
const child = this.executeCommand(program, args, undefined, { silent: true });
|
||||
try {
|
||||
const result = await child.result;
|
||||
log.debug(localize('command.version.test.return.code', 'Command version test return code {0}', nullableValueToString(result.retc)));
|
||||
log.trace(localize('command.version.test.return.code', '"{0}" returned code {1}', `${program} ${args.join(' ')}`, nullableValueToString(result.retc)));
|
||||
return result.retc === 0;
|
||||
} catch (e: any) {
|
||||
const e2: NodeJS.ErrnoException = e;
|
||||
log.debug(localize('command.version.test.return.code', 'Command version test return code {0}', nullableValueToString(e2.code)));
|
||||
log.debug(localize('command.version.test.return.code', '"{0}" returned code {1}', `${program} ${args.join(' ')}`, nullableValueToString(e2.code)));
|
||||
if (e2.code === 'ENOENT') {
|
||||
return false;
|
||||
}
|
||||
|
@ -867,8 +850,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
return this.configure(trigger, extra_args, consumer);
|
||||
}
|
||||
|
||||
async testCompilerVersion(program: string, cwd: string, arg: string | undefined,
|
||||
regexp: RegExp, captureGroup: number): Promise<string | undefined> {
|
||||
async testCompilerVersion(program: string, cwd: string, arg: string | undefined, regexp: RegExp, captureGroup: number): Promise<string | undefined> {
|
||||
const args = [];
|
||||
if (arg) {
|
||||
args.push(arg);
|
||||
|
@ -876,7 +858,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
const child = this.executeCommand(program, args, undefined, { silent: true, cwd });
|
||||
try {
|
||||
const result = await child.result;
|
||||
console.log(localize('command.version.test.return.code', 'Command version test return code {0}', nullableValueToString(result.retc)));
|
||||
log.trace(localize('command.version.test.return.code', '"{0}" returned code {1}', `${program} ${arg}`, nullableValueToString(result.retc)));
|
||||
// Various compilers will output into stdout, others in stderr.
|
||||
// It's safe to concat them into one string to search in, since it's enough to analyze
|
||||
// the first match (stderr can't print a different version than stdout).
|
||||
|
@ -887,7 +869,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
return match ? match[captureGroup] : "error";
|
||||
} catch (e: any) {
|
||||
const e2: NodeJS.ErrnoException = e;
|
||||
console.log(localize('compiler.version.return.code', 'Compiler version test return code {0}', nullableValueToString(e2.code)));
|
||||
log.debug(localize('compiler.version.return.code', '"{0}" returned code {1}', `${program} ${arg}`, nullableValueToString(e2.code)));
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
@ -1131,8 +1113,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
// since some compilers can output their version without a specific switch.
|
||||
let version;
|
||||
if (compiler?.versionOutputRegexp) {
|
||||
version = await this.testCompilerVersion(compilerName, compilerDir, compiler?.versionSwitch,
|
||||
RegExp(compiler.versionOutputRegexp, "mgi"), compiler.captureGroup) || "unknown";
|
||||
version = await this.testCompilerVersion(compilerName, compilerDir, compiler?.versionSwitch, RegExp(compiler.versionOutputRegexp, "mgi"), compiler.captureGroup) || "unknown";
|
||||
} else {
|
||||
version = "unknown";
|
||||
}
|
||||
|
@ -1229,7 +1210,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
try {
|
||||
// _beforeConfigureOrBuild needs to refresh expansions early because it reads various settings
|
||||
// (example: cmake.sourceDirectory).
|
||||
await this._refreshExpansions(showCommandOnly);
|
||||
await this._refreshExpansions();
|
||||
if (!showCommandOnly) {
|
||||
if (!shouldUseCachedConfiguration) {
|
||||
log.debug(localize('start.configure', 'Start configure'), extra_args);
|
||||
|
@ -1273,7 +1254,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
}
|
||||
|
||||
// A more complete round of expansions
|
||||
await this._refreshExpansions(showCommandOnly);
|
||||
await this._refreshExpansions();
|
||||
|
||||
const timeStart: number = new Date().getTime();
|
||||
let retc: number;
|
||||
|
@ -1570,7 +1551,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
*/
|
||||
private async _beforeConfigureOrBuild(showCommandOnly?: boolean): Promise<boolean> {
|
||||
if (!showCommandOnly) {
|
||||
log.debug(localize('running.pre-configure.checks', 'Runnnig pre-configure checks and steps'));
|
||||
log.debug(localize('running.pre-configure.checks', 'Running pre-configure checks and steps'));
|
||||
}
|
||||
|
||||
if (!this.sourceDir) {
|
||||
|
|
39
src/kit.ts
39
src/kit.ts
|
@ -160,7 +160,7 @@ export async function getCompilerVersion(vendor: CompilerVendorEnum, binPath: st
|
|||
}
|
||||
const exec = await proc.execute(binPath, ['-v'], undefined, { overrideLocale: true }).result;
|
||||
if (exec.retc !== 0) {
|
||||
log.debug(localize('bad.compiler.binary', 'Bad {0} binary ("-v" returns non-zero): {1}', vendor, binPath));
|
||||
log.debug(localize('bad.compiler.binary', 'Bad {0} binary ("-v" returns {1}): {2}', vendor, exec.retc, binPath));
|
||||
return null;
|
||||
}
|
||||
let version_re: RegExp;
|
||||
|
@ -374,6 +374,11 @@ export async function kitIfCompiler(bin: string, pr?: ProgressReporter): Promise
|
|||
}
|
||||
|
||||
async function scanDirectory<Ret>(dir: string, mapper: (filePath: string) => Promise<Ret | null>): Promise<Ret[]> {
|
||||
if (process.env['CMT_TESTING'] === '1' && process.platform === 'win32' && dir.indexOf('AppData') > 0 && dir.indexOf('Local') > 0) {
|
||||
// This folder causes problems with tests on Windows.
|
||||
log.debug(localize('skipping.scan.of.appdata', 'Skipping scan of %LocalAppData% folder'));
|
||||
return [];
|
||||
}
|
||||
if (!await fs.exists(dir)) {
|
||||
log.debug(localize('skipping.scan.of.not.existing.path', 'Skipping scan of not existing path {0}', dir));
|
||||
return [];
|
||||
|
@ -402,7 +407,9 @@ async function scanDirectory<Ret>(dir: string, mapper: (filePath: string) => Pro
|
|||
if (e.code === 'EACCESS' || e.code === 'EPERM') {
|
||||
return [];
|
||||
}
|
||||
throw e;
|
||||
console.log('unexpected file system error');
|
||||
console.log(e);
|
||||
return [];
|
||||
}
|
||||
|
||||
const prs = await Promise.all(bins.map(b => mapper(b)));
|
||||
|
@ -877,7 +884,7 @@ const VsGenerators: { [key: string]: string } = {
|
|||
};
|
||||
|
||||
async function varsForVSInstallation(inst: VSInstallation, hostArch: string, targetArch?: string): Promise<Map<string, string> | null> {
|
||||
console.log(`varsForVSInstallation path:'${inst.installationPath}' version:${inst.installationVersion} host arch:${hostArch} - target arch:${targetArch}`);
|
||||
log.trace(`varsForVSInstallation path:'${inst.installationPath}' version:${inst.installationVersion} host arch:${hostArch} - target arch:${targetArch}`);
|
||||
const common_dir = path.join(inst.installationPath, 'Common7', 'Tools');
|
||||
const majorVersion = parseInt(inst.installationVersion);
|
||||
let vcvarsScript: string = 'vcvarsall.bat';
|
||||
|
@ -1012,7 +1019,7 @@ export async function scanForVSKits(pr?: ProgressReporter): Promise<Kit[]> {
|
|||
return ([] as Kit[]).concat(...vs_kits);
|
||||
}
|
||||
|
||||
async function scanDirForClangForMSVCKits(dir: string, vsInstalls: VSInstallation[], cmakeTools: CMakeTools | undefined): Promise<Kit[]> {
|
||||
async function scanDirForClangForMSVCKits(dir: string, vsInstalls: VSInstallation[], cmakeTools?: CMakeTools): Promise<Kit[]> {
|
||||
const kits = await scanDirectory(dir, async (binPath): Promise<Kit[] | null> => {
|
||||
const isClangGNUCLI = (path.basename(binPath, '.exe') === 'clang');
|
||||
const isClangCL = (path.basename(binPath, '.exe') === 'clang-cl');
|
||||
|
@ -1030,11 +1037,10 @@ async function scanDirForClangForMSVCKits(dir: string, vsInstalls: VSInstallatio
|
|||
// Clang for MSVC ABI with GNU CLI (command line interface) is supported in CMake 3.15.0+
|
||||
if (isClangGNUCLI) {
|
||||
if (undefined === cmakeTools) {
|
||||
log.error(localize("failed.to.scan.for.kits", "Failed to scan for kits: cmakeTools is undefined"));
|
||||
|
||||
log.info(localize("failed.to.scan.for.kits", "Unable to scan for GNU CLI Clang kits: cmakeTools is undefined"));
|
||||
return null;
|
||||
} else {
|
||||
const cmake_executable = await cmakeTools?.getCMakeExecutable();
|
||||
const cmake_executable = await cmakeTools.getCMakeExecutable();
|
||||
if (undefined === cmake_executable.version) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -1073,7 +1079,7 @@ async function scanDirForClangForMSVCKits(dir: string, vsInstalls: VSInstallatio
|
|||
return ([] as Kit[]).concat(...kits);
|
||||
}
|
||||
|
||||
export async function scanForClangForMSVCKits(searchPaths: string[], cmakeTools: CMakeTools | undefined): Promise<Promise<Kit[]>[]> {
|
||||
export async function scanForClangForMSVCKits(searchPaths: string[], cmakeTools?: CMakeTools): Promise<Promise<Kit[]>[]> {
|
||||
const vs_installs = await vsInstallations();
|
||||
const results = searchPaths.map(p => scanDirForClangForMSVCKits(p, vs_installs, cmakeTools));
|
||||
return results;
|
||||
|
@ -1185,6 +1191,7 @@ export async function findCLCompilerPath(env: Map<string, string>): Promise<stri
|
|||
}
|
||||
|
||||
export interface KitScanOptions {
|
||||
ignorePath?: boolean;
|
||||
scanDirs?: string[];
|
||||
minGWSearchDirs?: string[];
|
||||
}
|
||||
|
@ -1193,7 +1200,7 @@ export interface KitScanOptions {
|
|||
* Search for Kits available on the platform.
|
||||
* @returns A list of Kits.
|
||||
*/
|
||||
export async function scanForKits(cmakeTools: CMakeTools | undefined, opt?: KitScanOptions) {
|
||||
export async function scanForKits(cmakeTools?: CMakeTools, opt?: KitScanOptions) {
|
||||
const kit_options = opt || {};
|
||||
|
||||
log.debug(localize('scanning.for.kits.on.system', 'Scanning for Kits on system'));
|
||||
|
@ -1211,8 +1218,18 @@ export async function scanForKits(cmakeTools: CMakeTools | undefined, opt?: KitS
|
|||
|
||||
// Search directories on `PATH` for compiler binaries
|
||||
if (process.env.hasOwnProperty('PATH')) {
|
||||
const sep = isWin32 ? ';' : ':';
|
||||
for (const dir of (process.env.PATH as string).split(sep)) {
|
||||
if (opt && opt.ignorePath) {
|
||||
log.debug(localize('skip.scan.path', 'Skipping scan of PATH'));
|
||||
} else {
|
||||
const sep = isWin32 ? ';' : ':';
|
||||
for (const dir of (process.env.PATH as string).split(sep)) {
|
||||
scan_paths.add(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (opt?.scanDirs) {
|
||||
for (const dir of opt.scanDirs) {
|
||||
scan_paths.add(dir);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ export class KitsController {
|
|||
}
|
||||
|
||||
const folderKitsFiles: string[] = [KitsController._workspaceKitsPath(cmakeTools.folder)].concat(await KitsController.expandAdditionalKitFiles(cmakeTools));
|
||||
const kitsWatcher = chokidar.watch(folderKitsFiles, { ignoreInitial: true });
|
||||
const kitsWatcher = chokidar.watch(folderKitsFiles, { ignoreInitial: true, followSymlinks: false });
|
||||
const kitsController = new KitsController(cmakeTools, kitsWatcher);
|
||||
chokidarOnAnyChange(kitsWatcher, _ => rollbar.takePromise(localize('rereading.kits', 'Re-reading folder kits'), {},
|
||||
kitsController.readKits(KitsReadMode.folderKits)));
|
||||
|
|
|
@ -259,6 +259,11 @@ export class Logger {
|
|||
SingletonLogger.instance().showChannel(!should_focus);
|
||||
}
|
||||
}
|
||||
|
||||
static logTestName(suite?: string, test?: string) {
|
||||
SingletonLogger.instance().info('-----------------------------------------------------------------------');
|
||||
SingletonLogger.instance().info(`Beginning test: ${suite ?? 'unknown suite'} - ${test ?? 'unknown test'}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function createLogger(tag: string) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import { DirectoryContext } from '@cmt/workspace';
|
||||
import * as path from 'path';
|
||||
import * as which from 'which';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { vsInstallations } from './installs/visual-studio';
|
||||
import { expandString } from './expand';
|
||||
|
@ -18,10 +19,16 @@ interface VSCMakePaths {
|
|||
|
||||
class WindowsEnvironment {
|
||||
get AppData(): string | undefined {
|
||||
if (process.env['CMT_TESTING'] === '1') {
|
||||
return path.join(vscode.workspace.workspaceFolders![0].uri.fsPath, '.vscode');
|
||||
}
|
||||
return process.env['APPDATA'];
|
||||
}
|
||||
|
||||
get LocalAppData(): string | undefined {
|
||||
if (process.env['CMT_TESTING'] === '1') {
|
||||
return path.join(vscode.workspace.workspaceFolders![0].uri.fsPath, '.vscode');
|
||||
}
|
||||
return process.env['LOCALAPPDATA'];
|
||||
}
|
||||
|
||||
|
|
|
@ -187,6 +187,8 @@ export function execute(command: string,
|
|||
line_acc += lines[0];
|
||||
if (outputConsumer) {
|
||||
outputConsumer.output(line_acc);
|
||||
} else if (process.env['CMT_TESTING']) {
|
||||
log.info(line_acc);
|
||||
}
|
||||
line_acc = '';
|
||||
// Erase the first line from the list
|
||||
|
@ -205,6 +207,8 @@ export function execute(command: string,
|
|||
stderr_line_acc += lines[0];
|
||||
if (outputConsumer) {
|
||||
outputConsumer.error(stderr_line_acc);
|
||||
} else if (process.env['CMT_TESTING'] && stderr_line_acc) {
|
||||
log.info(stderr_line_acc);
|
||||
}
|
||||
stderr_line_acc = '';
|
||||
// Erase the first line from the list
|
||||
|
|
|
@ -129,17 +129,17 @@ export function computeTargetTriple(target: TargetTriple): string {
|
|||
|
||||
export function parseTargetTriple(triple: string): TargetTriple | undefined {
|
||||
const triples = triple.split("-");
|
||||
let foundArch = "unknow";
|
||||
let foundOs = 'unknow';
|
||||
let foundAbi = 'unknow';
|
||||
let foundLibc = 'unknow';
|
||||
let foundArch = 'unknown';
|
||||
let foundOs = 'unknown';
|
||||
let foundAbi = 'unknown';
|
||||
let foundLibc = 'unknown';
|
||||
const elementToSkip: string[] = [];
|
||||
for (const tripleElement of triples) {
|
||||
for (const key of Object.keys(TriplePossibleArch)) {
|
||||
const archReg = TriplePossibleArch[key];
|
||||
if (archReg.exec(tripleElement) !== null) {
|
||||
elementToSkip.push(tripleElement);
|
||||
if (foundArch === "unknow") {
|
||||
if (foundArch === 'unknown') {
|
||||
foundArch = key;
|
||||
break;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ export function parseTargetTriple(triple: string): TargetTriple | undefined {
|
|||
const osReg = TriplePossibleOS[key];
|
||||
if (osReg.exec(tripleElement) !== null) {
|
||||
elementToSkip.push(tripleElement);
|
||||
if (foundOs === "unknow" || foundOs === 'none') {
|
||||
if (foundOs === 'unknown' || foundOs === 'none') {
|
||||
// os other than none have higher priority
|
||||
// so we not break
|
||||
foundOs = key;
|
||||
|
@ -162,7 +162,7 @@ export function parseTargetTriple(triple: string): TargetTriple | undefined {
|
|||
const abiReg = TriplePossibleABI[key];
|
||||
if (abiReg.exec(tripleElement) !== null) {
|
||||
elementToSkip.push(tripleElement);
|
||||
if (foundAbi === "unknow") {
|
||||
if (foundAbi === 'unknown') {
|
||||
foundAbi = key;
|
||||
break;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ export function parseTargetTriple(triple: string): TargetTriple | undefined {
|
|||
const libcReg = possibleLibC.regexp;
|
||||
if (libcReg.exec(tripleElement) !== null) {
|
||||
elementToSkip.push(tripleElement);
|
||||
if (foundLibc === "unknow") {
|
||||
if (foundLibc === 'unknown') {
|
||||
foundLibc = possibleLibC.key;
|
||||
break;
|
||||
}
|
||||
|
@ -189,11 +189,11 @@ export function parseTargetTriple(triple: string): TargetTriple | undefined {
|
|||
|
||||
return {
|
||||
triple,
|
||||
targetOs: foundOs === 'unknow' ? 'none' : foundOs,
|
||||
targetOs: foundOs === 'unknown' ? 'none' : foundOs,
|
||||
targetArch: foundArch,
|
||||
vendors,
|
||||
abi: foundAbi === 'unknow' ? '' : foundAbi,
|
||||
libc: foundLibc === 'unknow' ? '' : foundLibc
|
||||
abi: foundAbi === 'unknown' ? '' : foundAbi,
|
||||
libc: foundLibc === 'unknown' ? '' : foundLibc
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -637,6 +637,9 @@ export function isBoolean(x: any): x is boolean {
|
|||
}
|
||||
|
||||
export function makeHashString(str: string): string {
|
||||
if (process.platform === 'win32') {
|
||||
str = normalizePath(str, {normCase: 'always'});
|
||||
}
|
||||
const crypto = require('crypto');
|
||||
const hash = crypto.createHash('sha256');
|
||||
hash.update(str);
|
||||
|
|
|
@ -187,7 +187,7 @@ export class VariantManager implements vscode.Disposable {
|
|||
/**
|
||||
* Watches for changes to the variants file on the filesystem
|
||||
*/
|
||||
private readonly _variantFileWatcher = chokidar.watch([], { ignoreInitial: true });
|
||||
private readonly _variantFileWatcher = chokidar.watch([], { ignoreInitial: true, followSymlinks: false });
|
||||
|
||||
private customVariantsFileExists: boolean = false;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'module-alias/register';
|
|||
import * as path from 'path';
|
||||
import * as Mocha from 'mocha';
|
||||
import * as glob from 'glob';
|
||||
import { Logger } from '@cmt/logging';
|
||||
|
||||
export function run(): Promise<void> {
|
||||
// Create the mocha test
|
||||
|
@ -20,11 +21,23 @@ export function run(): Promise<void> {
|
|||
}
|
||||
|
||||
// Add files to the test suite
|
||||
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
|
||||
const regex = process.env.TEST_FILTER ? new RegExp(process.env.TEST_FILTER) : /.*/;
|
||||
files.forEach(f => {
|
||||
if (regex.test(f)) {
|
||||
mocha.addFile(path.resolve(testsRoot, f));
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
// Run the mocha test
|
||||
mocha.timeout(100000);
|
||||
|
||||
// Log the name of each test before it starts.
|
||||
const beforeEach: Mocha.Func = function (this: Mocha.Context, done: Mocha.Done) {
|
||||
Logger.logTestName(this.currentTest?.parent?.title, this.currentTest?.title);
|
||||
done();
|
||||
};
|
||||
mocha.rootHooks({beforeEach});
|
||||
mocha.run(failures => {
|
||||
if (failures > 0) {
|
||||
e(new Error(`${failures} tests failed.`));
|
||||
|
|
|
@ -1,63 +1,56 @@
|
|||
[
|
||||
{
|
||||
"name": "Test Toolchain",
|
||||
"toolchainFile": "${workspaceFolder}\\test-toolchain.cmake"
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Mingw - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "MinGW Makefiles"
|
||||
},
|
||||
"environmentVariables": {
|
||||
"PATH": "${env:PATH};C:\\MinGW\\bin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
} ,
|
||||
{
|
||||
"name": "Generator switch test GCC no generator - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
}
|
||||
} ,
|
||||
{
|
||||
"name": "Generator switch test GCC Make",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Unix Makefiles"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC no generator",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "Test Toolchain",
|
||||
"toolchainFile": "${workspaceFolder}\\test-toolchain.cmake"
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Make",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Unix Makefiles"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC no generator",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86",
|
||||
"preferredGenerator": {
|
||||
"name": "Visual Studio 16 2019",
|
||||
"platform": "win32",
|
||||
"toolset": "host=x86"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019 Ninja",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86",
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019 no generator",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,63 +1,56 @@
|
|||
[
|
||||
{
|
||||
"name": "Test Toolchain",
|
||||
"toolchainFile": "${workspaceFolder}\\test-toolchain.cmake"
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Mingw - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "MinGW Makefiles"
|
||||
},
|
||||
"environmentVariables": {
|
||||
"PATH": "${env:PATH};C:\\MinGW\\bin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
} ,
|
||||
{
|
||||
"name": "Generator switch test GCC no generator - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
}
|
||||
} ,
|
||||
{
|
||||
"name": "Generator switch test GCC Make",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Unix Makefiles"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC no generator",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "Test Toolchain",
|
||||
"toolchainFile": "${workspaceFolder}\\test-toolchain.cmake"
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Make",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Unix Makefiles"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC no generator",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86",
|
||||
"preferredGenerator": {
|
||||
"name": "Visual Studio 16 2019",
|
||||
"platform": "win32",
|
||||
"toolset": "host=x86"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019 Ninja",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86",
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019 no generator",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -15,7 +15,11 @@ async function main() {
|
|||
const testWorkspace = path.resolve(extensionDevelopmentPath, 'test/extension-tests/multi-root-UI/project-workspace.code-workspace');
|
||||
|
||||
const launchArgs = ["--disable-extensions", testWorkspace];
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = { "CMT_TESTING": "1" };
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"TEST_FILTER": process.env.TEST_FILTER ?? ".*"
|
||||
};
|
||||
|
||||
// Download VS Code, unzip it and run the integration test
|
||||
await runTests({ launchArgs, extensionDevelopmentPath, extensionTestsPath, extensionTestsEnv });
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { fs } from '@cmt/pr';
|
||||
import { TestProgramResult } from '@test/helpers/testprogram/test-program-result';
|
||||
import { logFilePath } from '@cmt/logging';
|
||||
import {
|
||||
clearExistingKitConfigurationFile,
|
||||
DefaultEnvironment,
|
||||
|
@ -11,22 +10,12 @@ import {
|
|||
import * as fs_ from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import CMakeTools from '@cmt/cmake-tools';
|
||||
|
||||
let workername: string = process.platform;
|
||||
|
||||
if (process.env.APPVEYOR_BUILD_WORKER_IMAGE) {
|
||||
workername = process.env.APPVEYOR_BUILD_WORKER_IMAGE;
|
||||
}
|
||||
|
||||
if (process.env.TRAVIS_OS_NAME) {
|
||||
workername = process.env.TRAVIS_OS_NAME;
|
||||
}
|
||||
const workername: string = process.platform;
|
||||
|
||||
suite('Build', async () => {
|
||||
let testEnv: DefaultEnvironment;
|
||||
let folder2: DefaultEnvironment;
|
||||
let compdb_cp_path: string;
|
||||
let cmakeTools: CMakeTools;
|
||||
|
||||
suiteSetup(async function (this: Mocha.Context) {
|
||||
this.timeout(100000);
|
||||
|
@ -34,44 +23,31 @@ suite('Build', async () => {
|
|||
const build_loc = 'build';
|
||||
const exe_res = 'output.txt';
|
||||
|
||||
testEnv = new DefaultEnvironment('test/extension-tests/multi-root-UI/project-folder2', build_loc, exe_res);
|
||||
compdb_cp_path = path.join(testEnv.projectFolder.location, 'compdb_cp.json');
|
||||
cmakeTools = await CMakeTools.create(testEnv.vsContext, testEnv.wsContext);
|
||||
folder2 = new DefaultEnvironment('test/extension-tests/multi-root-UI/project-folder2', build_loc, exe_res);
|
||||
compdb_cp_path = path.join(folder2.projectFolder.location, 'compdb_cp.json');
|
||||
|
||||
// This test will use all on the same kit.
|
||||
// No rescan of the tools is needed
|
||||
// No new kit selection is needed
|
||||
await vscode.commands.executeCommand('cmake.scanForKits');
|
||||
await clearExistingKitConfigurationFile();
|
||||
await vscode.commands.executeCommand('cmake.scanForKits');
|
||||
});
|
||||
|
||||
setup(async function (this: Mocha.Context) {
|
||||
this.timeout(100000);
|
||||
|
||||
const kit = await getFirstSystemKit(cmakeTools);
|
||||
console.log("Using following kit in next test: ", kit.name);
|
||||
const kit = await getFirstSystemKit();
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', kit.name);
|
||||
testEnv.projectFolder.buildDirectory.clear();
|
||||
folder2.projectFolder.buildDirectory.clear();
|
||||
});
|
||||
|
||||
teardown(async function (this: Mocha.Context) {
|
||||
this.timeout(100000);
|
||||
const logPath = logFilePath();
|
||||
testEnv.clean();
|
||||
if (await fs.exists(logPath)) {
|
||||
if (this.currentTest?.state === "failed") {
|
||||
const logContent = await fs.readFile(logPath);
|
||||
logContent.toString().split('\n').forEach(line => {
|
||||
console.log(line);
|
||||
});
|
||||
}
|
||||
await fs.writeFile(logPath, "");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
suiteTeardown(async () => {
|
||||
if (testEnv) {
|
||||
testEnv.teardown();
|
||||
if (folder2) {
|
||||
folder2.teardown();
|
||||
}
|
||||
if (await fs.exists(compdb_cp_path)) {
|
||||
await fs.unlink(compdb_cp_path);
|
||||
|
@ -81,25 +57,25 @@ suite('Build', async () => {
|
|||
test('Configure', async () => {
|
||||
expect(await vscode.commands.executeCommand('cmake.configure')).to.be.eq(0);
|
||||
// Didn't configure this folder
|
||||
expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(false, 'cache present');
|
||||
expect(folder2.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(false, 'cache present');
|
||||
}).timeout(100000);
|
||||
|
||||
test('ConfigureAll', async () => {
|
||||
expect(await vscode.commands.executeCommand('cmake.configureAll')).to.be.eq(0);
|
||||
|
||||
expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, 'no expected cache present');
|
||||
expect(folder2.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, 'no expected cache present');
|
||||
}).timeout(200000);
|
||||
|
||||
test('Build', async () => {
|
||||
expect(await vscode.commands.executeCommand('cmake.build')).to.be.eq(0);
|
||||
|
||||
expect(fs_.existsSync(path.join(testEnv.projectFolder.buildDirectory.location, testEnv.executableResult))).to.eql(false, 'Wrong folder built');
|
||||
expect(fs_.existsSync(path.join(folder2.projectFolder.buildDirectory.location, folder2.executableResult))).to.eql(false, 'Wrong folder built');
|
||||
}).timeout(200000);
|
||||
|
||||
test('BuildAll', async () => {
|
||||
expect(await vscode.commands.executeCommand('cmake.buildAll')).to.be.eq(0);
|
||||
|
||||
const result = await testEnv.result.getResultAsJson();
|
||||
const result = await folder2.result.getResultAsJson();
|
||||
expect(result['cookie']).to.eq('passed-cookie');
|
||||
}).timeout(200000);
|
||||
|
||||
|
@ -107,7 +83,7 @@ suite('Build', async () => {
|
|||
expect(await vscode.commands.executeCommand('cmake.configureAll')).to.be.eq(0);
|
||||
expect(await vscode.commands.executeCommand('cmake.buildAll')).to.be.eq(0);
|
||||
|
||||
const result = await testEnv.result.getResultAsJson();
|
||||
const result = await folder2.result.getResultAsJson();
|
||||
expect(result['cookie']).to.eq('passed-cookie');
|
||||
}).timeout(200000);
|
||||
|
||||
|
@ -118,7 +94,7 @@ suite('Build', async () => {
|
|||
await vscode.commands.executeCommand('cmake.setDefaultTarget', vscode.workspace.workspaceFolders![1], 'runTestTarget');
|
||||
expect(await vscode.commands.executeCommand('cmake.buildAll')).to.be.eq(0);
|
||||
|
||||
const resultFile = new TestProgramResult(testEnv.projectFolder.buildDirectory.location, 'output_target.txt');
|
||||
const resultFile = new TestProgramResult(folder2.projectFolder.buildDirectory.location, 'output_target.txt');
|
||||
const result = await resultFile.getResultAsJson();
|
||||
expect(result['cookie']).to.eq('passed-cookie');
|
||||
}).timeout(200000);
|
||||
|
@ -127,7 +103,7 @@ suite('Build', async () => {
|
|||
// Select compiler build node dependent
|
||||
const os_compilers: { [osName: string]: { kitLabel: RegExp; compiler: string }[] } = {
|
||||
linux: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }],
|
||||
win32: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^VisualStudio/, compiler: 'MSVC' }]
|
||||
win32: [{ kitLabel: /^Visual Studio/, compiler: 'MSVC' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }]
|
||||
};
|
||||
if (!(workername in os_compilers)) {
|
||||
this.skip();
|
||||
|
@ -135,43 +111,41 @@ suite('Build', async () => {
|
|||
const compiler = os_compilers[workername];
|
||||
|
||||
// Run test
|
||||
testEnv.kitSelection.defaultKitLabel = compiler[0].kitLabel;
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', (await getMatchingSystemKit(cmakeTools, compiler[0].kitLabel)).name);
|
||||
folder2.kitSelection.defaultKitLabel = compiler[0].kitLabel;
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', (await getMatchingSystemKit(undefined, compiler[0].kitLabel)).name);
|
||||
|
||||
await vscode.commands.executeCommand('cmake.buildAll');
|
||||
|
||||
testEnv.kitSelection.defaultKitLabel = compiler[1].kitLabel;
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', (await getMatchingSystemKit(cmakeTools, compiler[1].kitLabel)).name);
|
||||
folder2.kitSelection.defaultKitLabel = compiler[1].kitLabel;
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', (await getMatchingSystemKit(undefined, compiler[1].kitLabel)).name);
|
||||
|
||||
await vscode.commands.executeCommand('cmake.buildAll');
|
||||
const result = await testEnv.result.getResultAsJson();
|
||||
const result = await folder2.result.getResultAsJson();
|
||||
expect(result['compiler']).to.eql(compiler[1].compiler);
|
||||
}).timeout(100000);
|
||||
}).timeout(150000);
|
||||
|
||||
test('Test kit switch between different preferred generators and compilers',
|
||||
async function (this: Mocha.Context) {
|
||||
// Select compiler build node dependent
|
||||
const os_compilers: { [osName: string]: { kitLabel: RegExp; compiler: string }[] } = {
|
||||
linux: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }],
|
||||
win32: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^VisualStudio/, compiler: 'MSVC' }]
|
||||
};
|
||||
if (!(workername in os_compilers)) {
|
||||
this.skip();
|
||||
}
|
||||
const compiler = os_compilers[workername];
|
||||
test('Test kit switch between different preferred generators and compilers', async function (this: Mocha.Context) {
|
||||
// Select compiler build node dependent
|
||||
const os_compilers: { [osName: string]: { kitLabel: RegExp; compiler: string }[] } = {
|
||||
linux: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }],
|
||||
win32: [{ kitLabel: /^Visual Studio/, compiler: 'MSVC' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }]
|
||||
};
|
||||
if (!(workername in os_compilers)) {
|
||||
this.skip();
|
||||
}
|
||||
const compiler = os_compilers[workername];
|
||||
|
||||
testEnv.kitSelection.defaultKitLabel = compiler[0].kitLabel;
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', (await getMatchingSystemKit(cmakeTools, compiler[0].kitLabel)).name);
|
||||
await vscode.commands.executeCommand('cmake.buildAll');
|
||||
folder2.kitSelection.defaultKitLabel = compiler[0].kitLabel;
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', (await getMatchingSystemKit(undefined, compiler[0].kitLabel)).name);
|
||||
await vscode.commands.executeCommand('cmake.buildAll');
|
||||
|
||||
testEnv.kitSelection.defaultKitLabel = compiler[1].kitLabel;
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', (await getMatchingSystemKit(cmakeTools, compiler[1].kitLabel)).name);
|
||||
await vscode.commands.executeCommand('cmake.buildAll');
|
||||
folder2.kitSelection.defaultKitLabel = compiler[1].kitLabel;
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', (await getMatchingSystemKit(undefined, compiler[1].kitLabel)).name);
|
||||
await vscode.commands.executeCommand('cmake.buildAll');
|
||||
|
||||
const result = await testEnv.result.getResultAsJson();
|
||||
expect(result['compiler']).to.eql(compiler[1].compiler);
|
||||
})
|
||||
.timeout(100000);
|
||||
const result = await folder2.result.getResultAsJson();
|
||||
expect(result['compiler']).to.eql(compiler[1].compiler);
|
||||
}).timeout(150000);
|
||||
|
||||
test('Test build twice', async function (this: Mocha.Context) {
|
||||
console.log('1. Build');
|
||||
|
@ -216,6 +190,6 @@ suite('Build', async () => {
|
|||
expect(await vscode.commands.executeCommand('cmake.buildAll')).eq(0);
|
||||
await vscode.commands.executeCommand('cmake.cleanRebuildAll');
|
||||
expect(await vscode.commands.executeCommand('cmake.buildAll')).eq(0);
|
||||
await testEnv.result.getResultAsJson();
|
||||
await folder2.result.getResultAsJson();
|
||||
}).timeout(400000);
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ import { DefaultEnvironment, expect, getFirstSystemKit } from '@test/util';
|
|||
import * as vscode from 'vscode';
|
||||
import CMakeTools from '@cmt/cmake-tools';
|
||||
|
||||
suite('[Debug/Launch interface]', async () => {
|
||||
suite('Debug/Launch interface', async () => {
|
||||
let testEnv: DefaultEnvironment;
|
||||
let cmakeTools: CMakeTools;
|
||||
|
||||
|
@ -16,7 +16,6 @@ suite('[Debug/Launch interface]', async () => {
|
|||
cmakeTools = await CMakeTools.create(testEnv.vsContext, testEnv.wsContext);
|
||||
|
||||
const kit = await getFirstSystemKit(cmakeTools);
|
||||
console.log("Using following kit in next test: ", kit.name);
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', kit.name);
|
||||
testEnv.projectFolder.buildDirectory.clear();
|
||||
expect(await vscode.commands.executeCommand('cmake.buildAll')).to.be.eq(0);
|
||||
|
|
|
@ -6,7 +6,7 @@ import * as path from 'path';
|
|||
import * as vscode from 'vscode';
|
||||
import CMakeTools from '@cmt/cmake-tools';
|
||||
|
||||
suite('[Environment Variables in Variants]', async () => {
|
||||
suite('Environment Variables in Variants', async () => {
|
||||
let testEnv: DefaultEnvironment;
|
||||
let cmakeTools: CMakeTools;
|
||||
|
||||
|
@ -25,7 +25,6 @@ suite('[Environment Variables in Variants]', async () => {
|
|||
await clearExistingKitConfigurationFile();
|
||||
|
||||
const kit = await getFirstSystemKit(cmakeTools);
|
||||
console.log("Using following kit in next test: ", kit.name);
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', kit.name);
|
||||
|
||||
testEnv.projectFolder.buildDirectory.clear();
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'module-alias/register';
|
|||
import * as path from 'path';
|
||||
import * as Mocha from 'mocha';
|
||||
import * as glob from 'glob';
|
||||
import { Logger } from '@cmt/logging';
|
||||
|
||||
export function run(): Promise<void> {
|
||||
// Create the mocha test
|
||||
|
@ -21,11 +22,23 @@ export function run(): Promise<void> {
|
|||
}
|
||||
|
||||
// Add files to the test suite
|
||||
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
|
||||
const regex = process.env.TEST_FILTER ? new RegExp(process.env.TEST_FILTER) : /.*/;
|
||||
files.forEach(f => {
|
||||
if (regex.test(f)) {
|
||||
mocha.addFile(path.resolve(testsRoot, f));
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
// Run the mocha test
|
||||
mocha.timeout(100000);
|
||||
|
||||
// Log the name of each test before it starts.
|
||||
const beforeEach: Mocha.Func = function (this: Mocha.Context, done: Mocha.Done) {
|
||||
Logger.logTestName(this.currentTest?.parent?.title, this.currentTest?.title);
|
||||
done();
|
||||
};
|
||||
mocha.rootHooks({beforeEach});
|
||||
mocha.run(failures => {
|
||||
if (failures > 0) {
|
||||
e(new Error(`${failures} tests failed.`));
|
||||
|
|
|
@ -1,63 +1,56 @@
|
|||
[
|
||||
{
|
||||
"name": "Test Toolchain",
|
||||
"toolchainFile": "${workspaceFolder}\\test-toolchain.cmake"
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Mingw - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "MinGW Makefiles"
|
||||
},
|
||||
"environmentVariables": {
|
||||
"PATH": "${env:PATH};C:\\MinGW\\bin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
} ,
|
||||
{
|
||||
"name": "Generator switch test GCC no generator - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
}
|
||||
} ,
|
||||
{
|
||||
"name": "Generator switch test GCC Make",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Unix Makefiles"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC no generator",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "Test Toolchain",
|
||||
"toolchainFile": "${workspaceFolder}\\test-toolchain.cmake"
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Make",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Unix Makefiles"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC no generator",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86",
|
||||
"preferredGenerator": {
|
||||
"name": "Visual Studio 16 2019",
|
||||
"platform": "win32",
|
||||
"toolset": "host=x86"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019 Ninja",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86",
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019 no generator",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -16,7 +16,11 @@ async function main() {
|
|||
|
||||
const launchArgs = ["--disable-extensions", testWorkspace];
|
||||
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = { "CMT_TESTING": "1" };
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"TEST_FILTER": process.env.TEST_FILTER ?? ".*"
|
||||
};
|
||||
|
||||
// Download VS Code, unzip it and run the integration test
|
||||
await runTests({ launchArgs, extensionDevelopmentPath, extensionTestsPath, extensionTestsEnv });
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { fs } from '@cmt/pr';
|
||||
import { TestProgramResult } from '@test/helpers/testprogram/test-program-result';
|
||||
import { logFilePath } from '@cmt/logging';
|
||||
import {
|
||||
clearExistingKitConfigurationFile,
|
||||
DefaultEnvironment,
|
||||
|
@ -12,15 +11,7 @@ import * as path from 'path';
|
|||
import * as vscode from 'vscode';
|
||||
import CMakeTools from '@cmt/cmake-tools';
|
||||
|
||||
let workername: string = process.platform;
|
||||
|
||||
if (process.env.APPVEYOR_BUILD_WORKER_IMAGE) {
|
||||
workername = process.env.APPVEYOR_BUILD_WORKER_IMAGE;
|
||||
}
|
||||
|
||||
if (process.env.TRAVIS_OS_NAME) {
|
||||
workername = process.env.TRAVIS_OS_NAME;
|
||||
}
|
||||
const workername: string = process.platform;
|
||||
|
||||
suite('Build using Kits and Variants', async () => {
|
||||
let testEnv: DefaultEnvironment;
|
||||
|
@ -42,15 +33,14 @@ suite('Build using Kits and Variants', async () => {
|
|||
// This test will use all on the same kit.
|
||||
// No rescan of the tools is needed
|
||||
// No new kit selection is needed
|
||||
await vscode.commands.executeCommand('cmake.scanForKits');
|
||||
await clearExistingKitConfigurationFile();
|
||||
await vscode.commands.executeCommand('cmake.scanForKits');
|
||||
});
|
||||
|
||||
setup(async function (this: Mocha.Context) {
|
||||
this.timeout(100000);
|
||||
|
||||
const kit = await getFirstSystemKit(cmakeTools);
|
||||
console.log("Using following kit in next test: ", kit.name);
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', kit.name);
|
||||
testEnv.projectFolder.buildDirectory.clear();
|
||||
});
|
||||
|
@ -58,17 +48,6 @@ suite('Build using Kits and Variants', async () => {
|
|||
teardown(async function (this: Mocha.Context) {
|
||||
this.timeout(100000);
|
||||
await vscode.workspace.getConfiguration('cmake', vscode.workspace.workspaceFolders![0].uri).update('useCMakePresets', 'auto');
|
||||
const logPath = logFilePath();
|
||||
testEnv.clean();
|
||||
if (await fs.exists(logPath)) {
|
||||
if (this.currentTest?.state === "failed") {
|
||||
const logContent = await fs.readFile(logPath);
|
||||
logContent.toString().split('\n').forEach(line => {
|
||||
console.log(line);
|
||||
});
|
||||
}
|
||||
await fs.writeFile(logPath, "");
|
||||
}
|
||||
});
|
||||
|
||||
suiteTeardown(async () => {
|
||||
|
@ -117,7 +96,7 @@ suite('Build using Kits and Variants', async () => {
|
|||
// Select compiler build node dependent
|
||||
const os_compilers: { [osName: string]: { kitLabel: RegExp; compiler: string }[] } = {
|
||||
linux: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }],
|
||||
win32: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^VisualStudio/, compiler: 'MSVC' }]
|
||||
win32: [{ kitLabel: /^Visual Studio/, compiler: 'MSVC' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }]
|
||||
};
|
||||
if (!(workername in os_compilers)) {
|
||||
this.skip();
|
||||
|
@ -143,7 +122,7 @@ suite('Build using Kits and Variants', async () => {
|
|||
// Select compiler build node dependent
|
||||
const os_compilers: { [osName: string]: { kitLabel: RegExp; compiler: string }[] } = {
|
||||
linux: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }],
|
||||
win32: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^VisualStudio/, compiler: 'MSVC' }]
|
||||
win32: [{ kitLabel: /^Visual Studio/, compiler: 'MSVC' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }]
|
||||
};
|
||||
if (!(workername in os_compilers)) {
|
||||
this.skip();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { fs } from '@cmt/pr';
|
||||
import { TestProgramResult } from '@test/helpers/testprogram/test-program-result';
|
||||
import { logFilePath } from '@cmt/logging';
|
||||
import {
|
||||
clearExistingKitConfigurationFile,
|
||||
DefaultEnvironment,
|
||||
|
@ -40,17 +39,6 @@ suite('Build using Presets', async () => {
|
|||
teardown(async function (this: Mocha.Context) {
|
||||
this.timeout(100000);
|
||||
await vscode.workspace.getConfiguration('cmake', vscode.workspace.workspaceFolders![0].uri).update('useCMakePresets', 'auto');
|
||||
const logPath = logFilePath();
|
||||
testEnv.clean();
|
||||
if (await fs.exists(logPath)) {
|
||||
if (this.currentTest?.state === "failed") {
|
||||
const logContent = await fs.readFile(logPath);
|
||||
logContent.toString().split('\n').forEach(line => {
|
||||
console.log(line);
|
||||
});
|
||||
}
|
||||
await fs.writeFile(logPath, "");
|
||||
}
|
||||
});
|
||||
|
||||
suiteTeardown(async () => {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { DefaultEnvironment, expect, getFirstSystemKit } from '@test/util';
|
|||
import * as vscode from 'vscode';
|
||||
import CMakeTools from '@cmt/cmake-tools';
|
||||
|
||||
suite('[Debug/Launch interface using Kits and Variants]', async () => {
|
||||
suite('Debug/Launch interface using Kits and Variants', async () => {
|
||||
let testEnv: DefaultEnvironment;
|
||||
let cmakeTools: CMakeTools;
|
||||
|
||||
|
@ -18,7 +18,6 @@ suite('[Debug/Launch interface using Kits and Variants]', async () => {
|
|||
await vscode.workspace.getConfiguration('cmake', vscode.workspace.workspaceFolders![0].uri).update('useCMakePresets', 'never');
|
||||
|
||||
const kit = await getFirstSystemKit(cmakeTools);
|
||||
console.log("Using following kit in next test: ", kit.name);
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', kit.name);
|
||||
testEnv.projectFolder.buildDirectory.clear();
|
||||
expect(await vscode.commands.executeCommand('cmake.build')).to.be.eq(0);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { DefaultEnvironment, expect } from '@test/util';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
suite('[Debug/Launch interface using Presets]', async () => {
|
||||
suite('Debug/Launch interface using Presets', async () => {
|
||||
let testEnv: DefaultEnvironment;
|
||||
|
||||
setup(async function (this: Mocha.Context) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import * as path from 'path';
|
|||
import * as vscode from 'vscode';
|
||||
import CMakeTools from '@cmt/cmake-tools';
|
||||
|
||||
suite('[Environment Variables in Variants]', async () => {
|
||||
suite('Environment Variables in Variants', async () => {
|
||||
let testEnv: DefaultEnvironment;
|
||||
let cmakeTools: CMakeTools;
|
||||
|
||||
|
@ -27,7 +27,6 @@ suite('[Environment Variables in Variants]', async () => {
|
|||
await clearExistingKitConfigurationFile();
|
||||
|
||||
const kit = await getFirstSystemKit(cmakeTools);
|
||||
console.log("Using following kit in next test: ", kit.name);
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', kit.name);
|
||||
|
||||
testEnv.projectFolder.buildDirectory.clear();
|
||||
|
|
|
@ -3,7 +3,7 @@ import { CMakeCache } from '@cmt/cache';
|
|||
import { DefaultEnvironment, expect } from '@test/util';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
suite('[Environment Variables in Presets]', async () => {
|
||||
suite('Environment Variables in Presets', async () => {
|
||||
let testEnv: DefaultEnvironment;
|
||||
|
||||
setup(async function (this: Mocha.Context) {
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'module-alias/register';
|
|||
import * as path from 'path';
|
||||
import * as Mocha from 'mocha';
|
||||
import * as glob from 'glob';
|
||||
import { Logger } from '@cmt/logging';
|
||||
|
||||
export function run(): Promise<void> {
|
||||
// Create the mocha test
|
||||
|
@ -20,11 +21,23 @@ export function run(): Promise<void> {
|
|||
}
|
||||
|
||||
// Add files to the test suite
|
||||
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
|
||||
const regex = process.env.TEST_FILTER ? new RegExp(process.env.TEST_FILTER) : /.*/;
|
||||
files.forEach(f => {
|
||||
if (regex.test(f)) {
|
||||
mocha.addFile(path.resolve(testsRoot, f));
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
// Run the mocha test
|
||||
mocha.timeout(100000);
|
||||
|
||||
// Log the name of each test before it starts.
|
||||
const beforeEach: Mocha.Func = function (this: Mocha.Context, done: Mocha.Done) {
|
||||
Logger.logTestName(this.currentTest?.parent?.title, this.currentTest?.title);
|
||||
done();
|
||||
};
|
||||
mocha.rootHooks({beforeEach});
|
||||
mocha.run(failures => {
|
||||
if (failures > 0) {
|
||||
e(new Error(`${failures} tests failed.`));
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[
|
||||
{
|
||||
"name": "Inside1"
|
||||
},
|
||||
{
|
||||
"name": "Inside2"
|
||||
}
|
||||
]
|
||||
{
|
||||
"name": "Inside1"
|
||||
},
|
||||
{
|
||||
"name": "Inside2"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,63 +1,56 @@
|
|||
[
|
||||
{
|
||||
"name": "Test Toolchain",
|
||||
"toolchainFile": "${workspaceFolder}\\test-toolchain.cmake"
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Mingw - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "MinGW Makefiles"
|
||||
},
|
||||
"environmentVariables": {
|
||||
"PATH": "${env:PATH};C:\\MinGW\\bin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
} ,
|
||||
{
|
||||
"name": "Generator switch test GCC no generator - Win",
|
||||
"compilers": {
|
||||
"CXX": "C:\\MinGW\\bin\\g++.exe",
|
||||
"C": "C:\\MinGW\\bin\\gcc.exe"
|
||||
}
|
||||
} ,
|
||||
{
|
||||
"name": "Generator switch test GCC Make",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Unix Makefiles"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC no generator",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "Test Toolchain",
|
||||
"toolchainFile": "${workspaceFolder}\\test-toolchain.cmake"
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Make",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Unix Makefiles"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC Ninja",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
},
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test GCC no generator",
|
||||
"compilers": {
|
||||
"CXX": "g++",
|
||||
"C": "gcc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86",
|
||||
"preferredGenerator": {
|
||||
"name": "Visual Studio 16 2019",
|
||||
"platform": "win32",
|
||||
"toolset": "host=x86"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019 Ninja",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86",
|
||||
"preferredGenerator": {
|
||||
"name": "Ninja"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generator switch test VS 2019 no generator",
|
||||
"visualStudio": "VisualStudio.16.0",
|
||||
"visualStudioArchitecture": "x86"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -16,7 +16,11 @@ async function main() {
|
|||
|
||||
const launchArgs = ["--disable-extensions", testWorkspace];
|
||||
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = { "CMT_TESTING": "1" };
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"TEST_FILTER": process.env.TEST_FILTER ?? ".*"
|
||||
};
|
||||
|
||||
// Download VS Code, unzip it and run the integration test
|
||||
await runTests({ launchArgs, extensionDevelopmentPath, extensionTestsPath, extensionTestsEnv });
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { CMakeTools, ConfigureTrigger } from '@cmt/cmake-tools';
|
||||
import { fs } from '@cmt/pr';
|
||||
import { TestProgramResult } from '@test/helpers/testprogram/test-program-result';
|
||||
import { logFilePath } from '@cmt/logging';
|
||||
import { ExtensionConfigurationSettings } from '@cmt/config';
|
||||
import {
|
||||
clearExistingKitConfigurationFile,
|
||||
DefaultEnvironment,
|
||||
|
@ -13,15 +13,7 @@ import {
|
|||
} from '@test/util';
|
||||
import * as path from 'path';
|
||||
|
||||
let workername: string = process.platform;
|
||||
|
||||
if (process.env.APPVEYOR_BUILD_WORKER_IMAGE) {
|
||||
workername = process.env.APPVEYOR_BUILD_WORKER_IMAGE;
|
||||
}
|
||||
|
||||
if (process.env.TRAVIS_OS_NAME) {
|
||||
workername = process.env.TRAVIS_OS_NAME;
|
||||
}
|
||||
const workername: string = process.platform;
|
||||
|
||||
suite('Build', async () => {
|
||||
let cmt: CMakeTools;
|
||||
|
@ -50,7 +42,6 @@ suite('Build', async () => {
|
|||
|
||||
cmt = await CMakeTools.create(testEnv.vsContext, testEnv.wsContext);
|
||||
const kit = await getFirstSystemKit(cmt);
|
||||
console.log("Using following kit in next test: ", kit.name);
|
||||
await cmt.setKit(kit);
|
||||
testEnv.projectFolder.buildDirectory.clear();
|
||||
});
|
||||
|
@ -58,17 +49,6 @@ suite('Build', async () => {
|
|||
teardown(async function (this: Mocha.Context) {
|
||||
this.timeout(100000);
|
||||
await cmt.asyncDispose();
|
||||
const logPath = logFilePath();
|
||||
testEnv.clean();
|
||||
if (await fs.exists(logPath)) {
|
||||
if (this.currentTest?.state === "failed") {
|
||||
const logContent = await fs.readFile(logPath);
|
||||
logContent.toString().split('\n').forEach(line => {
|
||||
console.log(line);
|
||||
});
|
||||
}
|
||||
await fs.writeFile(logPath, "");
|
||||
}
|
||||
});
|
||||
|
||||
suiteTeardown(async () => {
|
||||
|
@ -130,7 +110,7 @@ suite('Build', async () => {
|
|||
// Select compiler build node dependent
|
||||
const os_compilers: { [osName: string]: { kitLabel: RegExp; compiler: string }[] } = {
|
||||
linux: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }],
|
||||
win32: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^VisualStudio/, compiler: 'MSVC' }]
|
||||
win32: [{ kitLabel: /^Visual Studio/, compiler: 'MSVC' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }]
|
||||
};
|
||||
if (!(workername in os_compilers)) {
|
||||
this.skip();
|
||||
|
@ -159,8 +139,8 @@ suite('Build', async () => {
|
|||
{ kitLabel: /^Generator switch test GCC no generator$/, generator: '' }
|
||||
],
|
||||
win32: [
|
||||
{ kitLabel: /^Generator switch test GCC Mingw - Win/, generator: 'MinGW Makefiles' },
|
||||
{ kitLabel: /^Generator switch test GCC no generator - Win/, generator: '' }
|
||||
{kitLabel: /^Generator switch test VS 2019/, generator: 'Visual Studio 16 2019'},
|
||||
{kitLabel: /^Generator switch test VS 2019 no generator/, generator: ''}
|
||||
]
|
||||
};
|
||||
if (!(workername in os_compilers)) {
|
||||
|
@ -208,7 +188,7 @@ suite('Build', async () => {
|
|||
// Select compiler build node dependent
|
||||
const os_compilers: { [osName: string]: { kitLabel: RegExp; compiler: string }[] } = {
|
||||
linux: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }],
|
||||
win32: [{ kitLabel: /^GCC \d/, compiler: 'GNU' }, { kitLabel: /^VisualStudio/, compiler: 'MSVC' }]
|
||||
win32: [{ kitLabel: /^Visual Studio/, compiler: 'MSVC' }, { kitLabel: /^Clang \d/, compiler: 'Clang' }]
|
||||
};
|
||||
if (!(workername in os_compilers)) {
|
||||
this.skip();
|
||||
|
@ -237,8 +217,8 @@ suite('Build', async () => {
|
|||
{ kitLabel: /^Generator switch test GCC Ninja$/, generator: 'Ninja' }
|
||||
],
|
||||
win32: [
|
||||
{ kitLabel: /^Generator switch test GCC Mingw - Win/, generator: 'MinGW Makefiles' },
|
||||
{ kitLabel: /^Generator switch test GCC Ninja - Win/, generator: 'Ninja' }
|
||||
{kitLabel: /^Generator switch test VS 2019/, generator: 'Visual Studio 16 2019'},
|
||||
{kitLabel: /^Generator switch test VS 2019 Ninja/, generator: 'Ninja'}
|
||||
]
|
||||
};
|
||||
if (!(workername in os_compilers)) {
|
||||
|
@ -271,8 +251,8 @@ suite('Build', async () => {
|
|||
{ kitLabel: /^Generator switch test GCC Ninja$/, generator: 'Ninja' }
|
||||
],
|
||||
win32: [
|
||||
{ kitLabel: /^Generator switch test GCC Mingw - Win/, generator: 'MinGW Makefiles' },
|
||||
{ kitLabel: /^Generator switch test GCC Ninja - Win/, generator: 'Ninja' }
|
||||
{kitLabel: /^Generator switch test VS 2019/, generator: 'Visual Studio 16 2019'},
|
||||
{kitLabel: /^Generator switch test VS 2019 no generator/, generator: 'Ninja'}
|
||||
]
|
||||
};
|
||||
if (!(workername in os_compilers)) {
|
||||
|
@ -333,10 +313,16 @@ suite('Build', async () => {
|
|||
|
||||
test('Copy compile_commands.json to a pre-determined path', async () => {
|
||||
expect(await fs.exists(compdb_cp_path), 'File shouldn\'t be there!').to.be.false;
|
||||
let retc = await cmt.configureInternal(ConfigureTrigger.runTests);
|
||||
const newSettings: Partial<ExtensionConfigurationSettings> = {};
|
||||
if (process.platform === 'win32') {
|
||||
newSettings.generator = 'Ninja'; // VS generators don't create compile_commands.json
|
||||
testEnv.config.updatePartial(newSettings);
|
||||
}
|
||||
let retc = await cmt.cleanConfigure(ConfigureTrigger.runTests);
|
||||
expect(retc).to.eq(0);
|
||||
expect(await fs.exists(compdb_cp_path), 'File still shouldn\'t be there').to.be.false;
|
||||
testEnv.config.updatePartial({ copyCompileCommands: compdb_cp_path });
|
||||
newSettings.copyCompileCommands = compdb_cp_path;
|
||||
testEnv.config.updatePartial(newSettings);
|
||||
retc = await cmt.configureInternal(ConfigureTrigger.runTests);
|
||||
expect(retc).to.eq(0);
|
||||
expect(await fs.exists(compdb_cp_path), 'File wasn\'t copied').to.be.true;
|
||||
|
|
|
@ -5,7 +5,7 @@ import { DefaultEnvironment, expect, getFirstSystemKit } from '@test/util';
|
|||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
suite('[Debug/Launch interface]', async () => {
|
||||
suite('Debug/Launch interface', async () => {
|
||||
let cmt: CMakeTools;
|
||||
let testEnv: DefaultEnvironment;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { CMakeTools } from '@cmt/cmake-tools';
|
|||
import { clearExistingKitConfigurationFile, DefaultEnvironment, expect, getFirstSystemKit } from '@test/util';
|
||||
import * as path from 'path';
|
||||
|
||||
suite('[Environment]', async () => {
|
||||
suite('Environment', async () => {
|
||||
let cmt: CMakeTools;
|
||||
let testEnv: DefaultEnvironment;
|
||||
|
||||
|
|
|
@ -1,350 +0,0 @@
|
|||
/* eslint-disable no-unused-expressions */
|
||||
import { CMakeTools } from '@cmt/cmake-tools';
|
||||
import { Kit, scanForKits } from '@cmt/kit';
|
||||
import { clearExistingKitConfigurationFile, DefaultEnvironment, expect } from '@test/util';
|
||||
import * as path from 'path';
|
||||
|
||||
interface KitEnvironment {
|
||||
defaultKit: RegExp;
|
||||
excludeKit?: RegExp;
|
||||
expectedDefaultGenerator: RegExp;
|
||||
path?: string[];
|
||||
isVsNewerThan14?: boolean;
|
||||
}
|
||||
|
||||
let workername = process.env.APPVEYOR_BUILD_WORKER_IMAGE;
|
||||
|
||||
if (process.env.TRAVIS_OS_NAME) {
|
||||
workername = process.env.TRAVIS_OS_NAME;
|
||||
}
|
||||
|
||||
if (workername === undefined) {
|
||||
workername = process.platform;
|
||||
}
|
||||
|
||||
const DEFAULT_VS_KITS: KitEnvironment[] = [
|
||||
// Visual Studio 2017
|
||||
{
|
||||
defaultKit: /^Visual Studio Community 2017/,
|
||||
excludeKit: /Preview/,
|
||||
expectedDefaultGenerator: /^Visual Studio 15 2017/,
|
||||
isVsNewerThan14: true
|
||||
},
|
||||
{
|
||||
defaultKit: /^Visual Studio Community 2017 Preview/,
|
||||
expectedDefaultGenerator: /^Visual Studio 15 2017/,
|
||||
isVsNewerThan14: true
|
||||
},
|
||||
{
|
||||
defaultKit: /^Visual Studio Professional 2017/,
|
||||
excludeKit: /Preview/,
|
||||
expectedDefaultGenerator: /Visual Studio 15 2017/,
|
||||
isVsNewerThan14: true
|
||||
},
|
||||
{
|
||||
defaultKit: /^Visual Studio Professional 2017 Preview/,
|
||||
expectedDefaultGenerator: /^Visual Studio 15 2017/,
|
||||
isVsNewerThan14: true
|
||||
},
|
||||
{
|
||||
defaultKit: /^Visual Studio Enterprise 2017/,
|
||||
excludeKit: /Preview/,
|
||||
expectedDefaultGenerator: /^Visual Studio 15 2017/,
|
||||
isVsNewerThan14: true
|
||||
},
|
||||
{
|
||||
defaultKit: /^Visual Studio Enterprise 2017 Preview/,
|
||||
expectedDefaultGenerator: /^Visual Studio 15 2017/,
|
||||
isVsNewerThan14: true
|
||||
},
|
||||
|
||||
// Visual Studio 2015
|
||||
{
|
||||
defaultKit: /^VisualStudio.14.0/,
|
||||
expectedDefaultGenerator: /^Visual Studio 14 2015/,
|
||||
path: [''],
|
||||
isVsNewerThan14: false
|
||||
},
|
||||
|
||||
// Visual Studio 2012
|
||||
{
|
||||
defaultKit: /^VisualStudio.11.0/,
|
||||
expectedDefaultGenerator: /^Visual Studio 11 2012/,
|
||||
path: [''],
|
||||
isVsNewerThan14: false
|
||||
}
|
||||
];
|
||||
|
||||
const DEFAULT_CYGWIN_KITS: KitEnvironment[] =
|
||||
[{ defaultKit: /^GCC/, expectedDefaultGenerator: /^Unix Makefiles/, path: ['c:\\cygwin64\\bin'] }];
|
||||
|
||||
const DEFAULT_MINGW_KITS: KitEnvironment[] = [
|
||||
{
|
||||
defaultKit: /^GCC 7.3.0/,
|
||||
expectedDefaultGenerator: /^MinGW Makefiles/,
|
||||
path: [
|
||||
'C:\\Program Files\\mingw-w64\\x86_64-7.3.0-posix-seh-rt_v5-rev0\\mingw64\\bin',
|
||||
'C:\\mingw-w64\\x86_64-7.3.0-posix-seh-rt_v5-rev0\\mingw64\\bin'
|
||||
]
|
||||
},
|
||||
{
|
||||
defaultKit: /^GCC 7.2.0/,
|
||||
expectedDefaultGenerator: /^MinGW Makefiles/,
|
||||
path: [
|
||||
'C:\\Program Files\\mingw-w64\\x86_64-7.2.0-posix-seh-rt_v5-rev1\\mingw64\\bin',
|
||||
'C:\\mingw-w64\\x86_64-7.2.0-posix-seh-rt_v5-rev1\\mingw64\\bin'
|
||||
]
|
||||
},
|
||||
{
|
||||
defaultKit: /^GCC 6.3.0/,
|
||||
expectedDefaultGenerator: /^MinGW Makefiles/,
|
||||
path: [
|
||||
'C:\\Program Files\\mingw-w64\\x86_64-6.3.0-posix-seh-rt_v5-rev1\\mingw64\\bin',
|
||||
'C:\\mingw-w64\\x86_64-6.3.0-posix-seh-rt_v5-rev1\\mingw64\\bin'
|
||||
]
|
||||
},
|
||||
{ defaultKit: /^GCC 5.3.0/, expectedDefaultGenerator: /^MinGW Makefiles/, path: ['C:\\MinGW\\bin'] }
|
||||
];
|
||||
|
||||
const DEFAULT_WINDOWS_KITS: KitEnvironment[]
|
||||
= DEFAULT_VS_KITS.concat(DEFAULT_CYGWIN_KITS, DEFAULT_MINGW_KITS);
|
||||
|
||||
const KITS_BY_PLATFORM: { [osName: string]: KitEnvironment[] } = {
|
||||
['win32']: DEFAULT_WINDOWS_KITS.concat([{
|
||||
defaultKit: /^Clang .* for MSVC/,
|
||||
expectedDefaultGenerator: /^Unix Makefiles/,
|
||||
path: [' C:\\Program Files\\LLVM\\bin']
|
||||
}]),
|
||||
['Visual Studio 2017']: DEFAULT_VS_KITS,
|
||||
['Visual Studio 2017 Preview']: DEFAULT_VS_KITS,
|
||||
['Visual Studio 2015']: DEFAULT_VS_KITS,
|
||||
['linux']: [
|
||||
{ defaultKit: /Clang/, expectedDefaultGenerator: /Unix Makefiles/ },
|
||||
{ defaultKit: /GCC/, expectedDefaultGenerator: /Unix Makefiles/ }
|
||||
],
|
||||
['darwin']: [
|
||||
{ defaultKit: /^Clang/, expectedDefaultGenerator: /^Unix Makefiles/ },
|
||||
{ defaultKit: /^GCC/, expectedDefaultGenerator: /^Unix Makefiles/ }
|
||||
],
|
||||
// This is a special case for travis
|
||||
['osx']: [{
|
||||
defaultKit: /^Clang/,
|
||||
expectedDefaultGenerator: /^Unix Makefiles/,
|
||||
path: [
|
||||
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin',
|
||||
'/Applications/Xcode.app/Contents/Developer/usr/bin',
|
||||
process.env.CMAKE_EXECUTABLE ? path.dirname(process.env.CMAKE_EXECUTABLE)
|
||||
: '/Users/travis/.local/share/CMakeTools/test-cmake-root/3.10.0/bin'
|
||||
]
|
||||
}]
|
||||
};
|
||||
|
||||
interface CMakeContext {
|
||||
cmt: CMakeTools;
|
||||
kits: Kit[];
|
||||
testEnv: DefaultEnvironment;
|
||||
pathBackup: string;
|
||||
buildSystem: KitEnvironment;
|
||||
}
|
||||
|
||||
// This exactly matches the kit name
|
||||
function exactKitCheck(kitName: string, defaultKit: RegExp): boolean {
|
||||
return defaultKit.test(kitName);
|
||||
}
|
||||
|
||||
// This only does a fuzzy check with the ability to exclude kits which have a substring included
|
||||
// in their name.
|
||||
function fuzzyKitCheck(kitName: string, defaultKit: RegExp, excludeKit?: RegExp): boolean {
|
||||
return defaultKit.test(kitName) && (excludeKit ? !excludeKit.test(kitName) : true);
|
||||
}
|
||||
|
||||
// Check if the kit provided by the buildSystem is available
|
||||
// by first doing an exact check and if that didn't yield any
|
||||
// results, a fuzzy check.
|
||||
function isKitAvailable(context: CMakeContext): boolean {
|
||||
const kits = context.kits;
|
||||
return kits.find(kit => exactKitCheck(kit.name, context.buildSystem.defaultKit))
|
||||
? true
|
||||
: kits.find(kit => fuzzyKitCheck(kit.name, context.buildSystem.defaultKit, context.buildSystem.excludeKit))
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
|
||||
// Check if the kit provided by the buildSystem has a preferred generator
|
||||
// defined in the kits file.
|
||||
function isPreferredGeneratorAvailable(context: CMakeContext): boolean {
|
||||
const kits = context.kits;
|
||||
return kits.find(kit => exactKitCheck(kit.name, context.buildSystem.defaultKit) && kit.preferredGenerator ? true
|
||||
: false)
|
||||
? true
|
||||
: kits.find(kit => fuzzyKitCheck(kit.name, context.buildSystem.defaultKit, context.buildSystem.excludeKit)
|
||||
&& kit.preferredGenerator
|
||||
? true
|
||||
: false)
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
|
||||
interface SkipOptions {
|
||||
kitIsNotAvailable?: boolean;
|
||||
preferredGeneratorIsAvailable?: boolean;
|
||||
preferredGeneratorIsNotAvailable?: boolean;
|
||||
}
|
||||
|
||||
function skipTestIf(skipOptions: SkipOptions, testContext: any, context: CMakeContext): void {
|
||||
// Skip if kit is not available (matched by default name)
|
||||
if (skipOptions.kitIsNotAvailable && !isKitAvailable(context)) {
|
||||
testContext.skip();
|
||||
}
|
||||
|
||||
if ((skipOptions.preferredGeneratorIsAvailable && isPreferredGeneratorAvailable(context))
|
||||
|| (skipOptions.preferredGeneratorIsNotAvailable && !isPreferredGeneratorAvailable(context))) {
|
||||
testContext.skip();
|
||||
}
|
||||
}
|
||||
|
||||
function makeExtensionTestSuite(name: string,
|
||||
expectedBuildSystem: KitEnvironment,
|
||||
cb: (context: CMakeContext) => void) {
|
||||
suite(name, () => {
|
||||
const context = { buildSystem: expectedBuildSystem } as CMakeContext;
|
||||
|
||||
suiteSetup(async function (this: Mocha.Context) {
|
||||
this.timeout(100000);
|
||||
context.testEnv = new DefaultEnvironment('test/extension-tests/successful-build/project-folder',
|
||||
'build',
|
||||
'output.txt',
|
||||
context.buildSystem.defaultKit,
|
||||
context.buildSystem.excludeKit);
|
||||
|
||||
context.pathBackup = process.env.PATH!;
|
||||
if (context.buildSystem.path && context.buildSystem.path.length !== 0) {
|
||||
process.env.PATH = context.buildSystem.path.join(process.platform === 'win32' ? ';' : ':');
|
||||
}
|
||||
|
||||
context.cmt = await CMakeTools.create(context.testEnv.vsContext, context.testEnv.wsContext);
|
||||
// This test will use all on the same kit.
|
||||
// No rescan of the tools is needed
|
||||
// No new kit selection is needed
|
||||
await clearExistingKitConfigurationFile();
|
||||
context.kits = await scanForKits(context.cmt);
|
||||
skipTestIf({ kitIsNotAvailable: true }, this, context);
|
||||
});
|
||||
|
||||
setup(async function (this: Mocha.Context) {
|
||||
this.timeout(10000);
|
||||
context.cmt = await CMakeTools.create(context.testEnv.vsContext, context.testEnv.wsContext);
|
||||
const kit = context.kits.find(k => expectedBuildSystem.defaultKit.test(k.name));
|
||||
expect(kit, `Kit required for test "${expectedBuildSystem.defaultKit}" is not available.`).to.not.be.null;
|
||||
await context.cmt.setKit(kit!);
|
||||
context.testEnv.projectFolder.buildDirectory.clear();
|
||||
});
|
||||
|
||||
teardown(async function (this: Mocha.Context) {
|
||||
this.timeout(100000);
|
||||
await context.cmt.asyncDispose();
|
||||
context.testEnv.clean();
|
||||
});
|
||||
|
||||
suiteTeardown(() => {
|
||||
process.env.PATH = context.pathBackup;
|
||||
|
||||
if (context.testEnv) {
|
||||
context.testEnv.teardown();
|
||||
}
|
||||
});
|
||||
|
||||
cb(context);
|
||||
});
|
||||
}
|
||||
|
||||
// Preferred generator selection order is settings.json -> cmake-kit.json -> error
|
||||
KITS_BY_PLATFORM[workername].forEach(buildSystem => {
|
||||
makeExtensionTestSuite(`Preferred generators (${buildSystem.defaultKit})`, buildSystem, (context: CMakeContext) => {
|
||||
const BUILD_TIMEOUT: number = 120000;
|
||||
|
||||
// This test is only valid for kits which have at least one preferred generator defined.
|
||||
test(`Use preferred generator from kit file (${buildSystem.defaultKit})`,
|
||||
async function (this: Mocha.Context) {
|
||||
skipTestIf({ preferredGeneratorIsNotAvailable: true }, this, context);
|
||||
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);
|
||||
expect(context.testEnv.errorMessagesQueue.length).to.eql(0);
|
||||
});
|
||||
|
||||
test(`Use preferred generator from settings file (${buildSystem.defaultKit})`,
|
||||
async function (this: Mocha.Context) {
|
||||
this.timeout(BUILD_TIMEOUT);
|
||||
|
||||
context.testEnv.config.updatePartial({
|
||||
preferredGenerators: [
|
||||
'NMake Makefiles',
|
||||
'Unix Makefiles',
|
||||
'MinGW Makefiles'
|
||||
]
|
||||
});
|
||||
expect(await context.cmt.build()).to.eql(0);
|
||||
const result = await context.testEnv.result.getResultAsJson();
|
||||
|
||||
expect(result['cmake-generator'])
|
||||
.to.be.match((context.buildSystem.isVsNewerThan14 === true)
|
||||
? /^NMake Makefiles/
|
||||
: context.buildSystem.expectedDefaultGenerator);
|
||||
|
||||
expect(context.testEnv.errorMessagesQueue.length).to.eql(0);
|
||||
});
|
||||
|
||||
// This test is NOT valid for kits which have any preferred generator defined
|
||||
// since we expect CMT to reject the build.
|
||||
test(`Reject invalid preferred generator in settings file (${buildSystem.defaultKit})`,
|
||||
async function (this: Mocha.Context) {
|
||||
skipTestIf({ preferredGeneratorIsAvailable: true }, this, context);
|
||||
this.timeout(BUILD_TIMEOUT);
|
||||
|
||||
context.testEnv.config.updatePartial({ preferredGenerators: ['BlaBla'] });
|
||||
await expect(context.cmt.build()).to.eventually.be.rejected;
|
||||
|
||||
expect(context.testEnv.errorMessagesQueue.length).to.be.gte(1);
|
||||
expect(context.testEnv.errorMessagesQueue[0])
|
||||
.to.be.contains('Unable to determine what CMake generator to use.');
|
||||
});
|
||||
|
||||
// This test verifies that kits without any preferred generator defined
|
||||
// are still able to pick one preferred generator from the default list
|
||||
// (Ninja + Unix Makefiles)
|
||||
test(`Select default if all \'preferredGenerators\' fields are empty (${buildSystem.defaultKit})`,
|
||||
async function (this: Mocha.Context) {
|
||||
skipTestIf({ preferredGeneratorIsAvailable: true }, this, context);
|
||||
this.timeout(BUILD_TIMEOUT);
|
||||
context.testEnv.config.updatePartial({ preferredGenerators: [] });
|
||||
expect(await context.cmt.build()).to.eql(0);
|
||||
|
||||
const result = await context.testEnv.result.getResultAsJson();
|
||||
// "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]);
|
||||
});
|
||||
|
||||
test(`Use preferred generator from settings or kit file (${buildSystem.defaultKit})`,
|
||||
async function (this: Mocha.Context) {
|
||||
this.timeout(BUILD_TIMEOUT);
|
||||
|
||||
context.testEnv.config.updatePartial({ preferredGenerators: ['Unix Makefiles', 'MinGW Makefiles'] });
|
||||
expect(await context.cmt.build()).to.eql(0);
|
||||
const result = await context.testEnv.result.getResultAsJson();
|
||||
expect(result['cmake-generator']).to.match(buildSystem.expectedDefaultGenerator);
|
||||
expect(context.testEnv.errorMessagesQueue.length)
|
||||
.to.eql(0, 'Wrong message ' + context.testEnv.errorMessagesQueue[0]);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -2,7 +2,10 @@ import { scanForKits } from '@cmt/kit';
|
|||
import { fs } from '@cmt/pr';
|
||||
import { expect } from '@test/util';
|
||||
|
||||
suite('[MinGW Tests]', async () => {
|
||||
suite('MinGW Tests', async () => {
|
||||
|
||||
// TODO: this test needs some work
|
||||
|
||||
const mingw_dirs: string[] = ['C:\\Qt\\Tools\\mingw492_32', 'C:\\mingw-w64\\x86_64-7.2.0-posix-seh-rt_v5-rev1\\mingw64'];
|
||||
|
||||
setup(async function (this: Mocha.Context) {
|
||||
|
@ -12,7 +15,8 @@ suite('[MinGW Tests]', async () => {
|
|||
test('Test scan of mingw', async () => {
|
||||
const kits = await scanForKits(undefined, {
|
||||
scanDirs: [],
|
||||
minGWSearchDirs: mingw_dirs
|
||||
minGWSearchDirs: mingw_dirs,
|
||||
ignorePath: true
|
||||
});
|
||||
const is_kit_MinGW_present = kits.find(kit => kit.name.indexOf('GCC for i686-w64-mingw32 4.9.2') >= 0) ? true : false;
|
||||
const is_kit_MinGW_w64_present = kits.find(kit => kit.name.indexOf('GCC for x86_64-w64-mingw32 7.2.0') >= 0) ? true : false;
|
||||
|
|
|
@ -6,15 +6,12 @@ import { readKitsFile, kitsForWorkspaceDirectory, getAdditionalKits, USER_KITS_F
|
|||
import { platformNormalizePath } from '@cmt/util';
|
||||
import { DefaultEnvironment, expect } from '@test/util';
|
||||
|
||||
suite('[Toolchain Substitution]', async () => {
|
||||
suite('Toolchain Substitution', async () => {
|
||||
let cmt: CMakeTools;
|
||||
let testEnv: DefaultEnvironment;
|
||||
|
||||
setup(async function (this: Mocha.Context) {
|
||||
this.timeout(100000);
|
||||
if (process.platform === 'win32') {
|
||||
this.skip();
|
||||
}
|
||||
|
||||
testEnv = new DefaultEnvironment('test/extension-tests/successful-build/project-folder', 'build', 'output.txt');
|
||||
cmt = await CMakeTools.create(testEnv.vsContext, testEnv.wsContext);
|
||||
|
|
|
@ -6,7 +6,7 @@ import { objectPairs, platformNormalizePath, makeHashString } from '@cmt/util';
|
|||
import { clearExistingKitConfigurationFile, DefaultEnvironment, expect, getFirstSystemKit } from '@test/util';
|
||||
import * as path from 'path';
|
||||
|
||||
suite('[Variable Substitution]', async () => {
|
||||
suite('Variable Substitution', async () => {
|
||||
let cmt: CMakeTools;
|
||||
let testEnv: DefaultEnvironment;
|
||||
|
||||
|
@ -76,10 +76,8 @@ suite('[Variable Substitution]', async () => {
|
|||
|
||||
const cacheEntry = cache.get('workspaceHash') as api.CacheEntry;
|
||||
expect(cacheEntry.type).to.eq(api.CacheEntryType.String, '[workspaceHash] unexpected cache entry type');
|
||||
expect(cacheEntry.key)
|
||||
.to.eq('workspaceHash', '[workspaceHash] unexpected cache entry key name');
|
||||
expect(cacheEntry.as<string>())
|
||||
.to.eq(makeHashString(testEnv.projectFolder.location), '[workspaceHash] substitution incorrect');
|
||||
expect(cacheEntry.key).to.eq('workspaceHash', '[workspaceHash] unexpected cache entry key name');
|
||||
expect(cacheEntry.as<string>()).to.eq(makeHashString(testEnv.projectFolder.location), '[workspaceHash] substitution incorrect');
|
||||
expect(typeof cacheEntry.value).to.eq('string', '[workspaceHash] unexpected cache entry value type');
|
||||
}).timeout(100000);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import { clearExistingKitConfigurationFile, DefaultEnvironment, expect, getFirst
|
|||
import { fs } from '@cmt/pr';
|
||||
import * as path from 'path';
|
||||
|
||||
suite('[Environment Variables in Variants]', async () => {
|
||||
suite('Environment Variables in Variants', async () => {
|
||||
let cmt: CMakeTools;
|
||||
let testEnv: DefaultEnvironment;
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
cmake_minimum_required(VERSION 3.0.0)
|
||||
cmake_minimum_required(VERSION 3.15.0)
|
||||
project(FakeOutputGenerator VERSION 0.1.0)
|
||||
|
||||
add_executable(FakeOutputGenerator main.cpp)
|
||||
set_property(TARGET FakeOutputGenerator PROPERTY CXX_STANDARD 98)
|
||||
file(GLOB CONFIG_FILES "configfiles/*.cfg")
|
||||
foreach(config ${CONFIG_FILES})
|
||||
get_filename_component(target "${config}" NAME_WLE)
|
||||
add_executable(${target} main.cpp)
|
||||
set_property(TARGET ${target} PROPERTY CXX_STANDARD 98)
|
||||
install(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
install(FILES ${config} DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
endforeach()
|
||||
|
|
|
@ -19,7 +19,7 @@ int main(int argc, char** argv)
|
|||
{
|
||||
#ifdef _WIN32
|
||||
char buffer[MAX_PATH];
|
||||
DWORD length = GetModuleFileName( NULL, buffer, MAX_PATH);
|
||||
DWORD length = GetModuleFileName(NULL, buffer, MAX_PATH);
|
||||
std::string filePath(buffer);
|
||||
#else
|
||||
std::string filePath = argv[0];
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as rimraf from 'rimraf';
|
||||
|
||||
export class BuildDirectoryHelper {
|
||||
public constructor(private readonly _location: string) {}
|
||||
|
||||
public clear() {
|
||||
if (fs.existsSync(this._location)) {
|
||||
return rimraf.sync(this._location);
|
||||
}
|
||||
return fs.rmSync(this._location, {recursive: true, force: true});
|
||||
}
|
||||
|
||||
public get location(): string {
|
||||
|
|
|
@ -7,7 +7,7 @@ async function main() {
|
|||
// The folder containing the Extension Manifest package.json
|
||||
// Passed to `--extensionDevelopmentPath`
|
||||
const extensionDevelopmentPath = path.resolve(__dirname, '../../../../');
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = { "CMT_TESTING": "1" };
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = { "CMT_TESTING": "1", "CMT_QUIET_CONSOLE": "1" };
|
||||
|
||||
// The path to the extension test runner script
|
||||
const extensionTestsPath = path.resolve(__dirname, './index');
|
||||
|
|
|
@ -7,7 +7,7 @@ async function main() {
|
|||
// The folder containing the Extension Manifest package.json
|
||||
// Passed to `--extensionDevelopmentPath`
|
||||
const extensionDevelopmentPath = path.resolve(__dirname, '../../../../');
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = { "CMT_TESTING": "1" };
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = { "CMT_TESTING": "1", "CMT_QUIET_CONSOLE": "1" };
|
||||
|
||||
// The path to the extension test runner script
|
||||
const extensionTestsPath = path.resolve(__dirname, './index');
|
||||
|
|
|
@ -7,7 +7,7 @@ async function main() {
|
|||
// The folder containing the Extension Manifest package.json
|
||||
// Passed to `--extensionDevelopmentPath`
|
||||
const extensionDevelopmentPath = path.resolve(__dirname, '../../../../');
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = { "CMT_TESTING": "1" };
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = { "CMT_TESTING": "1", "CMT_QUIET_CONSOLE": "1" };
|
||||
|
||||
// The path to the extension test runner script
|
||||
const extensionTestsPath = path.resolve(__dirname, './index');
|
||||
|
|
|
@ -64,7 +64,7 @@ function createConfig(conf: Partial<ExtensionConfigurationSettings>): Configurat
|
|||
return ret;
|
||||
}
|
||||
|
||||
suite('[Configuration]', () => {
|
||||
suite('Configuration', () => {
|
||||
test('Create a read from a configuration', () => {
|
||||
const conf = createConfig({ parallelJobs: 13 });
|
||||
expect(conf.parallelJobs).to.eq(13);
|
||||
|
|
|
@ -7,16 +7,10 @@ import { CMakeGenerator, Kit } from '@cmt/kit';
|
|||
import { makeCodeModelDriverTestsuite } from './driver-codemodel-tests';
|
||||
import { makeDriverTestsuite } from './driver-test';
|
||||
|
||||
async function cmakeFileApiDriverFactory(cmake: CMakeExecutable,
|
||||
config: ConfigurationReader,
|
||||
kit: Kit | null,
|
||||
workspaceFolder: string | null,
|
||||
preconditionHandler: CMakePreconditionProblemSolver,
|
||||
preferredGenerators: CMakeGenerator[]) {
|
||||
const d: CMakeDriver
|
||||
= await CMakeFileApiDriver.create(cmake, config, false, kit, null, null, null, workspaceFolder, preconditionHandler, preferredGenerators);
|
||||
async function cmakeFileApiDriverFactory(cmake: CMakeExecutable, config: ConfigurationReader, kit: Kit | null, workspaceFolder: string | null, preconditionHandler: CMakePreconditionProblemSolver, preferredGenerators: CMakeGenerator[]) {
|
||||
const d: CMakeDriver = await CMakeFileApiDriver.create(cmake, config, false, kit, null, null, null, workspaceFolder, preconditionHandler, preferredGenerators);
|
||||
return d;
|
||||
}
|
||||
|
||||
makeDriverTestsuite(cmakeFileApiDriverFactory);
|
||||
makeCodeModelDriverTestsuite(cmakeFileApiDriverFactory);
|
||||
makeDriverTestsuite('FileAPI', cmakeFileApiDriverFactory);
|
||||
makeCodeModelDriverTestsuite('FileAPI', cmakeFileApiDriverFactory);
|
||||
|
|
|
@ -7,16 +7,10 @@ import { CMakeGenerator, Kit } from '@cmt/kit';
|
|||
import { makeCodeModelDriverTestsuite } from './driver-codemodel-tests';
|
||||
import { makeDriverTestsuite } from './driver-test';
|
||||
|
||||
async function cmakeServerDriverFactory(cmake: CMakeExecutable,
|
||||
config: ConfigurationReader,
|
||||
kit: Kit | null,
|
||||
workspaceFolder: string | null,
|
||||
preconditionHandler: CMakePreconditionProblemSolver,
|
||||
preferredGenerators: CMakeGenerator[]) {
|
||||
const d: CMakeDriver = await cms_driver.CMakeServerClientDriver
|
||||
.create(cmake, config, false, kit, null, null, null, workspaceFolder, preconditionHandler, preferredGenerators);
|
||||
async function cmakeServerDriverFactory(cmake: CMakeExecutable, config: ConfigurationReader, kit: Kit | null, workspaceFolder: string | null, preconditionHandler: CMakePreconditionProblemSolver, preferredGenerators: CMakeGenerator[]) {
|
||||
const d: CMakeDriver = await cms_driver.CMakeServerClientDriver.create(cmake, config, false, kit, null, null, null, workspaceFolder, preconditionHandler, preferredGenerators);
|
||||
return d;
|
||||
}
|
||||
|
||||
makeDriverTestsuite(cmakeServerDriverFactory);
|
||||
makeCodeModelDriverTestsuite(cmakeServerDriverFactory);
|
||||
makeDriverTestsuite('Server', cmakeServerDriverFactory);
|
||||
makeCodeModelDriverTestsuite('Server', cmakeServerDriverFactory);
|
||||
|
|
|
@ -8,7 +8,6 @@ import { expect } from 'chai';
|
|||
import * as chaiString from 'chai-string';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as rimraf from 'rimraf';
|
||||
|
||||
chai.use(chaiString);
|
||||
|
||||
|
@ -22,22 +21,14 @@ function getTestRootFilePath(filename: string): string {
|
|||
}
|
||||
|
||||
function cleanupBuildDir(build_dir: string): boolean {
|
||||
if (fs.existsSync(build_dir)) {
|
||||
rimraf.sync(build_dir);
|
||||
}
|
||||
fs.rmSync(build_dir, {recursive: true, force: true});
|
||||
return !fs.existsSync(build_dir);
|
||||
}
|
||||
|
||||
let driver: CMakeDriver | null = null;
|
||||
|
||||
export function makeCodeModelDriverTestsuite(
|
||||
driver_generator: (cmake: CMakeExecutable,
|
||||
config: ConfigurationReader,
|
||||
kit: Kit | null,
|
||||
workspaceFolder: string | null,
|
||||
preconditionHandler: CMakePreconditionProblemSolver,
|
||||
preferredGenerators: CMakeGenerator[]) => Promise<CMakeDriver>) {
|
||||
suite('CMake-CodeModel-Driver tests', () => {
|
||||
export function makeCodeModelDriverTestsuite(driverName: string, driver_generator: (cmake: CMakeExecutable, config: ConfigurationReader, kit: Kit | null, workspaceFolder: string | null, preconditionHandler: CMakePreconditionProblemSolver, preferredGenerators: CMakeGenerator[]) => Promise<CMakeDriver>) {
|
||||
suite(`CMake CodeModel ${driverName} Driver tests`, () => {
|
||||
const cmakePath: string = process.env.CMAKE_EXECUTABLE ? process.env.CMAKE_EXECUTABLE : 'cmake';
|
||||
const workspacePath: string = 'test/unit-tests/driver/workspace';
|
||||
const root = getTestRootFilePath(workspacePath);
|
||||
|
@ -49,14 +40,13 @@ export function makeCodeModelDriverTestsuite(
|
|||
let kitDefault: Kit;
|
||||
if (process.platform === 'win32') {
|
||||
kitDefault = {
|
||||
name: 'Visual Studio Community 2017 - amd64',
|
||||
visualStudio: 'VisualStudio.15.0',
|
||||
visualStudioArchitecture: 'amd64',
|
||||
preferredGenerator: { name: 'Visual Studio 15 2017', platform: 'x64' }
|
||||
name: 'Visual Studio Community 2019',
|
||||
visualStudio: 'VisualStudio.16.0',
|
||||
visualStudioArchitecture: 'x64',
|
||||
preferredGenerator: {name: 'Visual Studio 16 2019', platform: 'x64', toolset: 'host=x64'}
|
||||
} as Kit;
|
||||
} else {
|
||||
kitDefault
|
||||
= { name: 'GCC', compilers: { C: 'gcc', CXX: 'g++' }, preferredGenerator: { name: 'Unix Makefiles' } } as Kit;
|
||||
kitDefault = { name: 'GCC', compilers: { C: 'gcc', CXX: 'g++' }, preferredGenerator: { name: 'Unix Makefiles' } } as Kit;
|
||||
}
|
||||
|
||||
setup(async function (this: Mocha.Context, done) {
|
||||
|
@ -191,7 +181,7 @@ export function makeCodeModelDriverTestsuite(
|
|||
|
||||
// compile flags for file groups
|
||||
if (process.platform === 'win32') {
|
||||
expect(compile_information!.compileFlags).to.eq('/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 ');
|
||||
expect(compile_information!.compileFlags?.trim()).to.eq('/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1');
|
||||
}
|
||||
}).timeout(90000);
|
||||
|
||||
|
@ -227,7 +217,7 @@ export function makeCodeModelDriverTestsuite(
|
|||
|
||||
// compile flags for file groups
|
||||
if (process.platform === 'win32') {
|
||||
expect(target!.fileGroups![0].compileFlags).to.eq('/DWIN32 /D_WINDOWS /W3 /MDd /Zi /Ob0 /Od /RTC1 ');
|
||||
expect(target!.fileGroups![0].compileFlags?.trim()).to.eq('/DWIN32 /D_WINDOWS /W3 /MDd /Zi /Ob0 /Od /RTC1');
|
||||
}
|
||||
}).timeout(90000);
|
||||
|
||||
|
@ -281,7 +271,11 @@ export function makeCodeModelDriverTestsuite(
|
|||
expect(target!.fileGroups).to.be.not.undefined;
|
||||
const compile_information = target!.fileGroups!.find(t => !!t.language);
|
||||
expect(compile_information).to.be.not.undefined;
|
||||
expect(compile_information!.sources).to.include(sourcefile_name);
|
||||
const sources: string[] = [];
|
||||
compile_information!.sources.forEach(source => {
|
||||
sources.push(path.normalize(source).toLowerCase());
|
||||
});
|
||||
expect(sources).to.include(path.normalize(sourcefile_name).toLowerCase());
|
||||
}
|
||||
}).timeout(90000);
|
||||
});
|
||||
|
|
|
@ -7,9 +7,8 @@ import { expect } from 'chai';
|
|||
import * as chaiString from 'chai-string';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as rimraf from 'rimraf';
|
||||
import { CMakeFileApiDriver } from '@cmt/drivers/cmfileapi-driver';
|
||||
import { CMakeServerClientDriver } from '@cmt/drivers/cms-driver';
|
||||
import { CMakeServerClientDriver, NoGeneratorError } from '@cmt/drivers/cms-driver';
|
||||
|
||||
chai.use(chaiString);
|
||||
|
||||
|
@ -22,21 +21,14 @@ function getTestRootFilePath(filename: string): string {
|
|||
}
|
||||
|
||||
function cleanupBuildDir(build_dir: string): boolean {
|
||||
if (fs.existsSync(build_dir)) {
|
||||
rimraf.sync(build_dir);
|
||||
}
|
||||
fs.rmSync(build_dir, {recursive: true, force: true});
|
||||
return !fs.existsSync(build_dir);
|
||||
}
|
||||
|
||||
export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
||||
config: ConfigurationReader,
|
||||
kit: Kit | null,
|
||||
workspaceFolder: string | null,
|
||||
preconditionHandler: CMakePreconditionProblemSolver,
|
||||
preferredGenerators: CMakeGenerator[]) => Promise<CMakeDriver>) {
|
||||
export function makeDriverTestsuite(driverName: string, driver_generator: (cmake: CMakeExecutable, config: ConfigurationReader, kit: Kit | null, workspaceFolder: string | null, preconditionHandler: CMakePreconditionProblemSolver, preferredGenerators: CMakeGenerator[]) => Promise<CMakeDriver>) {
|
||||
let driver: CMakeDriver | null = null;
|
||||
|
||||
suite('CMake-Driver tests', () => {
|
||||
suite(`CMake ${driverName} driver tests`, () => {
|
||||
const cmakePath: string = process.env.CMAKE_EXECUTABLE ? process.env.CMAKE_EXECUTABLE : 'cmake';
|
||||
const defaultWorkspaceFolder = getTestRootFilePath('test/unit-tests/driver/workspace/test_project');
|
||||
const emptyWorkspaceFolder = getTestRootFilePath('test/unit-tests/driver/workspace/empty_project');
|
||||
|
@ -45,22 +37,21 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
let kitDefault: Kit;
|
||||
if (process.platform === 'win32') {
|
||||
kitDefault = {
|
||||
name: 'Visual Studio Community 2017 - amd64',
|
||||
visualStudio: 'VisualStudio.15.0',
|
||||
visualStudioArchitecture: 'amd64',
|
||||
preferredGenerator: { name: 'Visual Studio 15 2017', platform: 'x64' }
|
||||
name: 'Visual Studio Community 2019 - amd64',
|
||||
visualStudio: 'VisualStudio.16.0',
|
||||
visualStudioArchitecture: 'x64',
|
||||
preferredGenerator: {name: 'Visual Studio 16 2019', platform: 'x64'}
|
||||
} as Kit;
|
||||
} else {
|
||||
kitDefault
|
||||
= { name: 'GCC', compilers: { C: 'gcc', CXX: 'g++' }, preferredGenerator: { name: 'Unix Makefiles' } } as Kit;
|
||||
kitDefault = { name: 'GCC', compilers: { C: 'gcc', CXX: 'g++' }, preferredGenerator: { name: 'Unix Makefiles' } } as Kit;
|
||||
}
|
||||
|
||||
let kitNinja: Kit;
|
||||
if (process.platform === 'win32') {
|
||||
kitNinja = {
|
||||
name: 'Visual Studio Community 2017 - amd64',
|
||||
visualStudio: 'VisualStudio.15.0',
|
||||
visualStudioArchitecture: 'amd64',
|
||||
name: 'Visual Studio Community 2019 - amd64',
|
||||
visualStudio: 'VisualStudio.16.0',
|
||||
visualStudioArchitecture: 'x64',
|
||||
preferredGenerator: { name: 'Ninja' }
|
||||
} as Kit;
|
||||
} else {
|
||||
|
@ -144,8 +135,14 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
|
||||
const kit = { name: 'GCC', preferredGenerator: { name: 'BlaBla' } } as Kit;
|
||||
|
||||
await expect(driver_generator(executable, config, kit, defaultWorkspaceFolder, async () => {}, []))
|
||||
.to.be.rejectedWith('No usable generator found.');
|
||||
try {
|
||||
await driver_generator(executable, config, kit, defaultWorkspaceFolder, async () => {}, []);
|
||||
expect(false, 'configure did not detect the invalid generator').to.be.true;
|
||||
} catch (e) {
|
||||
if (!(e instanceof NoGeneratorError)) {
|
||||
expect(false, `configure threw the wrong Error type: ${typeof(e)}`).to.be.true;
|
||||
}
|
||||
}
|
||||
}).timeout(60000);
|
||||
|
||||
test('Test compiler name reporting for telemetry', async () => {
|
||||
|
@ -202,8 +199,7 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
expect(e).to.be.eq(CMakePreconditionProblems.MissingCMakeListsFile);
|
||||
called = true;
|
||||
};
|
||||
driver
|
||||
= await driver_generator(executable, config, kitDefault, emptyWorkspaceFolder, checkPreconditionHelper, []);
|
||||
driver = await driver_generator(executable, config, kitDefault, emptyWorkspaceFolder, checkPreconditionHelper, []);
|
||||
expect(await driver.cleanConfigure(ConfigureTrigger.runTests, [])).to.be.eq(-2);
|
||||
expect(called).to.be.true;
|
||||
}).timeout(60000);
|
||||
|
@ -217,8 +213,7 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
expect(e).to.be.eq(CMakePreconditionProblems.ConfigureIsAlreadyRunning);
|
||||
called = true;
|
||||
};
|
||||
driver
|
||||
= await driver_generator(executable, config, kitDefault, defaultWorkspaceFolder, checkPreconditionHelper, []);
|
||||
driver = await driver_generator(executable, config, kitDefault, defaultWorkspaceFolder, checkPreconditionHelper, []);
|
||||
const configure1 = driver.configure(ConfigureTrigger.runTests, []);
|
||||
const configure2 = driver.configure(ConfigureTrigger.runTests, []);
|
||||
|
||||
|
@ -417,7 +412,7 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
|
||||
driver = await driver_generator(executable, config, kitDefault, defaultWorkspaceFolder, async () => {}, []);
|
||||
await driver.configure(ConfigureTrigger.runTests, ['-DEXTRA_ARGS_TEST=Hallo']);
|
||||
expect(driver.cmakeCacheEntries.get('extraArgsEnvironment')!.value).to.be.eq('Hallo');
|
||||
expect(driver.cmakeCacheEntries.get('extraArgsEnvironment')?.value).to.be.eq('Hallo');
|
||||
}).timeout(90000);
|
||||
|
||||
test('Test extra arguments on clean and configure', async () => {
|
||||
|
@ -426,7 +421,7 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
|
||||
driver = await driver_generator(executable, config, kitDefault, defaultWorkspaceFolder, async () => {}, []);
|
||||
await driver.cleanConfigure(ConfigureTrigger.runTests, ['-DEXTRA_ARGS_TEST=Hallo']);
|
||||
expect(driver.cmakeCacheEntries.get('extraArgsEnvironment')!.value).to.be.eq('Hallo');
|
||||
expect(driver.cmakeCacheEntries.get('extraArgsEnvironment')?.value).to.be.eq('Hallo');
|
||||
}).timeout(90000);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'module-alias/register';
|
|||
import * as path from 'path';
|
||||
import * as Mocha from 'mocha';
|
||||
import * as glob from 'glob';
|
||||
import { Logger } from '@cmt/logging';
|
||||
|
||||
export function run(): Promise<void> {
|
||||
// Create the mocha test
|
||||
|
@ -21,11 +22,23 @@ export function run(): Promise<void> {
|
|||
}
|
||||
|
||||
// Add files to the test suite
|
||||
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
|
||||
const regex = process.env.TEST_FILTER ? new RegExp(process.env.TEST_FILTER) : /.*/;
|
||||
files.forEach(f => {
|
||||
if (regex.test(f)) {
|
||||
mocha.addFile(path.resolve(testsRoot, f));
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
// Run the mocha test
|
||||
mocha.timeout(100000);
|
||||
|
||||
// Log the name of each test before it starts.
|
||||
const beforeEach: Mocha.Func = function (this: Mocha.Context, done: Mocha.Done) {
|
||||
Logger.logTestName(this.currentTest?.parent?.title, this.currentTest?.title);
|
||||
done();
|
||||
};
|
||||
mocha.rootHooks({beforeEach});
|
||||
mocha.run(failures => {
|
||||
if (failures > 0) {
|
||||
e(new Error(`${failures} tests failed.`));
|
||||
|
|
|
@ -19,7 +19,7 @@ function getTestRootFilePath(filename: string): string {
|
|||
}
|
||||
|
||||
function getPathWithoutCompilers() {
|
||||
if (process.arch === 'win32') {
|
||||
if (process.platform === 'win32') {
|
||||
return 'C:\\TMP';
|
||||
} else {
|
||||
return '/tmp';
|
||||
|
@ -84,21 +84,18 @@ suite('Kits scan test', async () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('Detect system kits never throws',
|
||||
async () => {
|
||||
const build_loc = 'build';
|
||||
const exe_res = 'output.txt';
|
||||
test('Detect system kits never throws', async () => {
|
||||
const build_loc = 'build';
|
||||
const exe_res = 'output.txt';
|
||||
|
||||
testEnv = new DefaultEnvironment('test/extension-tests/successful-build/project-folder', build_loc, exe_res);
|
||||
cmt = await CMakeTools.create(testEnv.vsContext, testEnv.wsContext);
|
||||
testEnv = new DefaultEnvironment('test/extension-tests/successful-build/project-folder', build_loc, exe_res);
|
||||
cmt = await CMakeTools.create(testEnv.vsContext, testEnv.wsContext);
|
||||
|
||||
await clearExistingKitConfigurationFile();
|
||||
await clearExistingKitConfigurationFile();
|
||||
|
||||
// Don't care about the result, just check that we don't throw during the test
|
||||
await kit.scanForKits(cmt);
|
||||
})
|
||||
// Compiler detection can run a little slow
|
||||
.timeout(60000);
|
||||
// Don't care about the result, just check that we don't throw during the test
|
||||
await kit.scanForKits(cmt, { ignorePath: process.platform === 'win32' });
|
||||
}).timeout(120000); // Compiler detection can run a little slow
|
||||
|
||||
test('Detect a GCC compiler file', async () => {
|
||||
const compiler = path.join(fakebin, 'gcc-42.1');
|
||||
|
@ -165,8 +162,7 @@ suite('Kits scan test', async () => {
|
|||
expect(compkit!.environmentVariables).to.be.undefined;
|
||||
});
|
||||
|
||||
// Test is broken, the use of env path has changed
|
||||
test.skip('Detect an MinGW compiler file on windows', async () => {
|
||||
test('Detect an MinGW compiler file on windows', async () => {
|
||||
if (process.platform !== 'win32') {
|
||||
return;
|
||||
}
|
||||
|
@ -180,7 +176,7 @@ suite('Kits scan test', async () => {
|
|||
|
||||
expect(compkit!.name).to.eq('GCC 6.3.0 x86_64-w64-mingw32');
|
||||
expect(compkit!.preferredGenerator!.name).to.eq('MinGW Makefiles');
|
||||
expect(compkit!.environmentVariables!.PATH).include('fakebin');
|
||||
expect(compkit!.environmentVariables!.CMT_MINGW_PATH).include('fakebin');
|
||||
});
|
||||
|
||||
test('Detect non-compiler program', async () => {
|
||||
|
|
|
@ -14,11 +14,15 @@ async function main() {
|
|||
|
||||
// The current folder is the default workspace.
|
||||
// The driver tests change the default workspace folder.
|
||||
const testWorkspace = path.resolve(extensionDevelopmentPath, 'test/unit-tests');
|
||||
const testWorkspace = path.resolve(extensionDevelopmentPath, 'test/unit-tests/test-project-without-cmakelists');
|
||||
|
||||
const launchArgs = ["--disable-extensions", testWorkspace];
|
||||
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = { "CMT_TESTING": "1" };
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = {
|
||||
"CMT_TESTING": "1",
|
||||
"CMT_QUIET_CONSOLE": "1",
|
||||
"TEST_FILTER": process.env.TEST_FILTER ?? ".*"
|
||||
};
|
||||
|
||||
// Download VS Code, unzip it and run the integration test
|
||||
await runTests({ launchArgs, extensionDevelopmentPath, extensionTestsPath, extensionTestsEnv });
|
||||
|
|
|
@ -176,7 +176,7 @@ suite('Select debugger', async () => {
|
|||
|
||||
const target = { name: 'Test', path: 'Target' };
|
||||
const cache = await CMakeCache.fromPath(getTestResourceFilePath('TestCMakeCache-gcc.txt'));
|
||||
const debuggerPath = getTestResourceFilePath('../fakebin/gdb');
|
||||
const debuggerPath = getTestResourceFilePath(`../fakebin/gdb${process.platform === 'win32' ? '.exe' : ''}`);
|
||||
|
||||
const config = await Debugger.getDebugConfigurationFromCache(cache, target, 'darwin', Debugger.MIModes.gdb, debuggerPath);
|
||||
expect(config).to.not.be.null;
|
||||
|
@ -213,7 +213,7 @@ suite('Select debugger', async () => {
|
|||
|
||||
const target = { name: 'Test', path: 'Target' };
|
||||
const cache = await CMakeCache.fromPath(getTestResourceFilePath('TestCMakeCache-gcc.txt'));
|
||||
const debuggerPath = getTestResourceFilePath('../fakebin/lldb-mi');
|
||||
const debuggerPath = getTestResourceFilePath(`../fakebin/lldb-mi${process.platform === 'win32' ? '.exe' : ''}`);
|
||||
|
||||
const config = await Debugger.getDebugConfigurationFromCache(cache, target, 'darwin', undefined, debuggerPath);
|
||||
expect(config).to.not.be.null;
|
||||
|
|
21
test/util.ts
21
test/util.ts
|
@ -29,20 +29,29 @@ export async function getExtension() {
|
|||
|
||||
let AVAIL_KITS: Promise<Kit[]> | null = null;
|
||||
|
||||
export async function getSystemKits(cmakeTools: CMakeTools): Promise<Kit[]> {
|
||||
export async function getSystemKits(cmakeTools?: CMakeTools): Promise<Kit[]> {
|
||||
if (AVAIL_KITS === null) {
|
||||
AVAIL_KITS = scanForKits(cmakeTools);
|
||||
AVAIL_KITS = scanForKits(cmakeTools, { ignorePath: process.platform === 'win32' });
|
||||
}
|
||||
return AVAIL_KITS;
|
||||
}
|
||||
|
||||
export async function getFirstSystemKit(cmakeTools: CMakeTools): Promise<Kit> {
|
||||
/**
|
||||
* @returns a Visual Studio kit on Windows, a GCC or Clang kit on mac/linux
|
||||
*/
|
||||
export async function getFirstSystemKit(cmakeTools?: CMakeTools): Promise<Kit> {
|
||||
const kits = await getSystemKits(cmakeTools);
|
||||
console.assert(kits.length >= 1, 'No kits found for testing');
|
||||
return kits[0];
|
||||
return kits.find(kit => {
|
||||
if (process.platform === 'win32') {
|
||||
return !!kit.visualStudio;
|
||||
} else {
|
||||
return !!kit.compilers;
|
||||
}
|
||||
})!;
|
||||
}
|
||||
|
||||
export async function getMatchingSystemKit(cmakeTools: CMakeTools, re: RegExp): Promise<Kit> {
|
||||
export async function getMatchingSystemKit(cmakeTools: CMakeTools | undefined, re: RegExp): Promise<Kit> {
|
||||
const kits = await getSystemKits(cmakeTools);
|
||||
return getMatchingKit(kits, re);
|
||||
}
|
||||
|
@ -55,7 +64,7 @@ export async function getMatchingProjectKit(re: RegExp, dir: string): Promise<Ki
|
|||
function getMatchingKit(kits: Kit[], re: RegExp): Kit {
|
||||
const kit = kits.find(k => re.test(k.name));
|
||||
if (!kit) {
|
||||
throw new Error(`No kit matching expression: ${re}`);
|
||||
throw new Error(`Unable to find a Kit matching the expression: ${re}`);
|
||||
}
|
||||
return kit;
|
||||
}
|
||||
|
|
|
@ -6142,10 +6142,10 @@ vscode-tas-client@^0.1.22:
|
|||
dependencies:
|
||||
tas-client "0.1.21"
|
||||
|
||||
vscode-test@^1.5.2:
|
||||
version "1.5.2"
|
||||
resolved "https://registry.yarnpkg.com/vscode-test/-/vscode-test-1.5.2.tgz#d9ec3cab1815afae1d7d81923e3c685d13d32303"
|
||||
integrity sha512-x9PVfKxF6EInH9iSFGQi0V8H5zIW1fC7RAer6yNQR6sy3WyOwlWkuT3I+wf75xW/cO53hxMi1aj/EvqQfDFOAg==
|
||||
vscode-test@^1.6.1:
|
||||
version "1.6.1"
|
||||
resolved "https://registry.yarnpkg.com/vscode-test/-/vscode-test-1.6.1.tgz#44254c67036de92b00fdd72f6ace5f1854e1a563"
|
||||
integrity sha512-086q88T2ca1k95mUzffvbzb7esqQNvJgiwY4h29ukPhFo8u+vXOOmelUoU5EQUHs3Of8+JuQ3oGdbVCqaxuTXA==
|
||||
dependencies:
|
||||
http-proxy-agent "^4.0.1"
|
||||
https-proxy-agent "^5.0.0"
|
||||
|
|
Загрузка…
Ссылка в новой задаче