Skip to content

Commit

Permalink
Merge branch 'master' into corymhall/integ-runner/exit-code
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored May 27, 2022
2 parents 5355a99 + 7779531 commit b40d32f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
7 changes: 7 additions & 0 deletions packages/@aws-cdk/integ-runner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 0 additions & 4 deletions packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ export abstract class IntegRunner {

protected readonly profile?: string;

protected readonly cdkExecutable: string;

protected _destructiveChanges?: DestructiveChange[];
private legacyContext?: Record<string, any>;

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/integ-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions packages/cdk-cli-wrapper/lib/cdk-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'}"`);
}
}

Expand Down
24 changes: 12 additions & 12 deletions packages/cdk-cli-wrapper/test/cdk-wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -146,7 +146,7 @@ test('can parse boolean arguments', () => {

// THEN
expect(spawnSyncMock).toHaveBeenCalledWith(
expect.stringMatching(/aws-cdk\/bin\/cdk/),
expect.stringMatching(/cdk/),
[
'deploy',
'--app',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -211,7 +211,7 @@ test('can parse context', () => {

// THEN
expect(spawnSyncMock).toHaveBeenCalledWith(
expect.stringMatching(/aws-cdk\/bin\/cdk/),
expect.stringMatching(/cdk/),
[
'deploy',
'--app',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand All @@ -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({
Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit b40d32f

Please sign in to comment.