Skip to content

Commit

Permalink
Use test name as a hint for benchmarks (#48882)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #48882

Changelog: [internal]

The current hint for benchmarks is that the test body contains `unstable_benchmark` calls, but some benchmarks that need to use feature flags define their test bodies in a separate file, so the file containing the call to `unstable_benchmark` isn't the `-itest.js` one.

This adds a new hint to opt into optimized builds that uses the name of the test instead of its contents. If it contains `-benchmark` then we consider it a benchmark and do the opt in.

Reviewed By: andrewdacenko

Differential Revision: D68102300

fbshipit-source-id: 4c0909969f76b8a7d563959cccf686aefaef700d
  • Loading branch information
rubennorte authored and facebook-github-bot committed Jan 23, 2025
1 parent 8702ed5 commit 0736234
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/react-native-fantom/runner/getFantomTestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const DEFAULT_MODE: FantomTestConfigMode =

const FANTOM_FLAG_FORMAT = /^(\w+):(\w+)$/;

const FANTOM_BENCHMARK_FILENAME_RE = /[Bb]enchmark-itest\./g;
const FANTOM_BENCHMARK_SUITE_RE = /\nunstable_benchmark(\s*)\.suite\(/g;

/**
Expand Down Expand Up @@ -107,7 +108,10 @@ export default function getFantomTestConfig(
throw new Error(`Invalid Fantom mode: ${mode}`);
}
} else {
if (FANTOM_BENCHMARK_SUITE_RE.test(testContents)) {
if (
FANTOM_BENCHMARK_FILENAME_RE.test(testPath) ||
FANTOM_BENCHMARK_SUITE_RE.test(testContents)
) {
config.mode = FantomTestConfigMode.Optimized;
}
}
Expand Down

0 comments on commit 0736234

Please sign in to comment.