diff --git a/packages/@aws-cdk/integ-runner/README.md b/packages/@aws-cdk/integ-runner/README.md index 3f983273a4a1e..db79cf866b9ca 100644 --- a/packages/@aws-cdk/integ-runner/README.md +++ b/packages/@aws-cdk/integ-runner/README.md @@ -19,6 +19,13 @@ ## Overview +This tool has been created to be used initially by this repo (aws/aws-cdk). Long term the goal is +for this tool to be a general tool that can be used for running CDK integration tests. We are +publishing this tool so that it can be used by the community and we would love to receive feedback +on use cases that the tool should support, or issues that prevent the tool from being used in your +library. + +This tool is meant to be used with the [integ-tests](https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/integ-tests) library. ## Usage diff --git a/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts b/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts index 18b8a3c6e9f64..6ebdce2eea40c 100644 --- a/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts +++ b/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts @@ -129,8 +129,6 @@ export abstract class IntegRunner { protected readonly profile?: string; - protected readonly cdkExecutable: string; - protected _destructiveChanges?: DestructiveChange[]; private legacyContext?: Record; @@ -153,9 +151,7 @@ export abstract class IntegRunner { this.sourceFilePath = path.join(this.directory, parsed.base); this.cdkContextPath = path.join(this.directory, 'cdk.context.json'); - this.cdkExecutable = require.resolve('aws-cdk/bin/cdk'); this.cdk = options.cdk ?? new CdkCliWrapper({ - cdkExecutable: this.cdkExecutable, directory: this.directory, env: { ...options.env, diff --git a/packages/@aws-cdk/integ-runner/package.json b/packages/@aws-cdk/integ-runner/package.json index 5f08391b5bf08..fdf44c3311b9a 100644 --- a/packages/@aws-cdk/integ-runner/package.json +++ b/packages/@aws-cdk/integ-runner/package.json @@ -2,7 +2,7 @@ "name": "@aws-cdk/integ-runner", "description": "CDK Integration Testing Tool", "version": "0.0.0", - "private": true, + "private": false, "main": "lib/index.js", "types": "lib/index.d.ts", "bin": { diff --git a/packages/cdk-cli-wrapper/lib/cdk-wrapper.ts b/packages/cdk-cli-wrapper/lib/cdk-wrapper.ts index fd45c4ae0c07b..069673582f195 100644 --- a/packages/cdk-cli-wrapper/lib/cdk-wrapper.ts +++ b/packages/cdk-cli-wrapper/lib/cdk-wrapper.ts @@ -109,9 +109,9 @@ export class CdkCliWrapper implements ICdk { this.directory = options.directory; this.env = options.env; try { - this.cdk = options.cdkExecutable ?? require.resolve('aws-cdk/bin/cdk'); + this.cdk = options.cdkExecutable ?? 'cdk'; } catch (e) { - throw new Error(`could not resolve path to cdk executable: "${options.cdkExecutable}"`); + throw new Error(`could not resolve path to cdk executable: "${options.cdkExecutable ?? 'cdk'}"`); } } diff --git a/packages/cdk-cli-wrapper/test/cdk-wrapper.test.ts b/packages/cdk-cli-wrapper/test/cdk-wrapper.test.ts index c0d8f75195ea9..0a9d370426aae 100644 --- a/packages/cdk-cli-wrapper/test/cdk-wrapper.test.ts +++ b/packages/cdk-cli-wrapper/test/cdk-wrapper.test.ts @@ -32,7 +32,7 @@ test('default deploy', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), ['deploy', '--app', 'node bin/my-app.js', 'test-stack1'], expect.objectContaining({ env: expect.anything(), @@ -86,7 +86,7 @@ test('deploy with all arguments', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), expect.arrayContaining([ 'deploy', '--no-strict', @@ -146,7 +146,7 @@ test('can parse boolean arguments', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), [ 'deploy', '--app', @@ -179,7 +179,7 @@ test('can parse parameters', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), [ 'deploy', '--parameters', 'myparam=test', @@ -211,7 +211,7 @@ test('can parse context', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), [ 'deploy', '--app', @@ -243,7 +243,7 @@ test('can parse array arguments', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), [ 'deploy', '--notification-arns', 'arn:aws:us-east-1:1111111111:some:resource', @@ -274,7 +274,7 @@ test('can provide additional environment', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), ['deploy', '--app', 'node bin/my-app.js', 'test-stack1'], expect.objectContaining({ env: expect.objectContaining({ @@ -300,7 +300,7 @@ test('default synth', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), ['synth', '--app', 'node bin/my-app.js', 'test-stack1'], expect.objectContaining({ env: expect.objectContaining({ @@ -326,7 +326,7 @@ test('synth arguments', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), ['destroy', '--app', 'node bin/my-app.js', 'test-stack1'], expect.objectContaining({ env: expect.objectContaining({ @@ -354,7 +354,7 @@ test('destroy arguments', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), ['destroy', '--force', '--no-exclusively', '--app', 'node bin/my-app.js', 'test-stack1'], expect.objectContaining({ env: expect.objectContaining({ @@ -380,7 +380,7 @@ test('default ls', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), ['ls', '--app', 'node bin/my-app.js', '*'], expect.objectContaining({ env: expect.objectContaining({ @@ -415,7 +415,7 @@ test('ls arguments', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/aws-cdk\/bin\/cdk/), + expect.stringMatching(/cdk/), ['ls', '--long', '--app', 'node bin/my-app.js', '*'], expect.objectContaining({ env: expect.objectContaining({