Skip to content

Commit 09b1f24

Browse files
test(cdk): add executable guard that Lambda bundling is disabled (#366)
PR #371 review finding 1: the ~15× synth speedup rested entirely on the `disable-bundling.ts` setupFiles entry, but the only regression guards were honor-system prose (AGENTS.md) and a review_pr.md checklist item. Dropping the setupFiles wiring, reordering Jest setup, or a CDK rename of the context key would silently revert the suite to full-bundling synths with no failing check. Adds two assertions: the synth context carries `aws:cdk:bundling-stacks: []`, and a bare-App stack reports `bundlingRequired === false`. Verified empirically against aws-cdk-lib@2.259.0 that without the disable a bare App yields `bundlingRequired === true`, so these discriminate a real regression. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 94c604e commit 09b1f24

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* MIT No Attribution
3+
*
4+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software, and to permit persons to whom the Software is furnished to do so.
10+
*
11+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17+
* SOFTWARE.
18+
*/
19+
20+
// Executable guard for the global Lambda-bundling disable (#366).
21+
//
22+
// The speedup in this package depends entirely on `test/setup/disable-bundling.ts`
23+
// running as a Jest `setupFiles` entry. Until now the only regression guards
24+
// were prose in AGENTS.md and a checklist item in review_pr.md — both
25+
// honor-system. If someone drops the `setupFiles` wiring, reorders Jest setup,
26+
// or a CDK rename breaks the context key, the suite silently reverts to a
27+
// full-bundling (~15× slower) synth with no failing check. These assertions
28+
// make that floor machine-enforced.
29+
import { App, Stack } from 'aws-cdk-lib';
30+
31+
describe('global Lambda bundling disable', () => {
32+
it('sets aws:cdk:bundling-stacks to [] in the synth context', () => {
33+
// A bare `new App()` reads CDK_CONTEXT_JSON, which setupFiles populated.
34+
expect(new App().node.tryGetContext('aws:cdk:bundling-stacks')).toEqual([]);
35+
});
36+
37+
it('makes a bare-App stack report bundlingRequired === false', () => {
38+
const stack = new Stack(new App(), 'BundlingProbe', {
39+
env: { account: '123456789012', region: 'us-east-1' },
40+
});
41+
expect(stack.bundlingRequired).toBe(false);
42+
});
43+
});

0 commit comments

Comments
 (0)