Skip to content

Commit

Permalink
Add support for ${workspaceFolderBasename} (#1044)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbrow authored Feb 4, 2020
1 parent 4f7dae9 commit e371089
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/drivers/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
workspaceFolder: ws_root,
buildType: this.currentBuildType,
workspaceRootFolderName: path.basename(ws_root),
workspaceFolderBasename: path.basename(ws_root),
generator: this.generatorName || 'null',
userHome: paths.userHome,
buildKit: this._kit ? this._kit.name : '__unknownkit__',
Expand Down
1 change: 1 addition & 0 deletions src/expand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface RequiredExpansionContextVars {
buildType: string;
buildKit: string;
workspaceRootFolderName: string;
workspaceFolderBasename: string;
generator: string;
userHome: string;
}
Expand Down
1 change: 1 addition & 0 deletions src/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class Paths {
buildType: '',
generator: '',
workspaceRootFolderName: path.basename(wsc.folder.uri.fsPath),
workspaceFolderBasename: path.basename(wsc.folder.uri.fsPath)
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,24 @@ suite('[Variable Substitution]', async () => {
expect(typeof cacheEntry.value).to.eq('string', '[workspaceRootFolderName] unexpected cache entry value type');
}).timeout(100000);

test('Check substitution for "workspaceFolderBasename"', async () => {
// Set fake settings
testEnv.config.updatePartial({configureSettings: {workspaceFolderBasename: '${workspaceFolderBasename}'}});

// Configure
expect(await cmt.configure()).to.be.eq(0, '[workspaceFolderBasename] configure failed');
expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, 'expected cache not present');
const cache = await CMakeCache.fromPath(await cmt.cachePath);

const cacheEntry = cache.get('workspaceFolderBasename') as api.CacheEntry;
expect(cacheEntry.type).to.eq(api.CacheEntryType.String, '[workspaceFolderBasename] unexpected cache entry type');
expect(cacheEntry.key)
.to.eq('workspaceFolderBasename', '[workspaceFolderBasename] unexpected cache entry key name');
expect(cacheEntry.as<string>())
.to.eq(path.basename(testEnv.projectFolder.location), '[workspaceFolderBasename] substitution incorrect');
expect(typeof cacheEntry.value).to.eq('string', '[workspaceFolderBasename] unexpected cache entry value type');
}).timeout(100000);

test('Check substitution for "generator"', async () => {
// Set fake settings
testEnv.config.updatePartial({configureSettings: {generator: '${generator}'}});
Expand Down

0 comments on commit e371089

Please sign in to comment.