Skip to content

Commit a6c2ad6

Browse files
chore: save the logs (#31274)
The tests for init are finding the cli's readme instead of the one it would be generating for a new app/library. When run in the cli, it's quite nice to have the README output, when we run the tests and get the cli's entire README it makes our build/test output unreadably long. This change doesn't get rid of quite all the unnecessary logs but it does decrease the log output by about 30,000 lines. ### Checklist - [ ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 1c63070 commit a6c2ad6

15 files changed

+151
-130
lines changed

packages/aws-cdk/lib/init.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,12 @@ async function initializeProject(
296296
await template.addMigrateContext(workDir);
297297
}
298298
if (await fs.pathExists('README.md')) {
299-
print(chalk.green(await fs.readFile('README.md', { encoding: 'utf-8' })));
299+
const readme = await fs.readFile('README.md', { encoding: 'utf-8' });
300+
// Save the logs!
301+
// Without this statement, the readme of the CLI is printed in every init test
302+
if (!readme.startsWith('# AWS CDK Toolkit')) {
303+
print(chalk.green(readme));
304+
}
300305
}
301306

302307
if (!generateOnly) {

packages/aws-cdk/test/api/hotswap/appsync-mapping-templates-hotswap-deployments.test.ts

+22-22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { AppSync, S3 } from 'aws-sdk';
33
import * as setup from './hotswap-test-setup';
44
import { HotswapMode } from '../../../lib/api/hotswap/common';
5+
import { silentTest } from '../../util/silent';
56

67
let hotswapMockSdkProvider: setup.HotswapMockSdkProvider;
78
let mockUpdateResolver: (params: AppSync.UpdateResolverRequest) => AppSync.UpdateResolverResponse;
@@ -22,11 +23,10 @@ beforeEach(() => {
2223
updateApiKey: mockUpdateApiKey,
2324
startSchemaCreation: mockStartSchemaCreation,
2425
});
25-
2626
});
2727

