Fix stateful regex bug in benchmark detection#56423
Closed
rubennorte wants to merge 1 commit intofacebook:mainfrom
Closed
Fix stateful regex bug in benchmark detection#56423rubennorte wants to merge 1 commit intofacebook:mainfrom
rubennorte wants to merge 1 commit intofacebook:mainfrom
Conversation
Summary: Changelog: [internal] The `FANTOM_BENCHMARK_FILENAME_RE` and `FANTOM_BENCHMARK_SUITE_RE` regexes used the `g` (global) flag, which makes `.test()` stateful — it preserves `lastIndex` between calls. When `getFantomTestConfigs` is called for multiple test files in the same process, the stale `lastIndex` from a previous successful match causes `.test()` to miss the match on the next file, returning `false`. This results in benchmark files intermittently getting the default dev config (`isJsOptimized: false`, `dev: true`), causing them to fail at runtime with "Benchmarks should not be run in development mode". Removes the `g` flag from both regexes since they are used with `.test()` across different strings and should be stateless. Differential Revision: D100603612
|
@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100603612. |
|
This pull request has been merged in 4bdfaf2. |
Collaborator
|
This pull request was successfully merged by @rubennorte in 4bdfaf2 When will my fix make it into a release? | How to file a pick request? |
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.
Summary:
Changelog: [internal]
The
FANTOM_BENCHMARK_FILENAME_REandFANTOM_BENCHMARK_SUITE_REregexes used theg(global) flag, which makes.test()stateful — it preserveslastIndexbetween calls. WhengetFantomTestConfigsis called for multiple test files in the same process, the stalelastIndexfrom a previous successful match causes.test()to miss the match on the next file, returningfalse. This results in benchmark files intermittently getting the default dev config (isJsOptimized: false,dev: true), causing them to fail at runtime with "Benchmarks should not be run in development mode".Removes the
gflag from both regexes since they are used with.test()across different strings and should be stateless.Differential Revision: D100603612