Skip to content

Commit dbd2401

Browse files
rix0rrrRomainMuller
authored andcommitted
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.
1 parent 1767b61 commit dbd2401

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tools/cdk-integ-tools/lib/integ-helpers.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,33 +61,33 @@ export class IntegrationTests {
6161
export class IntegrationTest {
6262
public readonly expectedFileName: string;
6363
private readonly expectedFilePath: string;
64-
private readonly cdkConfigPath: string;
64+
private readonly cdkContextPath: string;
6565

6666
constructor(private readonly directory: string, public readonly name: string) {
6767
const baseName = this.name.endsWith('.js') ? this.name.substr(0, this.name.length - 3) : this.name;
6868
this.expectedFileName = baseName + '.expected.json';
6969
this.expectedFilePath = path.join(this.directory, this.expectedFileName);
70-
this.cdkConfigPath = path.join(this.directory, 'cdk.json');
70+
this.cdkContextPath = path.join(this.directory, 'cdk.context.json');
7171
}
7272

7373
public async invoke(args: string[], options: { json?: boolean, context?: any, verbose?: boolean } = { }): Promise<any> {
7474
// Write context to cdk.json, afterwards delete. We need to do this because there is no way
7575
// to pass structured context data from the command-line, currently.
7676
if (options.context) {
77-
await this.writeCdkConfig({ context: options.context, versionReporting: false });
77+
await this.writeCdkContext(options.context);
7878
} else {
79-
this.deleteCdkConfig();
79+
this.deleteCdkContext();
8080
}
8181

8282
try {
8383
const cdk = require.resolve('aws-cdk/bin/cdk');
84-
return exec([cdk, '-a', `node ${this.name}`].concat(args), {
84+
return exec([cdk, '-a', `node ${this.name}`, '--no-version-reporting'].concat(args), {
8585
cwd: this.directory,
8686
json: options.json,
8787
verbose: options.verbose,
8888
});
8989
} finally {
90-
this.deleteCdkConfig();
90+
this.deleteCdkContext();
9191
}
9292
}
9393

@@ -103,13 +103,13 @@ export class IntegrationTest {
103103
await util.promisify(fs.writeFile)(this.expectedFilePath, JSON.stringify(actual, undefined, 2), { encoding: 'utf-8' });
104104
}
105105

106-
private async writeCdkConfig(config: any) {
107-
await util.promisify(fs.writeFile)(this.cdkConfigPath, JSON.stringify(config, undefined, 2), { encoding: 'utf-8' });
106+
private async writeCdkContext(config: any) {
107+
await util.promisify(fs.writeFile)(this.cdkContextPath, JSON.stringify(config, undefined, 2), { encoding: 'utf-8' });
108108
}
109109

110-
private deleteCdkConfig() {
111-
if (fs.existsSync(this.cdkConfigPath)) {
112-
fs.unlinkSync(this.cdkConfigPath);
110+
private deleteCdkContext() {
111+
if (fs.existsSync(this.cdkContextPath)) {
112+
fs.unlinkSync(this.cdkContextPath);
113113
}
114114
}
115115
}

0 commit comments

Comments
 (0)