From dbd240164cb952555902d161f0113315e6d1a9fb Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Wed, 6 Mar 2019 19:01:50 +0100 Subject: [PATCH] fix(cdk-integ): Update cdk-integ to use new context file (#1962) Running integ tests is currently broken, since the integ tests will write context to `cdk.json`, which then gets moved to `cdk.context.json`. `cdk.json` gets cleaned up afterwards but `cdk.context.json` does not, so it gets left there and messes up the next integ run. Just write all fake context to `cdk.context.json` right now as intended. --- tools/cdk-integ-tools/lib/integ-helpers.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/cdk-integ-tools/lib/integ-helpers.ts b/tools/cdk-integ-tools/lib/integ-helpers.ts index 19b3bcbd41132..b250790c269a8 100644 --- a/tools/cdk-integ-tools/lib/integ-helpers.ts +++ b/tools/cdk-integ-tools/lib/integ-helpers.ts @@ -61,33 +61,33 @@ export class IntegrationTests { export class IntegrationTest { public readonly expectedFileName: string; private readonly expectedFilePath: string; - private readonly cdkConfigPath: string; + private readonly cdkContextPath: string; constructor(private readonly directory: string, public readonly name: string) { const baseName = this.name.endsWith('.js') ? this.name.substr(0, this.name.length - 3) : this.name; this.expectedFileName = baseName + '.expected.json'; this.expectedFilePath = path.join(this.directory, this.expectedFileName); - this.cdkConfigPath = path.join(this.directory, 'cdk.json'); + this.cdkContextPath = path.join(this.directory, 'cdk.context.json'); } public async invoke(args: string[], options: { json?: boolean, context?: any, verbose?: boolean } = { }): Promise { // Write context to cdk.json, afterwards delete. We need to do this because there is no way // to pass structured context data from the command-line, currently. if (options.context) { - await this.writeCdkConfig({ context: options.context, versionReporting: false }); + await this.writeCdkContext(options.context); } else { - this.deleteCdkConfig(); + this.deleteCdkContext(); } try { const cdk = require.resolve('aws-cdk/bin/cdk'); - return exec([cdk, '-a', `node ${this.name}`].concat(args), { + return exec([cdk, '-a', `node ${this.name}`, '--no-version-reporting'].concat(args), { cwd: this.directory, json: options.json, verbose: options.verbose, }); } finally { - this.deleteCdkConfig(); + this.deleteCdkContext(); } } @@ -103,13 +103,13 @@ export class IntegrationTest { await util.promisify(fs.writeFile)(this.expectedFilePath, JSON.stringify(actual, undefined, 2), { encoding: 'utf-8' }); } - private async writeCdkConfig(config: any) { - await util.promisify(fs.writeFile)(this.cdkConfigPath, JSON.stringify(config, undefined, 2), { encoding: 'utf-8' }); + private async writeCdkContext(config: any) { + await util.promisify(fs.writeFile)(this.cdkContextPath, JSON.stringify(config, undefined, 2), { encoding: 'utf-8' }); } - private deleteCdkConfig() { - if (fs.existsSync(this.cdkConfigPath)) { - fs.unlinkSync(this.cdkConfigPath); + private deleteCdkContext() { + if (fs.existsSync(this.cdkContextPath)) { + fs.unlinkSync(this.cdkContextPath); } } }