Skip to content

Commit

Permalink
chore: change code for generating the integ test snapshot directory n…
Browse files Browse the repository at this point in the history
…ames
  • Loading branch information
mrgrain committed Nov 1, 2022
1 parent 6c25e36 commit a884681
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 36 deletions.
6 changes: 3 additions & 3 deletions packages/@aws-cdk/integ-runner/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ junit.xml
# Ignore this symlink, we recreate it at test time
test/test-archive-follow/data/linked

!**/*.integ.snapshot/**/asset.*/*.js
!**/*.integ.snapshot/**/asset.*/*.d.ts
!**/*.snapshot/**/asset.*/*.js
!**/*.snapshot/**/asset.*/*.d.ts

!**/*.integ.snapshot/**/asset.*/**
!**/*.snapshot/**/asset.*/**
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ export class IntegTest {
? parsed.name
: path.join(path.relative(this.info.discoveryRoot, parsed.dir), parsed.name);

const nakedTestName = parsed.name.slice(6); // Leave name without 'integ.' and '.ts'
this.normalizedTestName = parsed.name;
this.snapshotDir = path.join(this.directory, `${nakedTestName}.integ.snapshot`);
this.temporaryOutputDir = path.join(this.directory, `${CDK_OUTDIR_PREFIX}.${nakedTestName}`);
this.snapshotDir = path.join(this.directory, `${parsed.base}.snapshot`);
this.temporaryOutputDir = path.join(this.directory, `${CDK_OUTDIR_PREFIX}.${parsed.base}.snapshot`);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('IntegTest runIntegTests', () => {
expect(destroyMock).toHaveBeenCalledTimes(1);
expect(synthFastMock).toHaveBeenCalledTimes(1);
expect(deployMock).toHaveBeenCalledWith({
app: 'test-with-snapshot.integ.snapshot',
app: 'xxxxx.test-with-snapshot.js.snapshot',
requireApproval: 'never',
pathMetadata: false,
assetMetadata: false,
Expand All @@ -86,7 +86,7 @@ describe('IntegTest runIntegTests', () => {
requireApproval: 'never',
pathMetadata: false,
assetMetadata: false,
output: 'cdk-integ.out.test-with-snapshot',
output: 'cdk-integ.out.xxxxx.test-with-snapshot.js.snapshot',
profile: undefined,
context: expect.not.objectContaining({
'vpc-provider:account=12345678:filter.isDefault=true:region=test-region:returnAsymmetricSubnets=true': expect.objectContaining({
Expand All @@ -111,7 +111,7 @@ describe('IntegTest runIntegTests', () => {
profile: undefined,
force: true,
all: true,
output: 'cdk-integ.out.test-with-snapshot',
output: 'cdk-integ.out.xxxxx.test-with-snapshot.js.snapshot',
});
});

Expand Down Expand Up @@ -145,7 +145,7 @@ describe('IntegTest runIntegTests', () => {
rollback: false,
lookups: false,
stacks: ['stack1'],
output: 'cdk-integ.out.integ-test1',
output: 'cdk-integ.out.xxxxx.integ-test1.js.snapshot',
});
expect(destroyMock).toHaveBeenCalledWith({
app: 'node xxxxx.integ-test1.js',
Expand All @@ -155,7 +155,7 @@ describe('IntegTest runIntegTests', () => {
context: expect.any(Object),
force: true,
all: true,
output: 'cdk-integ.out.integ-test1',
output: 'cdk-integ.out.xxxxx.integ-test1.js.snapshot',
});
});

Expand Down Expand Up @@ -190,7 +190,7 @@ describe('IntegTest runIntegTests', () => {
lookups: true,
rollback: false,
stacks: ['test-stack'],
output: 'cdk-integ.out.test-with-snapshot-assets-diff',
output: 'cdk-integ.out.xxxxx.test-with-snapshot-assets-diff.js.snapshot',
profile: undefined,
});
expect(synthFastMock).toHaveBeenCalledWith({
Expand All @@ -200,7 +200,7 @@ describe('IntegTest runIntegTests', () => {
CDK_INTEG_REGION: 'test-region',
CDK_CONTEXT_JSON: expect.stringContaining('"vpcId":"vpc-60900905"'),
}),
output: 'test-with-snapshot-assets-diff.integ.snapshot',
output: 'xxxxx.test-with-snapshot-assets-diff.js.snapshot',
});
expect(destroyMock).toHaveBeenCalledWith({
app: 'node xxxxx.test-with-snapshot-assets-diff.js',
Expand All @@ -214,7 +214,7 @@ describe('IntegTest runIntegTests', () => {
versionReporting: false,
force: true,
all: true,
output: 'cdk-integ.out.test-with-snapshot-assets-diff',
output: 'cdk-integ.out.xxxxx.test-with-snapshot-assets-diff.js.snapshot',
});
});

Expand Down Expand Up @@ -272,7 +272,7 @@ describe('IntegTest runIntegTests', () => {
expect(synthFastMock).toHaveBeenCalledTimes(1);
expect(synthFastMock).toHaveBeenCalledWith({
execCmd: ['node', 'xxxxx.integ-test1.js'],
output: 'cdk-integ.out.integ-test1',
output: 'cdk-integ.out.xxxxx.integ-test1.js.snapshot',
env: expect.objectContaining({
CDK_INTEG_ACCOUNT: '12345678',
CDK_INTEG_REGION: 'test-region',
Expand Down Expand Up @@ -313,7 +313,7 @@ describe('IntegTest runIntegTests', () => {
rollback: false,
lookups: false,
stacks: ['stack1'],
output: 'cdk-integ.out.integ-test1',
output: 'cdk-integ.out.xxxxx.integ-test1.js.snapshot',
});
expect(destroyMock).toHaveBeenCalledWith({
app: 'node xxxxx.integ-test1.js',
Expand All @@ -328,7 +328,7 @@ describe('IntegTest runIntegTests', () => {
profile: 'test-profile',
force: true,
all: true,
output: 'cdk-integ.out.integ-test1',
output: 'cdk-integ.out.xxxxx.integ-test1.js.snapshot',
});
});

Expand Down Expand Up @@ -406,7 +406,7 @@ describe('IntegTest runIntegTests', () => {
'git', ['merge-base', 'HEAD', 'main'],
]),
expect.arrayContaining([
'git', ['checkout', 'abc', '--', 'test-with-snapshot.integ.snapshot'],
'git', ['checkout', 'abc', '--', 'xxxxx.test-with-snapshot.js.snapshot'],
]),
]));
});
Expand Down Expand Up @@ -495,11 +495,11 @@ describe('IntegTest runIntegTests', () => {
});

expect(removeSyncMock.mock.calls).toEqual([
['test/test-data/test-with-snapshot-assets.integ.snapshot'],
['test/test-data/xxxxx.test-with-snapshot-assets.js.snapshot'],
[
'test/test-data/test-with-snapshot-assets.integ.snapshot/asset.be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824',
'test/test-data/xxxxx.test-with-snapshot-assets.js.snapshot/asset.be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824',
],
['test/test-data/cdk-integ.out.test-with-snapshot-assets'],
['test/test-data/cdk-integ.out.xxxxx.test-with-snapshot-assets.js.snapshot'],
]);
});

Expand All @@ -516,9 +516,9 @@ describe('IntegTest runIntegTests', () => {
});

expect(removeSyncMock.mock.calls).toEqual([
['test/test-data/test-with-snapshot-assets-diff.integ.snapshot'],
['test/test-data/xxxxx.test-with-snapshot-assets-diff.js.snapshot'],
[
'test/test-data/test-with-snapshot-assets-diff.integ.snapshot/asset.fec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509',
'test/test-data/xxxxx.test-with-snapshot-assets-diff.js.snapshot/asset.fec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509',
],
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('IntegTest runSnapshotTests', () => {
fileName: 'test/test-data/xxxxx.test-with-snapshot.js',
discoveryRoot: 'test/test-data',
}),
integOutDir: 'test/test-data/test-with-snapshot.integ.snapshot',
integOutDir: 'test/test-data/xxxxx.test-with-snapshot.js.snapshot',
});
const results = integTest.testSnapshot();

Expand All @@ -62,7 +62,7 @@ describe('IntegTest runSnapshotTests', () => {
CDK_INTEG_REGION: 'test-region',
}),
execCmd: ['node', 'xxxxx.test-with-snapshot.js'],
output: 'test-with-snapshot.integ.snapshot',
output: 'xxxxx.test-with-snapshot.js.snapshot',
});
expect(results.diagnostics).toEqual([]);
});
Expand All @@ -86,7 +86,7 @@ describe('IntegTest runSnapshotTests', () => {
CDK_INTEG_REGION: 'test-region',
}),
execCmd: ['node', 'xxxxx.test-with-snapshot.js'],
output: 'cdk-integ.out.test-with-snapshot',
output: 'cdk-integ.out.xxxxx.test-with-snapshot.js.snapshot',
});
expect(results.diagnostics).toEqual(expect.arrayContaining([expect.objectContaining({
reason: DiagnosticReason.SNAPSHOT_FAILED,
Expand All @@ -103,7 +103,7 @@ describe('IntegTest runSnapshotTests', () => {
fileName: 'test/test-data/xxxxx.test-with-snapshot.js',
discoveryRoot: 'test/test-data',
}),
integOutDir: 'test/test-data/test-with-snapshot-diff.integ.snapshot',
integOutDir: 'test/test-data/xxxxx.test-with-snapshot-diff.js.snapshot',
});
const results = integTest.testSnapshot();

Expand All @@ -115,7 +115,7 @@ describe('IntegTest runSnapshotTests', () => {
CDK_INTEG_ACCOUNT: '12345678',
CDK_INTEG_REGION: 'test-region',
}),
output: 'test-with-snapshot-diff.integ.snapshot',
output: 'xxxxx.test-with-snapshot-diff.js.snapshot',
});
expect(results.diagnostics).toEqual(expect.arrayContaining([
expect.objectContaining({
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('IntegTest runSnapshotTests', () => {
fileName: path.join(__dirname, '../test-data/xxxxx.test-with-new-assets-diff.js'),
discoveryRoot: 'test/test-data',
}),
integOutDir: 'test/test-data/cdk-integ.out.test-with-new-assets',
integOutDir: 'test/test-data/cdk-integ.out.xxxxx.test-with-new-assets.js.snapshot',
});
const results = integTest.testSnapshot();
expect(results.diagnostics).toEqual([]);
Expand All @@ -157,7 +157,7 @@ describe('IntegTest runSnapshotTests', () => {
CDK_INTEG_ACCOUNT: '12345678',
CDK_INTEG_REGION: 'test-region',
}),
output: 'cdk-integ.out.test-with-new-assets',
output: 'cdk-integ.out.xxxxx.test-with-new-assets.js.snapshot',
});
});

Expand All @@ -169,7 +169,7 @@ describe('IntegTest runSnapshotTests', () => {
fileName: path.join(__dirname, '../test-data/xxxxx.test-with-new-assets.js'),
discoveryRoot: 'test/test-data',
}),
integOutDir: 'test/test-data/cdk-integ.out.test-with-new-assets-diff',
integOutDir: 'test/test-data/cdk-integ.out.xxxxx.test-with-new-assets-diff.js.snapshot',
});
const results = integTest.testSnapshot();

Expand All @@ -189,7 +189,7 @@ describe('IntegTest runSnapshotTests', () => {
fileName: path.join(__dirname, '../test-data/xxxxx.test-with-snapshot-assets-diff.js'),
discoveryRoot: 'test/test-data',
}),
integOutDir: 'test/test-data/test-with-snapshot-assets.integ.snapshot',
integOutDir: 'test/test-data/xxxxx.test-with-snapshot-assets.js.snapshot',
});
const results = integTest.testSnapshot();
expect(results.diagnostics).toEqual([]);
Expand All @@ -202,7 +202,7 @@ describe('IntegTest runSnapshotTests', () => {
CDK_INTEG_ACCOUNT: '12345678',
CDK_INTEG_REGION: 'test-region',
}),
output: 'test-with-snapshot-assets.integ.snapshot',
output: 'xxxxx.test-with-snapshot-assets.js.snapshot',
});
});

Expand Down Expand Up @@ -266,7 +266,7 @@ describe('IntegTest runSnapshotTests', () => {
fileName: path.join(__dirname, '../test-data/xxxxx.test-with-snapshot-assets.js'),
discoveryRoot: 'test/test-data',
}),
integOutDir: 'test/test-data/test-with-snapshot-assets-diff.integ.snapshot',
integOutDir: 'test/test-data/xxxxx.test-with-snapshot-assets-diff.js.snapshot',
});
const results = integTest.testSnapshot();

Expand All @@ -278,7 +278,7 @@ describe('IntegTest runSnapshotTests', () => {
CDK_INTEG_ACCOUNT: '12345678',
CDK_INTEG_REGION: 'test-region',
}),
output: 'test-with-snapshot-assets-diff.integ.snapshot',
output: 'xxxxx.test-with-snapshot-assets-diff.js.snapshot',
});
expect(results.diagnostics).toEqual(expect.arrayContaining([expect.objectContaining({
reason: DiagnosticReason.SNAPSHOT_FAILED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('test runner', () => {
]),
expect.arrayContaining([
expect.stringMatching(/git/),
['checkout', 'abc', '--', 'test-with-snapshot.integ.snapshot'],
['checkout', 'abc', '--', 'xxxxx.test-with-snapshot.js.snapshot'],
expect.objectContaining({
cwd: 'test/test-data',
}),
Expand Down

0 comments on commit a884681

Please sign in to comment.