Improve type checking of test macros#3873
Closed
henrymercer wants to merge 19 commits intomainfrom
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves TypeScript type checking in the AVA test suite by introducing small wrapper functions around test.macro(...) invocations, so macro arguments are type-checked at the wrapper call sites (instead of being erased/widened when passed directly through test(...)/test.serial(...)).
Changes:
- Added typed wrapper helper functions around several AVA macros to preserve argument type checking.
- Renamed some macro constants to
*Macroand updated call sites to use the new wrappers. - Minor refactor in one test loop to iterate over
BuiltInLanguagevalues when generating repeated test cases.
Show a summary per file
| File | Description |
|---|---|
| src/upload-sarif.test.ts | Adds testPostProcessAndUploadSarif(...) wrapper around the upload macro. |
| src/status-report.test.ts | Renames macro constant and adds testCreateInitWithConfigStatusReport(...) wrapper. |
| src/start-proxy.test.ts | Renames macros and adds wrappers for sendFailedStatusReport, getCredentials, and wrapFailure macro usage. |
| src/setup-codeql.test.ts | Adds testToolcacheInputFallback(...) wrapper around the toolcache fallback macro. |
| src/overlay/caching.test.ts | Renames macro constant and adds testDownloadOverlayBaseDatabaseFromCache(...) wrapper. |
| src/init.test.ts | Renames macro constant and adds testCheckPacksForOverlayCompatibility(...) wrapper. |
| src/init-action-post-helper.test.ts | Renames macro constant and adds testSkippedUpload(...) wrapper. |
| src/diff-informed-analysis-utils.test.ts | Renames macro constant and adds testShouldPerformDiffInformedAnalysis(...) wrapper. |
| src/config/db-config.test.ts | Adds wrappers for several macros (parsePacks, invalid pack names, pretty printing, augmentation tests). |
| src/config-utils.test.ts | Adds testCheckOverlayEnablement(...) wrapper and updates repeated test generation loop. |
| src/codeql.test.ts | Adds testInjectedConfig(...) wrapper around the injected config macro. |
Copilot's findings
- Files reviewed: 11/11 changed files
- Comments generated: 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When invoked via
testortest.serial, detailed argument types are erased and we lose some type safety.This PR wraps macro invocations in helper functions to ensure each of the arguments to the macros is type checked properly.
Dev/test only change.