Work in review comments.
- Fix name convention for methods, files, folder, variables - Fix typos - Replace declaration of class members by in constructors if possible
This commit is contained in:
Родитель
77c12dcab2
Коммит
dc5121416b
|
@ -29,9 +29,9 @@
|
|||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"${workspaceRoot}/test/unit_tests/test_project_without_cmakelists",
|
||||
"${workspaceRoot}/test/unit-tests/test-project-without-cmakelists",
|
||||
"--extensionDevelopmentPath=${workspaceRoot}",
|
||||
"--extensionTestsPath=${workspaceRoot}/out/test/unit_tests"
|
||||
"--extensionTestsPath=${workspaceRoot}/out/test/unit-tests"
|
||||
],
|
||||
"stopOnEntry": false,
|
||||
"sourceMaps": true,
|
||||
|
@ -39,7 +39,7 @@
|
|||
"${workspaceRoot}/out/*",
|
||||
"${workspaceRoot}/out/src/*",
|
||||
"${workspaceRoot}/out/test/*",
|
||||
"${workspaceRoot}/out/test/unit_tests/*"
|
||||
"${workspaceRoot}/out/test/unit-tests/*"
|
||||
],
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
|
@ -50,14 +50,14 @@
|
|||
// "smartStep": true
|
||||
},
|
||||
{
|
||||
"name": "Launch Extension Tests (Empty project folder)",
|
||||
"name": "Launch Extension Tests (without-cmakelist-file)",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"${workspaceRoot}/test/extension_tests/without_cmakelist_file/project_folder",
|
||||
"${workspaceRoot}/test/extension-tests/without-cmakelist-file/project-folder",
|
||||
"--extensionDevelopmentPath=${workspaceRoot}",
|
||||
"--extensionTestsPath=${workspaceRoot}/out/test/extension_tests/without_cmakelist_file"
|
||||
"--extensionTestsPath=${workspaceRoot}/out/test/extension-tests/without-cmakelist-file"
|
||||
],
|
||||
"stopOnEntry": false,
|
||||
"sourceMaps": true,
|
||||
|
@ -65,8 +65,8 @@
|
|||
"${workspaceRoot}/out/*",
|
||||
"${workspaceRoot}/out/src/*",
|
||||
"${workspaceRoot}/out/test/*",
|
||||
"${workspaceRoot}/out/test/extension_tests/without_cmakelist_file/*",
|
||||
"${workspaceRoot}/out/test/extension_tests/without_cmakelist_file/test/*"
|
||||
"${workspaceRoot}/out/test/extension-tests/without-cmakelist-file/*",
|
||||
"${workspaceRoot}/out/test/extension-tests/without-cmakelist-file/test/*"
|
||||
],
|
||||
|
||||
"preLaunchTask": "npm",
|
||||
|
@ -87,14 +87,14 @@
|
|||
// "smartStep": true
|
||||
},
|
||||
{
|
||||
"name": "Launch Extension Tests (successful_build)",
|
||||
"name": "Launch Extension Tests (successful-build)",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"${workspaceRoot}/test/extension_tests/successful_build/project_folder",
|
||||
"${workspaceRoot}/test/extension-tests/successful-build/project-folder",
|
||||
"--extensionDevelopmentPath=${workspaceRoot}",
|
||||
"--extensionTestsPath=${workspaceRoot}/out/test/extension_tests/successful_build"
|
||||
"--extensionTestsPath=${workspaceRoot}/out/test/extension-tests/successful-build"
|
||||
],
|
||||
"stopOnEntry": false,
|
||||
"sourceMaps": true,
|
||||
|
@ -102,8 +102,8 @@
|
|||
"${workspaceRoot}/out/*",
|
||||
"${workspaceRoot}/out/src/*",
|
||||
"${workspaceRoot}/out/test/*",
|
||||
"${workspaceRoot}/out/test/extension_tests/successful_build/*",
|
||||
"${workspaceRoot}/out/test/extension_tests/successful_build/test/*"
|
||||
"${workspaceRoot}/out/test/extension-tests/successful-build/*",
|
||||
"${workspaceRoot}/out/test/extension-tests/successful-build/test/*"
|
||||
],
|
||||
|
||||
"preLaunchTask": "npm",
|
||||
|
|
|
@ -7,8 +7,8 @@ set CMT_TESTING=1
|
|||
|
||||
REM Run all tests with a workspace folder where no CMakeLists.txt exists
|
||||
REM This prevents automatic loading of the extension.
|
||||
set CODE_TESTS_PATH=%~dp0\..\out\test\extension_tests\without_cmakelist_file
|
||||
set CODE_TESTS_WORKSPACE=%~dp0\..\test\extension_tests\without_cmakelist_file\project_folder
|
||||
set CODE_TESTS_PATH=%~dp0\..\out\test\extension-tests\without-cmakelist-file
|
||||
set CODE_TESTS_WORKSPACE=%~dp0\..\test\extension-tests\without-cmakelist-file\project-folder
|
||||
node ./node_modules/vscode/bin/test
|
||||
set TEST_ERRONO=%errorlevel%
|
||||
|
||||
|
@ -25,8 +25,8 @@ set CMT_TESTING=1
|
|||
|
||||
REM Run all tests with a workspace folder where no CMakeLists.txt exists
|
||||
REM This prevents automatic loading of the extension.
|
||||
set CODE_TESTS_PATH=%~dp0\..\out\test\extension_tests\successful_build
|
||||
set CODE_TESTS_WORKSPACE=%~dp0\..\test\extension_tests\successful_build\project_folder
|
||||
set CODE_TESTS_PATH=%~dp0\..\out\test\extension-tests\successful-build
|
||||
set CODE_TESTS_WORKSPACE=%~dp0\..\test\extension-tests\successful-build\project-folder
|
||||
node ./node_modules/vscode/bin/test
|
||||
set TEST_ERRONO=%errorlevel%
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ export CMT_TESTING=1
|
|||
|
||||
# Run all tests with a workspace folder where no CMakeLists.txt exists
|
||||
# This prevents automatic loading of the extension.
|
||||
export CODE_TESTS_PATH=$ROOT/out/test/extension_tests/without_cmakelist_file
|
||||
export CODE_TESTS_WORKSPACE=$ROOT/test/extension_tests/without_cmakelist_file/project_folder
|
||||
export CODE_TESTS_PATH=$ROOT/out/test/extension-tests/without-cmakelist-file
|
||||
export CODE_TESTS_WORKSPACE=$ROOT/test/extension-tests/without-cmakelist-file/project-folder
|
||||
node ./node_modules/vscode/bin/test
|
||||
test_error_code=$?
|
||||
|
||||
export CODE_TESTS_PATH=$ROOT/out/test/extension_tests/successful_build
|
||||
export CODE_TESTS_WORKSPACE=$ROOT/test/extension_tests/successful_build/project_folder
|
||||
export CODE_TESTS_PATH=$ROOT/out/test/extension-tests/successful-build
|
||||
export CODE_TESTS_WORKSPACE=$ROOT/test/extension-tests/successful-build/project-folder
|
||||
node ./node_modules/vscode/bin/test
|
||||
test_error_code_2=$?
|
||||
|
||||
|
@ -49,8 +49,8 @@ export CMT_TESTING=1
|
|||
|
||||
# Run all tests with a workspace folder where no CMakeLists.txt exists
|
||||
# This prevents automatic loading of the extension.
|
||||
export CODE_TESTS_PATH=$ROOT/out/test/extension_tests/successful_build
|
||||
export CODE_TESTS_WORKSPACE=$ROOT/test/extension_tests/successful_build/project_folder
|
||||
export CODE_TESTS_PATH=$ROOT/out/test/extension-tests/successful-build
|
||||
export CODE_TESTS_WORKSPACE=$ROOT/test/extension-tests/successful-build/project-folder
|
||||
node ./node_modules/vscode/bin/test
|
||||
test_error_code=$?
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ set CMT_TESTING=1
|
|||
|
||||
REM Run all tests with a workspace folder where no CMakeLists.txt exists
|
||||
REM This prevents automatic loading of the extension.
|
||||
set CODE_TESTS_PATH=%~dp0\..\out\test\unit_tests
|
||||
set CODE_TESTS_WORKSPACE=%~dp0\..\test\unit_tests\test_project_without_cmakelists
|
||||
set CODE_TESTS_PATH=%~dp0\..\out\test\unit-tests
|
||||
set CODE_TESTS_WORKSPACE=%~dp0\..\test\unit-tests\test-project-without-cmakelists
|
||||
node ./node_modules/vscode/bin/test
|
||||
set TEST_ERRONO=%errorlevel%
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ export CMT_TESTING=1
|
|||
|
||||
# Run all tests with a workspace folder where no CMakeLists.txt exists
|
||||
# This prevents automatic loading of the extension.
|
||||
export CODE_TESTS_PATH=$ROOT/out/test/unit_tests
|
||||
export CODE_TESTS_WORKSPACE=$ROOT/test/unit_tests/test_project_without_cmakelists
|
||||
export CODE_TESTS_PATH=$ROOT/out/test/unit-tests
|
||||
export CODE_TESTS_WORKSPACE=$ROOT/test/unit-tests/test-project-without-cmakelists
|
||||
node ./node_modules/vscode/bin/test
|
||||
|
||||
popd
|
||||
|
|
|
@ -386,9 +386,9 @@ const VsArchitectures: {[key: string]: string} = {
|
|||
* Preferred CMake VS generators by VS version
|
||||
*/
|
||||
const VsGenerators: {[key: string]: string} = {
|
||||
11: "Visual Studio 11 2012",
|
||||
11: 'Visual Studio 11 2012',
|
||||
VS120COMNTOOLS: 'Visual Studio 12 2013',
|
||||
12: "Visual Studio 12 2013",
|
||||
12: 'Visual Studio 12 2013',
|
||||
VS140COMNTOOLS: 'Visual Studio 14 2015',
|
||||
14: 'Visual Studio 14 2015',
|
||||
15: 'Visual Studio 15 2017'
|
||||
|
|
|
@ -3,8 +3,8 @@ import {expect} from 'chai';
|
|||
import * as chaiAsPromised from 'chai-as-promised';
|
||||
chai.use(chaiAsPromised);
|
||||
|
||||
import {clearExistingKitConfigurationFile} from '../../../test_helpers';
|
||||
import {DefaultEnvironment} from '../../../helpers/test/defaultenvironment';
|
||||
import {clearExistingKitConfigurationFile} from '../../../test-helpers';
|
||||
import {DefaultEnvironment} from '../../../helpers/test/default-environment';
|
||||
|
||||
import {CMakeTools} from '../../../../src/cmake-tools';
|
||||
import config from '../../../../src/config';
|
||||
|
@ -19,7 +19,7 @@ suite('Build', async() => {
|
|||
}
|
||||
this.timeout(100000);
|
||||
|
||||
testEnv = new DefaultEnvironment('test/extension_tests/successful_build/project_folder');
|
||||
testEnv = new DefaultEnvironment('test/extension-tests/successful-build/project-folder');
|
||||
cmt = await CMakeTools.create(testEnv.vsContext);
|
||||
|
||||
// This test will use all on the same kit.
|
||||
|
@ -29,7 +29,7 @@ suite('Build', async() => {
|
|||
await cmt.scanForKits();
|
||||
await cmt.selectKit();
|
||||
|
||||
testEnv.projectFolder.BuildDirectory.Clear();
|
||||
testEnv.projectFolder.buildDirectory.clear();
|
||||
});
|
||||
|
||||
teardown(async function(this: Mocha.IBeforeAndAfterContext) {
|
||||
|
@ -41,13 +41,13 @@ suite('Build', async() => {
|
|||
test('Configure ', async() => {
|
||||
expect(await cmt.configure()).to.be.eq(0);
|
||||
|
||||
expect(testEnv.projectFolder.BuildDirectory.IsCMakeCachePresent).to.eql(true, 'no expected cache presetruent');
|
||||
expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, 'no expected cache present');
|
||||
}).timeout(60000);
|
||||
|
||||
test('Build', async() => {
|
||||
expect(await cmt.build()).to.be.eq(0);
|
||||
|
||||
const result = await testEnv.result.GetResultAsJson();
|
||||
const result = await testEnv.result.getResultAsJson();
|
||||
expect(result['compiler']).to.eq('Microsoft Visual Studio');
|
||||
}).timeout(60000);
|
||||
|
||||
|
@ -56,7 +56,7 @@ suite('Build', async() => {
|
|||
expect(await cmt.configure()).to.be.eq(0);
|
||||
expect(await cmt.build()).to.be.eq(0);
|
||||
|
||||
const result = await testEnv.result.GetResultAsJson();
|
||||
const result = await testEnv.result.getResultAsJson();
|
||||
expect(result['compiler']).to.eq('Microsoft Visual Studio');
|
||||
}).timeout(60000);
|
||||
|
||||
|
@ -64,7 +64,7 @@ suite('Build', async() => {
|
|||
expect(await cmt.configure()).to.be.eq(0);
|
||||
expect(await cmt.build()).to.be.eq(0);
|
||||
|
||||
const result = await testEnv.result.GetResultAsJson();
|
||||
const result = await testEnv.result.getResultAsJson();
|
||||
expect(result['compiler']).to.eq('Microsoft Visual Studio');
|
||||
}).timeout(60000);
|
||||
|
|
@ -4,7 +4,7 @@ chai.use(chaiAsPromised);
|
|||
|
||||
import {expect} from 'chai';
|
||||
|
||||
import {clearExistingKitConfigurationFile, getExtension} from '../../../test_helpers';
|
||||
import {clearExistingKitConfigurationFile, getExtension} from '../../../test-helpers';
|
||||
|
||||
// This tests will be skipped when a Visual Studio installation marker (Env.HasVs=true) is present.
|
||||
// It is not possible to hide an installation against the test. In that case
|
|
@ -0,0 +1,17 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public get location(): string { return this._location; }
|
||||
|
||||
public get isCMakeCachePresent(): boolean { return fs.existsSync(path.join(this.location, 'CMakeCache.txt')); }
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as rimraf from 'rimraf';
|
||||
|
||||
export class BuildDirectoryHelper {
|
||||
|
||||
private readonly location: string;
|
||||
|
||||
public constructor(location: string) { this.location = location; }
|
||||
|
||||
public Clear() {
|
||||
if (fs.existsSync(this.location)) {
|
||||
return rimraf.sync(this.location);
|
||||
}
|
||||
}
|
||||
|
||||
public get Location(): string { return this.location; }
|
||||
|
||||
public get IsCMakeCachePresent(): boolean { return fs.existsSync(path.join(this.Location, 'CMakeCache.txt')); }
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
import * as path from 'path';
|
||||
import {BuildDirectoryHelper} from './build-directory-helper';
|
||||
|
||||
|
||||
export class ProjectRootHelper {
|
||||
private readonly _locationOfThisClassFile: string = __dirname;
|
||||
private readonly _buildFolder: BuildDirectoryHelper;
|
||||
private readonly _projectRoot: string;
|
||||
|
||||
constructor(relativeRoot: string, buildDir: string = 'build') {
|
||||
this._projectRoot = path.join(this.extensionSourceRoot, relativeRoot);
|
||||
this._buildFolder = new BuildDirectoryHelper(path.join(this._projectRoot, buildDir));
|
||||
}
|
||||
|
||||
private get extensionSourceRoot(): string {
|
||||
return path.normalize(path.join(this._locationOfThisClassFile, '../../../../'));
|
||||
}
|
||||
|
||||
public get buildDirectory(): BuildDirectoryHelper { return this._buildFolder; }
|
||||
|
||||
public get location(): string { return this._projectRoot; }
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
import * as path from 'path';
|
||||
import {BuildDirectoryHelper} from './builddirectoryhelper';
|
||||
|
||||
|
||||
export class ProjectRootHelper {
|
||||
private readonly locationOfThisClassFile: string = __dirname;
|
||||
private readonly buildFolder: BuildDirectoryHelper;
|
||||
private readonly projectRoot: string;
|
||||
constructor(relativeRoot: string, buildDir: string = 'build') {
|
||||
this.projectRoot = path.join(this.ExtensionSourceRoot, relativeRoot);
|
||||
this.buildFolder = new BuildDirectoryHelper(path.join(this.projectRoot, buildDir));
|
||||
}
|
||||
|
||||
private get ExtensionSourceRoot(): string {
|
||||
return path.normalize(path.join(this.locationOfThisClassFile, '../../../../'));
|
||||
}
|
||||
|
||||
public get BuildDirectory(): BuildDirectoryHelper { return this.buildFolder; }
|
||||
|
||||
public get Location(): string { return this.projectRoot; }
|
||||
}
|
|
@ -1,41 +1,37 @@
|
|||
import * as sinon from 'sinon';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import {ProjectRootHelper} from '../cmake/projectroothelper';
|
||||
import {TestProgramResult} from '../testprogram/testprogramresult';
|
||||
import {ProjectRootHelper} from '../cmake/project-root-helper';
|
||||
import {TestProgramResult} from '../testprogram/test-program-result';
|
||||
import {FakeContextDefinition} from '../vscodefake/extensioncontext';
|
||||
import {QuickPickerHandleStrategy, SelectKitPickerHandle} from '../vscodefake/quickpicker';
|
||||
import {CMakeToolsSettingFile} from '../vscodefake/workspaceconfiguration';
|
||||
import {QuickPickerHandleStrategy, SelectKitPickerHandle} from '../vscodefake/quick-picker';
|
||||
import {CMakeToolsSettingFile} from '../vscodefake/workspace-configuration';
|
||||
|
||||
export class DefaultEnvironment {
|
||||
|
||||
sandbox: sinon.SinonSandbox;
|
||||
sandbox: sinon.SinonSandbox = sinon.sandbox.create();
|
||||
projectFolder: ProjectRootHelper;
|
||||
kitSelection: SelectKitPickerHandle;
|
||||
result: TestProgramResult;
|
||||
public vsContext: FakeContextDefinition = new FakeContextDefinition();
|
||||
setting: CMakeToolsSettingFile;
|
||||
setting: CMakeToolsSettingFile = new CMakeToolsSettingFile(this.sandbox);
|
||||
|
||||
public constructor(projectRoot: string,
|
||||
buildLocation: string = 'build',
|
||||
executableResult: string = 'output.txt',
|
||||
defaultkitRegExp = '^VisualStudio') {
|
||||
this.projectFolder = new ProjectRootHelper(projectRoot, buildLocation);
|
||||
this.result = new TestProgramResult(this.projectFolder.BuildDirectory.Location, executableResult);
|
||||
this.result = new TestProgramResult(this.projectFolder.buildDirectory.location, executableResult);
|
||||
|
||||
this.kitSelection = new SelectKitPickerHandle(defaultkitRegExp);
|
||||
this.setupShowQuickPickerStub([this.kitSelection]);
|
||||
|
||||
|
||||
// clean build folder
|
||||
this.sandbox = sinon.sandbox.create();
|
||||
|
||||
this.SetupShowQuickPickerStub([this.kitSelection]);
|
||||
this.setting = new CMakeToolsSettingFile(this.sandbox);
|
||||
this.sandbox.stub(vscode.window, 'showInformationMessage').callsFake(() => ({doOpen: false}));
|
||||
}
|
||||
|
||||
private SetupShowQuickPickerStub(selections: QuickPickerHandleStrategy[]) {
|
||||
private setupShowQuickPickerStub(selections: QuickPickerHandleStrategy[]) {
|
||||
this.sandbox.stub(vscode.window, 'showQuickPick').callsFake((items, options): Thenable<string|undefined> => {
|
||||
if (options.placeHolder == selections[0].Identifier) {
|
||||
if (options.placeHolder == selections[0].identifier) {
|
||||
return Promise.resolve(selections[0].handleQuickPick(items));
|
||||
}
|
||||
return Promise.reject(`Unknown quick pick "${options.placeHolder}"`);
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
import {expect} from 'chai';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import {normalizePath} from '../../../src/util';
|
||||
|
||||
export class TestProgramResult {
|
||||
|
||||
private readonly _result_file_location: string;
|
||||
|
||||
public constructor(location: string, filename: string = 'output.txt') {
|
||||
this._result_file_location = normalizePath(path.join(location, filename));
|
||||
}
|
||||
|
||||
public get isPresent(): boolean { return fs.existsSync(this._result_file_location); }
|
||||
|
||||
public async getResultAsJson(): Promise<any> {
|
||||
expect(this.isPresent).to.eq(true, 'Test programm result file was not found');
|
||||
const content = fs.readFileSync(this._result_file_location);
|
||||
expect(content.toLocaleString()).to.not.eq('');
|
||||
|
||||
return JSON.parse(content.toString());
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
import {expect} from 'chai';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import {normalizePath} from '../../../src/util';
|
||||
|
||||
export class TestProgramResult {
|
||||
|
||||
private readonly result_file_location: string;
|
||||
|
||||
public constructor(location: string, filename: string = 'output.txt') {
|
||||
this.result_file_location = normalizePath(path.join(location, filename));
|
||||
}
|
||||
|
||||
public get IsPresent(): boolean { return fs.existsSync(this.result_file_location); }
|
||||
|
||||
public async GetResultAsJson(): Promise<any> {
|
||||
expect(this.IsPresent).to.eq(true, 'Test programm result file was not found');
|
||||
const content = fs.readFileSync(this.result_file_location);
|
||||
expect(content.toLocaleString()).to.not.eq('');
|
||||
|
||||
return JSON.parse(content.toString());
|
||||
}
|
||||
}
|
|
@ -2,17 +2,22 @@ import * as vscode from 'vscode';
|
|||
import {TestMemento} from './memento';
|
||||
|
||||
export class FakeContextDefinition implements vscode.ExtensionContext {
|
||||
|
||||
subscriptions: {dispose(): any;}[];
|
||||
workspaceState: vscode.Memento;
|
||||
globalState: vscode.Memento;
|
||||
extensionPath: string;
|
||||
|
||||
asAbsolutePath(relativePath: string): string { return relativePath; }
|
||||
storagePath: string|undefined;
|
||||
|
||||
constructor() {
|
||||
this.globalState = new TestMemento();
|
||||
this.workspaceState = new TestMemento();
|
||||
get extensionPath(): string {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
get storagePath(): string | undefined {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
get subscriptions(): {dispose(): any;}[] {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
workspaceState: vscode.Memento = new TestMemento();
|
||||
globalState: vscode.Memento = new TestMemento();
|
||||
|
||||
asAbsolutePath(relativePath:string): string { return relativePath; }
|
||||
|
||||
constructor() {}
|
||||
}
|
|
@ -1,18 +1,17 @@
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
export class TestMemento implements vscode.Memento {
|
||||
private readonly storage: {[key: string]: any} = {};
|
||||
|
||||
public get<T>(key: string): T|undefined;
|
||||
public get<T>(key: string, defaultValue: T): T;
|
||||
public get(key: any, defaultValue?: any) {
|
||||
if (this.ContainsKey(key)) {
|
||||
if (this.containsKey(key)) {
|
||||
return this.storage[key];
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
public update(key: string, value: any): Thenable<void> { return this.storage[key] = value; }
|
||||
private readonly storage: {[key: string]: any} = {};
|
||||
|
||||
public ContainsKey(key: string): boolean { return this.storage.hasOwnProperty(key); }
|
||||
public containsKey(key: string): boolean { return this.storage.hasOwnProperty(key); }
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import {expect} from 'chai';
|
||||
|
||||
export interface QuickPickerHandleStrategy {
|
||||
Identifier: string;
|
||||
identifier: string;
|
||||
|
||||
handleQuickPick(items: any): any;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ export class SelectKitPickerHandle implements QuickPickerHandleStrategy {
|
|||
|
||||
constructor(readonly defaultKitLabelRegEx: string) {}
|
||||
|
||||
public get Identifier(): string { return 'Select a Kit'; }
|
||||
public get identifier(): string { return 'Select a Kit'; }
|
||||
|
||||
public handleQuickPick(items: any): any {
|
||||
const defaultKit: string[] = items.filter((item: any) => {
|
|
@ -1,24 +1,27 @@
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
class CMakeToolsWorkspaceConfiguration implements vscode.WorkspaceConfiguration {
|
||||
private _values: {[section: string]: any;} = {};
|
||||
|
||||
constructor(protected _original: vscode.WorkspaceConfiguration) {}
|
||||
|
||||
readonly [key: string]: any;
|
||||
get<T>(section: string): T|undefined;
|
||||
get<T>(section: string, defaultValue: T): T;
|
||||
get(section: any, defaultValue?: any): any {
|
||||
if (this.values.hasOwnProperty(section)) {
|
||||
return this.values[section];
|
||||
if (this._values.hasOwnProperty(section)) {
|
||||
return this._values[section];
|
||||
} else {
|
||||
if (this.original.has(section)) {
|
||||
return this.original[section];
|
||||
if (this._original.has(section)) {
|
||||
return this._original[section];
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
has(section: string): boolean {
|
||||
const fakeHasSection: boolean = this.values.has(section);
|
||||
const origHasSection: boolean = this.original.has(section);
|
||||
const fakeHasSection: boolean = this._values.has(section);
|
||||
const origHasSection: boolean = this._original.has(section);
|
||||
return fakeHasSection || origHasSection;
|
||||
}
|
||||
inspect<T>(): {
|
||||
|
@ -28,30 +31,20 @@ class CMakeToolsWorkspaceConfiguration implements vscode.WorkspaceConfiguration
|
|||
throw new Error('Method not implemented.');
|
||||
}
|
||||
update(section: string, value: any): Thenable<void> {
|
||||
this.values[section] = value;
|
||||
this._values[section] = value;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
||||
private values: {[section: string]: any;} = {};
|
||||
protected original: vscode.WorkspaceConfiguration;
|
||||
|
||||
public clear() { this.values = {}; }
|
||||
|
||||
constructor(original: vscode.WorkspaceConfiguration) { this.original = original; }
|
||||
public clear() { this._values = {}; }
|
||||
}
|
||||
|
||||
export class CMakeToolsSettingFile {
|
||||
|
||||
readonly originalValues: vscode.WorkspaceConfiguration;
|
||||
readonly originalValues: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration('cmake');
|
||||
readonly filepath: string;
|
||||
readonly fakeValues: CMakeToolsWorkspaceConfiguration;
|
||||
readonly originalFunction: any;
|
||||
readonly fakeValues: CMakeToolsWorkspaceConfiguration = new CMakeToolsWorkspaceConfiguration(this.originalValues);
|
||||
readonly originalFunction: any = vscode.workspace.getConfiguration;
|
||||
|
||||
constructor(sandbox: sinon.SinonSandbox) {
|
||||
this.originalValues = vscode.workspace.getConfiguration('cmake');
|
||||
this.originalFunction = vscode.workspace.getConfiguration;
|
||||
this.fakeValues = new CMakeToolsWorkspaceConfiguration(this.originalValues);
|
||||
sandbox.stub(vscode.workspace, 'getConfiguration').callsFake(((section?: string, resource?: vscode.Uri) => {
|
||||
return this.getConfiguration(section, resource);
|
||||
}));
|
|
@ -13,7 +13,7 @@ import * as util from '../../src/util';
|
|||
|
||||
const here = __dirname;
|
||||
function getTestResourceFilePath(filename: string): string {
|
||||
return path.normalize(path.join(here, '../../../test/unit_tests', filename));
|
||||
return path.normalize(path.join(here, '../../../test/unit-tests', filename));
|
||||
}
|
||||
|
||||
suite('Cache test', async () => {
|
|
@ -13,7 +13,7 @@ import * as compdb from '../../src/compdb';
|
|||
|
||||
const here = __dirname;
|
||||
function getTestResourceFilePath(filename: string): string {
|
||||
return path.normalize(path.join(here, '../../../test/unit_tests', filename));
|
||||
return path.normalize(path.join(here, '../../../test/unit-tests', filename));
|
||||
}
|
||||
|
||||
suite('Compilation info', () => {
|
|
@ -24,7 +24,7 @@ function getTestRootFilePath(filename: string): string {
|
|||
|
||||
|
||||
function getTestResourceFilePath(filename: string): string {
|
||||
return path.normalize(path.join(here, '../../../test/unit_tests', filename));
|
||||
return path.normalize(path.join(here, '../../../test/unit-tests', filename));
|
||||
}
|
||||
|
||||
function getResourcePath(filename: string): string { return path.normalize(path.join(here, '../../..', filename)); }
|
|
@ -16,7 +16,7 @@ import * as state from '../../src/state';
|
|||
|
||||
const here = __dirname;
|
||||
function getTestResourceFilePath(filename: string): string {
|
||||
return path.normalize(path.join(here, '../../../test/unit_tests', filename));
|
||||
return path.normalize(path.join(here, '../../../test/unit-tests', filename));
|
||||
}
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче