Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(integ-runner): support --language presets for TypeScript and JavaScript #22927

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions packages/@aws-cdk/integ-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,18 @@
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/cdk-build-tools": "0.0.0",
"@types/mock-fs": "^4.13.1",
"mock-fs": "^4.14.0",
"@aws-cdk/core": "^0.0.0",
"@aws-cdk/integ-tests": "^0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/fs-extra": "^8.1.2",
"@types/jest": "^27.5.2",
"@types/mock-fs": "^4.13.1",
"@types/node": "^14.18.33",
"@types/workerpool": "^6.1.0",
"@types/yargs": "^15.0.14",
"jest": "^27.5.1"
"constructs": "^10.0.0",
"jest": "^27.5.1",
"mock-fs": "^4.14.0"
},
"dependencies": {
"@aws-cdk/cloud-assembly-schema": "0.0.0",
Expand Down
11 changes: 11 additions & 0 deletions packages/@aws-cdk/integ-runner/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,15 @@ describe('CLI', () => {
].join('\n'),
]]);
});

test('find only TypeScript files', async () => {
await main(['--list', '--language', 'typescript', '--directory=test/test-data-typescript', '--test-regex="^xxxxx\\..*(?<!\\.d)\\.ts$"']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await main(['--list', '--language', 'typescript', '--directory=test/test-data-typescript', '--test-regex="^xxxxx\\..*(?<!\\.d)\\.ts$"']);
await main(['--list', '--language', 'typescript', '--directory=test/test-data-typescript']);

Otherwise this is just testing the regex, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test won't be picked up if we don't specify the regex, because it doesn't have the standard prefix integ. but rather xxxxx.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see comment re renaming the test file.
#22927 (comment)


expect(stdoutMock.mock.calls).toEqual([[
[
'xxxxx.typescript-test.ts',
'',
].join('\n'),
]]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -594,26 +594,26 @@ describe('IntegTest runIntegTests', () => {
const integTest = new IntegTestRunner({
cdk: cdkMock.cdk,
test: new IntegTest({
fileName: 'test/test-data/xxxxx.test-with-snapshot.ts',
discoveryRoot: 'test/test-data',
fileName: 'test/test-data-typescript/xxxxx.typescript-test.ts',
discoveryRoot: 'test/test-data-typescript',
}),
});
integTest.runIntegTestCase({
testCaseName: 'xxxxx.test-with-snapshot',
testCaseName: 'xxxxx.typescript-test',
});

// THEN
expect(deployMock).toHaveBeenCalledTimes(2);
expect(deployMock).toHaveBeenCalledTimes(1);
expect(destroyMock).toHaveBeenCalledTimes(1);
expect(synthFastMock).toHaveBeenCalledTimes(1);
expect(deployMock).toHaveBeenCalledWith(expect.objectContaining({
app: 'node -r ts-node/register xxxxx.test-with-snapshot.ts',
app: 'node -r ts-node/register xxxxx.typescript-test.ts',
}));
expect(synthFastMock).toHaveBeenCalledWith(expect.objectContaining({
execCmd: ['node', '-r', 'ts-node/register', 'xxxxx.test-with-snapshot.ts'],
execCmd: ['node', '-r', 'ts-node/register', 'xxxxx.typescript-test.ts'],
}));
expect(destroyMock).toHaveBeenCalledWith(expect.objectContaining({
app: 'node -r ts-node/register xxxxx.test-with-snapshot.ts',
app: 'node -r ts-node/register xxxxx.typescript-test.ts',
}));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { App, Stack } from '@aws-cdk/core';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is okay to be named integ.typescript-test.ts

(The other ones aren't because they are empty files that only need to exist for mocking purposes and we should probably try to just get rid of them at some point)

import { IntegTest } from '@aws-cdk/integ-tests';

const app = new App();
const stack = new Stack();

new IntegTest(app, 'Integ', { testCases: [stack] });

app.synth();
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "21.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
"path": "IntegDefaultTestDeployAssert4E6713E1.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"21.0.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "21.0.0",
"testCases": {
"Integ/DefaultTest": {
"stacks": [
"Default"
],
"assertionStack": "Integ/DefaultTest/DeployAssert",
"assertionStackName": "IntegDefaultTestDeployAssert4E6713E1"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"version": "21.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"IntegDefaultTestDeployAssert4E6713E1.assets": {
"type": "cdk:asset-manifest",
"properties": {
"file": "IntegDefaultTestDeployAssert4E6713E1.assets.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"IntegDefaultTestDeployAssert4E6713E1": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "IntegDefaultTestDeployAssert4E6713E1.template.json",
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
"IntegDefaultTestDeployAssert4E6713E1.assets"
],
"lookupRole": {
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
"requiresBootstrapStackVersion": 8,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"dependencies": [
"IntegDefaultTestDeployAssert4E6713E1.assets"
],
"metadata": {
"/Integ/DefaultTest/DeployAssert/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "BootstrapVersion"
}
],
"/Integ/DefaultTest/DeployAssert/CheckBootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
]
},
"displayName": "Integ/DefaultTest/DeployAssert"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"version": "tree-0.1",
"tree": {
"id": "App",
"path": "",
"children": {
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.161"
}
},
"Integ": {
"id": "Integ",
"path": "Integ",
"children": {
"DefaultTest": {
"id": "DefaultTest",
"path": "Integ/DefaultTest",
"children": {
"Default": {
"id": "Default",
"path": "Integ/DefaultTest/Default",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.161"
}
},
"DeployAssert": {
"id": "DeployAssert",
"path": "Integ/DefaultTest/DeployAssert",
"constructInfo": {
"fqn": "@aws-cdk/core.Stack",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/integ-tests.IntegTestCase",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/integ-tests.IntegTest",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/core.App",
"version": "0.0.0"
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading