aws / aws/aws-cdk

cdk-build-tools: testFutureBehavior/testLegacyBehavior outdated for CDK v2

Open
#20,890 0 comments 0 reactions 0 assignees View on GitHub
aws-cdk-lib bug effort/medium p1 package/tools
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

Methods `testFutureBehavior` and `testLegacyBehavior` were modified for CDK v2 development:
- `testFutureBehavior` ignores feature flags in CDK v2 because all feature flags are enabled by default
- Tests in `testLegacyBehavior` will be ignored because there is no legacy behavior when CDK v2 was released

This logic was correct during the development of CDK v2. Now, it must be possible to add new feature flags.

Instead of checking for version `2` in the following line, we need to change it to version `3`:
https://github.com/aws/aws-cdk/blob/2151a0e9b988723e050e6f37ed1780cced16c519/tools/%40aws-cdk/cdk-build-tools/lib/feature-flag.ts#L32

### Expected Behavior

- `testFutureBehavior` supports new feature flags
- `testLegacyBehavior` executes tests without feature flag

### Current Behavior

- `testFutureBehavior` doesn't support adding feature flags
- Tests in `testLegacyBehavior` will be skipped

### Reproduction Steps

Test cases in PR #18140 fail because `testFutureBehavior` doesn't execute the correct behavior after target branch of this PR was changed to v2 main branch.

### Possible Solution

Replace version `2` by `3` in the following lines:

https://github.com/aws/aws-cdk/blob/2151a0e9b988723e050e6f37ed1780cced16c519/tools/%40aws-cdk/cdk-build-tools/lib/feature-flag.ts#L32

https://github.com/aws/aws-cdk/blob/2151a0e9b988723e050e6f37ed1780cced16c519/tools/%40aws-cdk/cdk-build-tools/lib/feature-flag.ts#L60

### Additional Information/Context

_No response_

### CDK CLI Version

2.29.0

### Framework Version

_No response_

### Node.js Version

v16.15.1

### OS

MacOS

### Language

Typescript

### Language Version

_No response_

### Other information

I can create a PR to fix this issue. Please let me know if the proposed solution is correct.

Contributor guide

Open the contributing guide

Research direction

Start in tools/@aws-cdk/cdk-build-tools/lib/feature-flag.ts at the version checks on lines 32 and 60. Review the test cases referenced from PR #18140, then verify that testFutureBehavior supports new feature flags and testLegacyBehavior executes tests without a feature flag.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.