2828
describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => {
29-
test(`A new Resolver being added to the Stack returns undefined in CLASSIC mode and
29+
silentTest(`A new Resolver being added to the Stack returns undefined in CLASSIC mode and
3030
returns a noOp in HOTSWAP_ONLY mode`,
3131
async () => {
3232
// GIVEN
@@ -56,7 +56,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
5656
}
5757
});
5858

59-
test('calls the updateResolver() API when it receives only a mapping template difference in a Unit Resolver', async () => {
59+
silentTest('calls the updateResolver() API when it receives only a mapping template difference in a Unit Resolver', async () => {
6060
// GIVEN
6161
setup.setCurrentCfnStackTemplate({
6262
Resources: {
@@ -122,7 +122,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
122122
});
123123
});
124124

125-
test('calls the updateResolver() API when it receives only a mapping template difference s3 location in a Unit Resolver', async () => {
125+
silentTest('calls the updateResolver() API when it receives only a mapping template difference s3 location in a Unit Resolver', async () => {
126126
// GIVEN
127127
mockS3GetObject = jest.fn().mockImplementation(async () => {
128128
return { Body: 'template defined in s3' };
@@ -196,7 +196,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
196196
});
197197
});
198198

199-
test('calls the updateResolver() API when it receives only a code s3 location in a Pipeline Resolver', async () => {
199+
silentTest('calls the updateResolver() API when it receives only a code s3 location in a Pipeline Resolver', async () => {
200200
// GIVEN
201201
mockS3GetObject = jest.fn().mockImplementation(async () => {
202202
return { Body: 'code defined in s3' };
@@ -267,7 +267,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
267267
});
268268
});
269269

270-
test('calls the updateResolver() API when it receives only a code difference in a Pipeline Resolver', async () => {
270+
silentTest('calls the updateResolver() API when it receives only a code difference in a Pipeline Resolver', async () => {
271271
// GIVEN
272272
hotswapMockSdkProvider.stubS3({ getObject: mockS3GetObject });
273273
setup.setCurrentCfnStackTemplate({
@@ -331,7 +331,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
331331
});
332332
});
333333

334-
test('calls the updateResolver() API when it receives only a mapping template difference in a Pipeline Resolver', async () => {
334+
silentTest('calls the updateResolver() API when it receives only a mapping template difference in a Pipeline Resolver', async () => {
335335
// GIVEN
336336
setup.setCurrentCfnStackTemplate({
337337
Resources: {
@@ -399,7 +399,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
399399
});
400400
});
401401

402-
test(`when it receives a change that is not a mapping template difference in a Resolver, it does not call the updateResolver() API in CLASSIC mode
402+
silentTest(`when it receives a change that is not a mapping template difference in a Resolver, it does not call the updateResolver() API in CLASSIC mode
403403
but does call the updateResolver() API in HOTSWAP_ONLY mode`,
404404
async () => {
405405
// GIVEN
@@ -465,7 +465,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
465465
}
466466
});
467467

468-
test('does not call the updateResolver() API when a resource with type that is not AWS::AppSync::Resolver but has the same properties is changed', async () => {
468+
silentTest('does not call the updateResolver() API when a resource with type that is not AWS::AppSync::Resolver but has the same properties is changed', async () => {
469469
// GIVEN
470470
setup.setCurrentCfnStackTemplate({
471471
Resources: {
@@ -511,7 +511,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
511511
}
512512
});
513513

514-
test('calls the updateFunction() API when it receives only a mapping template difference in a Function', async () => {
514+
silentTest('calls the updateFunction() API when it receives only a mapping template difference in a Function', async () => {
515515
// GIVEN
516516
const mockListFunctions = jest.fn().mockReturnValue({ functions: [{ name: 'my-function', functionId: 'functionId' }] });
517517
hotswapMockSdkProvider.stubAppSync({ listFunctions: mockListFunctions, updateFunction: mockUpdateFunction });
@@ -571,7 +571,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
571571
});
572572
});
573573

574-
test('calls the updateFunction() API with function version when it receives both function version and runtime with a mapping template in a Function', async () => {
574+
silentTest('calls the updateFunction() API with function version when it receives both function version and runtime with a mapping template in a Function', async () => {
575575
// GIVEN
576576
const mockListFunctions = jest.fn().mockReturnValue({ functions: [{ name: 'my-function', functionId: 'functionId' }] });
577577
hotswapMockSdkProvider.stubAppSync({ listFunctions: mockListFunctions, updateFunction: mockUpdateFunction });
@@ -633,7 +633,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
633633
});
634634
});
635635

636-
test('calls the updateFunction() API with runtime when it receives both function version and runtime with code in a Function', async () => {
636+
silentTest('calls the updateFunction() API with runtime when it receives both function version and runtime with code in a Function', async () => {
637637
// GIVEN
638638
const mockListFunctions = jest.fn().mockReturnValue({ functions: [{ name: 'my-function', functionId: 'functionId' }] });
639639
hotswapMockSdkProvider.stubAppSync({ listFunctions: mockListFunctions, updateFunction: mockUpdateFunction });
@@ -692,7 +692,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
692692
});
693693
});
694694

695-
test('calls the updateFunction() API when it receives only a mapping template s3 location difference in a Function', async () => {
695+
silentTest('calls the updateFunction() API when it receives only a mapping template s3 location difference in a Function', async () => {
696696
// GIVEN
697697
mockS3GetObject = jest.fn().mockImplementation(async () => {
698698
return { Body: 'template defined in s3' };
@@ -760,7 +760,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
760760
});
761761
});
762762

763-
test(`when it receives a change that is not a mapping template difference in a Function, it does not call the updateFunction() API in CLASSIC mode
763+
silentTest(`when it receives a change that is not a mapping template difference in a Function, it does not call the updateFunction() API in CLASSIC mode
764764
but does in HOTSWAP_ONLY mode`,
765765
async () => {
766766
// GIVEN
@@ -823,7 +823,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
823823
}
824824
});
825825

826-
test('does not call the updateFunction() API when a resource with type that is not AWS::AppSync::FunctionConfiguration but has the same properties is changed', async () => {
826+
silentTest('does not call the updateFunction() API when a resource with type that is not AWS::AppSync::FunctionConfiguration but has the same properties is changed', async () => {
827827
// GIVEN
828828
setup.setCurrentCfnStackTemplate({
829829
Resources: {
@@ -871,7 +871,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
871871
}
872872
});
873873

874-
test('calls the startSchemaCreation() API when it receives only a definition difference in a graphql schema', async () => {
874+
silentTest('calls the startSchemaCreation() API when it receives only a definition difference in a graphql schema', async () => {
875875
// GIVEN
876876
mockStartSchemaCreation = jest.fn().mockReturnValueOnce({ status: 'SUCCESS' });
877877
hotswapMockSdkProvider.stubAppSync({ startSchemaCreation: mockStartSchemaCreation });
@@ -925,7 +925,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
925925
});
926926
});
927927

928-
test('calls the startSchemaCreation() API when it receives only a definition s3 location difference in a graphql schema', async () => {
928+
silentTest('calls the startSchemaCreation() API when it receives only a definition s3 location difference in a graphql schema', async () => {
929929
// GIVEN
930930
mockS3GetObject = jest.fn().mockImplementation(async () => {
931931
return { Body: 'schema defined in s3' };
@@ -988,7 +988,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
988988
});
989989
});
990990

991-
test('does not call startSchemaCreation() API when a resource with type that is not AWS::AppSync::GraphQLSchema but has the same properties is change', async () => {
991+
silentTest('does not call startSchemaCreation() API when a resource with type that is not AWS::AppSync::GraphQLSchema but has the same properties is change', async () => {
992992
// GIVEN
993993
setup.setCurrentCfnStackTemplate({
994994
Resources: {
@@ -1042,7 +1042,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
10421042
}
10431043
});
10441044

1045-
test('calls the startSchemaCreation() and waits for schema creation to stabilize before finishing', async () => {
1045+
silentTest('calls the startSchemaCreation() and waits for schema creation to stabilize before finishing', async () => {
10461046
// GIVEN
10471047
mockStartSchemaCreation = jest.fn().mockReturnValueOnce({ status: 'PROCESSING' });
10481048
const mockGetSchemaCreation = jest.fn().mockReturnValueOnce({ status: 'SUCCESS' });
@@ -1100,7 +1100,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
11001100
});
11011101
});
11021102

1103-
test('calls the startSchemaCreation() and throws if schema creation fails', async () => {
1103+
silentTest('calls the startSchemaCreation() and throws if schema creation fails', async () => {
11041104
// GIVEN
11051105
mockStartSchemaCreation = jest.fn().mockReturnValueOnce({ status: 'PROCESSING' });
11061106
const mockGetSchemaCreation = jest.fn().mockReturnValueOnce({ status: 'FAILED', details: 'invalid schema' });
@@ -1157,7 +1157,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
11571157
});
11581158
});
11591159

1160-
test('calls the updateApiKey() API when it receives only a expires property difference in an AppSync ApiKey', async () => {
1160+
silentTest('calls the updateApiKey() API when it receives only a expires property difference in an AppSync ApiKey', async () => {
11611161
// GIVEN
11621162
setup.setCurrentCfnStackTemplate({
11631163
Resources: {
@@ -1211,7 +1211,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
12111211
});
12121212
});
12131213

1214-
test('calls the updateApiKey() API when it receives only a expires property difference and no api-key-id in an AppSync ApiKey', async () => {
1214+
silentTest('calls the updateApiKey() API when it receives only a expires property difference and no api-key-id in an AppSync ApiKey', async () => {
12151215
// GIVEN
12161216
setup.setCurrentCfnStackTemplate({
12171217
Resources: {

packages/aws-cdk/test/api/hotswap/code-build-projects-hotswap-deployments.test.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/* eslint-disable import/order */
21
import { CodeBuild } from 'aws-sdk';
32
import * as setup from './hotswap-test-setup';
43
import { HotswapMode } from '../../../lib/api/hotswap/common';
4+
import { silentTest } from '../../util/silent';
55

66
let hotswapMockSdkProvider: setup.HotswapMockSdkProvider;
77
let mockUpdateProject: (params: CodeBuild.UpdateProjectInput) => CodeBuild.UpdateProjectOutput;
@@ -13,7 +13,7 @@ beforeEach(() => {
1313
});
1414

1515
describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hotswapMode) => {
16-
test('returns undefined when a new CodeBuild Project is added to the Stack', async () => {
16+
silentTest('returns undefined when a new CodeBuild Project is added to the Stack', async () => {
1717
// GIVEN
1818
const cdkStackArtifact = setup.cdkStackArtifactOf({
1919
template: {
@@ -43,7 +43,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
4343
}
4444
});
4545

46-
test('calls the updateProject() API when it receives only a source difference in a CodeBuild project', async () => {
46+
silentTest('calls the updateProject() API when it receives only a source difference in a CodeBuild project', async () => {
4747
// GIVEN
4848
setup.setCurrentCfnStackTemplate({
4949
Resources: {
@@ -96,7 +96,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
9696
});
9797
});
9898

99-
test('calls the updateProject() API when it receives only a source version difference in a CodeBuild project', async () => {
99+
silentTest('calls the updateProject() API when it receives only a source version difference in a CodeBuild project', async () => {
100100
// GIVEN
101101
setup.setCurrentCfnStackTemplate({
102102
Resources: {
@@ -148,7 +148,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
148148
});
149149
});
150150

151-
test('calls the updateProject() API when it receives only an environment difference in a CodeBuild project', async () => {
151+
silentTest('calls the updateProject() API when it receives only an environment difference in a CodeBuild project', async () => {
152152
// GIVEN
153153
setup.setCurrentCfnStackTemplate({
154154
Resources: {
@@ -254,7 +254,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
254254
});
255255
});
256256

257-
test("correctly evaluates the project's name when it references a different resource from the template", async () => {
257+
silentTest("correctly evaluates the project's name when it references a different resource from the template", async () => {
258258
// GIVEN
259259
setup.setCurrentCfnStackTemplate({
260260
Resources: {
@@ -324,7 +324,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
324324
});
325325
});
326326

327-
test("correctly falls back to taking the project's name from the current stack if it can't evaluate it in the template", async () => {
327+
silentTest("correctly falls back to taking the project's name from the current stack if it can't evaluate it in the template", async () => {
328328
// GIVEN
329329
setup.setCurrentCfnStackTemplate({
330330
Parameters: {
@@ -386,7 +386,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
386386
});
387387
});
388388

389-
test("will not perform a hotswap deployment if it cannot find a Ref target (outside the project's name)", async () => {
389+
silentTest("will not perform a hotswap deployment if it cannot find a Ref target (outside the project's name)", async () => {
390390
// GIVEN
391391
setup.setCurrentCfnStackTemplate({
392392
Parameters: {
@@ -436,7 +436,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
436436
).rejects.toThrow(/Parameter or resource 'Param1' could not be found for evaluation/);
437437
});
438438

439-
test("will not perform a hotswap deployment if it doesn't know how to handle a specific attribute (outside the project's name)", async () => {
439+
silentTest("will not perform a hotswap deployment if it doesn't know how to handle a specific attribute (outside the project's name)", async () => {
440440
// GIVEN
441441
setup.setCurrentCfnStackTemplate({
442442
Resources: {
@@ -489,7 +489,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
489489
).rejects.toThrow("We don't support the 'UnknownAttribute' attribute of the 'AWS::S3::Bucket' resource. This is a CDK limitation. Please report it at https://github.com/aws/aws-cdk/issues/new/choose");
490490
});
491491

492-
test('calls the updateProject() API when it receives a difference in a CodeBuild project with no name', async () => {
492+
silentTest('calls the updateProject() API when it receives a difference in a CodeBuild project with no name', async () => {
493493
// GIVEN
494494
setup.setCurrentCfnStackTemplate({
495495
Resources: {
@@ -541,7 +541,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
541541
});
542542
});
543543

544-
test('does not call the updateProject() API when it receives a change that is not Source, SourceVersion, or Environment difference in a CodeBuild project', async () => {
544+
silentTest('does not call the updateProject() API when it receives a change that is not Source, SourceVersion, or Environment difference in a CodeBuild project', async () => {
545545
// GIVEN
546546
setup.setCurrentCfnStackTemplate({
547547
Resources: {
@@ -592,7 +592,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
592592
}
593593
});
594594

595-
test(`when it receives a change that is not Source, SourceVersion, or Environment difference in a CodeBuild project alongside a hotswappable change,
595+
silentTest(`when it receives a change that is not Source, SourceVersion, or Environment difference in a CodeBuild project alongside a hotswappable change,
596596
it does not call the updateProject() API in CLASSIC mode, but it does in HOTSWAP_ONLY mode`,
597597
async () => {
598598
// GIVEN
@@ -650,7 +650,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
650650
});
651651
}
652652
});
653-
test('does not call the updateProject() API when a resource with type that is not AWS::CodeBuild::Project but has the same properties is changed', async () => {
653+
silentTest('does not call the updateProject() API when a resource with type that is not AWS::CodeBuild::Project but has the same properties is changed', async () => {
654654
// GIVEN
655655
setup.setCurrentCfnStackTemplate({
656656
Resources: {

0 commit comments

Comments
 (0)