Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions packages/@aws-cdk/integ-runner/lib/runner/integ-test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as chokidar from 'chokidar';
import * as fs from 'fs-extra';
import * as workerpool from 'workerpool';
import type { IntegRunnerOptions } from './runner-base';
import { IntegRunner, DEFAULT_SYNTH_OPTIONS } from './runner-base';
import { IntegRunner } from './runner-base';
import * as logger from '../logger';
import { chunks, exec, promiseWithResolvers } from '../utils';
import type { DestructiveChange, AssertionResults, AssertionResult } from '../workers/common';
Expand Down Expand Up @@ -237,17 +237,11 @@ export class IntegTestRunner extends IntegRunner {
updateWorkflowEnabled,
options.testCaseName,
);
} else {
await this.cdk.synthFast({
execCmd: this.cdkApp.split(' '),
context: this.getContext(actualTestSuite.enableLookups ? DEFAULT_SYNTH_OPTIONS.context : {}),
env: DEFAULT_SYNTH_OPTIONS.env,
output: path.relative(this.directory, this.cdkOutDir),
});
}

// only create the snapshot if there are no failed assertion results
// (i.e. no failures)
if (!assertionResults || !Object.values(assertionResults).some(result => result.status === 'fail')) {
if (!Object.values(assertionResults ?? {}).some(result => result.status === 'fail')) {
await this.createSnapshot();
}
} catch (e) {
Expand Down
16 changes: 6 additions & 10 deletions packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,12 @@ export abstract class IntegRunner {

// if lookups are enabled then we need to synth again
// using dummy context and save that as the snapshot
if ((await this.actualTestSuite()).enableLookups) {
await this.cdk.synthFast({
execCmd: this.cdkApp.split(' '),
context: this.getContext(DEFAULT_SYNTH_OPTIONS.context),
env: DEFAULT_SYNTH_OPTIONS.env,
output: path.relative(this.directory, this.snapshotDir),
});
} else {
fs.moveSync(this.cdkOutDir, this.snapshotDir, { overwrite: true });
}
await this.cdk.synthFast({
execCmd: this.cdkApp.split(' '),
context: this.getContext(DEFAULT_SYNTH_OPTIONS.context),
env: DEFAULT_SYNTH_OPTIONS.env,
output: path.relative(this.directory, this.snapshotDir),
});

await this.cleanupSnapshot();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('IntegTest runIntegTests', () => {
// THEN
expect(cdkMock.mocks.deploy).toHaveBeenCalledTimes(3);
expect(cdkMock.mocks.destroy).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(2);
expect(cdkMock.mocks.deploy).toHaveBeenCalledWith({
app: 'xxxxx.test-with-snapshot.js.snapshot',
requireApproval: 'never',
Expand Down Expand Up @@ -124,7 +124,7 @@ describe('IntegTest runIntegTests', () => {
// THEN
expect(cdkMock.mocks.deploy).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.destroy).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(2);
expect(cdkMock.mocks.deploy).toHaveBeenCalledWith({
app: 'node xxxxx.integ-test1.js',
requireApproval: 'never',
Expand Down Expand Up @@ -229,7 +229,7 @@ describe('IntegTest runIntegTests', () => {
// THEN
expect(cdkMock.mocks.deploy).toHaveBeenCalledTimes(3);
expect(cdkMock.mocks.destroy).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(2);
expect(cdkMock.mocks.deploy).toHaveBeenNthCalledWith(1, expect.objectContaining({
app: 'xxxxx.test-with-snapshot.js.snapshot',
context: expect.any(Object),
Expand Down Expand Up @@ -276,7 +276,7 @@ describe('IntegTest runIntegTests', () => {
// THEN
expect(cdkMock.mocks.deploy).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.destroy).toHaveBeenCalledTimes(0);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(2);
});

test('dryrun', async () => {
Expand Down Expand Up @@ -340,7 +340,7 @@ describe('IntegTest runIntegTests', () => {
// THEN
expect(cdkMock.mocks.deploy).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.destroy).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(2);
expect(cdkMock.mocks.deploy).toHaveBeenCalledWith({
app: 'node xxxxx.integ-test1.js',
requireApproval: 'never',
Expand Down Expand Up @@ -623,7 +623,7 @@ describe('IntegTest runIntegTests', () => {
// THEN
expect(cdkMock.mocks.deploy).toHaveBeenCalledTimes(3);
expect(cdkMock.mocks.destroy).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(1);
expect(cdkMock.mocks.synthFast).toHaveBeenCalledTimes(2);
expect(cdkMock.mocks.deploy).toHaveBeenCalledWith(expect.objectContaining({
app: 'node --no-warnings xxxxx.test-with-snapshot.js',
}));
Expand Down
Loading