本文整理汇总了TypeScript中@cmt/cache.CMakeCache.fromPath方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CMakeCache.fromPath方法的具体用法?TypeScript CMakeCache.fromPath怎么用?TypeScript CMakeCache.fromPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@cmt/cache.CMakeCache
的用法示例。
在下文中一共展示了CMakeCache.fromPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Check substitution for variant names', async () => {
// Define test keys and expected values
const testKeys = {buildType: 'debug-label', otherVariant: 'option1'};
// Update configure settings
const configSettings: {[key: string]: string} = {};
await Promise.all(Object.keys(testKeys).map(async key => configSettings[key] = `\${variant:${key}}`));
testEnv.config.updatePartial({configureSettings: configSettings});
// Configure and retrieve generated cache
expect(await cmt.configure()).to.be.eq(0, '[variant] configure failed');
expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, '[variant] cache not found');
const cache = await CMakeCache.fromPath(await cmt.cachePath);
// Helper function for checking test keys in a cmake cache
const checkTestKey = async (testKey: [string, string], testCache: CMakeCache) => {
const [key, expected] = testKey;
// Get cache entry for given test key
const cacheEntry = testCache.get(key) as api.CacheEntry;
// Check type and value of the retrieved cache entry
expect(cacheEntry.type).to.eq(api.CacheEntryType.String, `[variant:${key}] unexpected cache entry type`);
expect(cacheEntry.key).to.eql(key, `[variant:${key}] unexpected cache entry key name`);
expect(cacheEntry.as<string>()).to.eql(expected, `[variant:${key}] incorrect substitution`);
expect(typeof cacheEntry.value).to.eq('string', `[variant:${key}] unexpected cache entry value type`);
};
// Check test keys
await Promise.all(objectPairs(testKeys).map(async testKey => checkTestKey(testKey, cache)));
}).timeout(100000);
示例2: test
test('Passing env-vars to CMake but not to the compiler', async () => {
// Set fake settings
testEnv.config.updatePartial({
configureEnvironment: {
_CONFIGURE_ENV: '${workspaceRootFolderName}',
},
});
// Configure
expect(await cmt.configure()).to.be.eq(0, '[configureEnvironment] 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('configureEnvironment') as api.CacheEntry;
expect(cacheEntry.type).to.eq(api.CacheEntryType.String, '[configureEnvironment] unexpected cache entry type');
expect(cacheEntry.key).to.eq('configureEnvironment', '[configureEnvironment] unexpected cache entry key name');
expect(cacheEntry.as<string>())
.to.eq(path.basename(testEnv.projectFolder.location), '[configureEnvironment] substitution incorrect');
expect(typeof cacheEntry.value).to.eq('string', '[configureEnvironment] unexpected cache entry value type');
// Build
expect(await cmt.build()).to.be.eq(0, '[configureEnvironment] build failed');
const result = await testEnv.result.getResultAsJson();
expect(result['configure-env']).to.eq('', '[configureEnvironment] env-var got passed to compiler');
}).timeout(100000);
示例3: test
test('Check substitution within toolchain kits', async () => {
// Configure
expect(await cmt.configure()).to.be.eq(0, '[toolchain] 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('CMAKE_TOOLCHAIN_FILE') as api.CacheEntry;
// tslint:disable-next-line:no-unused-expression
expect(cacheEntry).to.not.be.null;
expect(cacheEntry.key).to.eq('CMAKE_TOOLCHAIN_FILE', '[toolchain] unexpected cache entry key name');
expect(platformNormalizePath(cacheEntry.as<string>()))
.to.eq(platformNormalizePath(testEnv.projectFolder.location.concat('/test-toolchain.cmake')),
'[toolchain] substitution incorrect');
}).timeout(100000);
示例4: test
test('Check for environment variables being passed to configure', async () => {
// Set fake settings
// Configure
expect(await cmt.configure()).to.be.eq(0, '[variantEnv] 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('variantEnv');
expect(cacheEntry_).to.not.be.eq(null, '[variantEnv] Cache entry was not present');
const cacheEntry = cacheEntry_!;
expect(cacheEntry.type).to.eq(api.CacheEntryType.String, '[variantEnv] unexpected cache entry type');
expect(cacheEntry.key).to.eq('variantEnv', '[variantEnv] unexpected cache entry key name');
expect(typeof cacheEntry.value).to.eq('string', '[variantEnv] unexpected cache entry value type');
expect(cacheEntry.as<string>())
.to.eq('0cbfb6ae-f2ec-4017-8ded-89df8759c502', '[variantEnv] incorrect environment variable');
}).timeout(100000);