File tree Expand file tree Collapse file tree 5 files changed +46
-1
lines changed
packages/react-native/src/private/__tests__
private/react-native-fantom Expand file tree Collapse file tree 5 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 55 * LICENSE file in the root directory of this source tree.
66 *
77 * @fantom_mode *
8+ * @fantom_disable_coverage
89 * @flow strict-local
910 * @format
1011 */
Original file line number Diff line number Diff line change @@ -147,6 +147,9 @@ Available pragmas:
147147 - Possible values:
148148 - ` true ` : using Hermes bytecode
149149 - ` false ` : not using Hermes bytecode
150+ - ` @fantom_disable_coverage ` : used to disable coverage collection for the test.
151+ - Example: ` @fantom_disable_coverage `
152+ - Does not require a value.
150153- ` @fantom_react_fb_flags ` : used to set overrides for internal React flags set
151154 in ReactNativeInternalFeatureFlags (Meta use only)
152155
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ *
7+ * @flow strict-local
8+ * @format
9+ */
10+
11+ // $FlowExpectedError[untyped-import]
12+ import { extract , parse } from 'jest-docblock' ;
13+
14+ type DocblockPragmas = { [ key : string ] : string | string [ ] } ;
15+
16+ const FANTOM_BENCHMARK_FILENAME_RE = / [ B b ] e n c h m a r k - i t e s t \. / g;
17+
18+ export function shouldCollectCoverage (
19+ testPath : string ,
20+ testContents : string ,
21+ globalConfig : { collectCoverage : boolean , ...} ,
22+ ) : boolean {
23+ if ( FANTOM_BENCHMARK_FILENAME_RE . test ( testPath ) ) {
24+ return false ;
25+ }
26+
27+ const docblock = extract ( testContents ) ;
28+ const pragmas = parse ( docblock ) as DocblockPragmas ;
29+
30+ if ( pragmas . fantom_disable_coverage != null ) {
31+ return false ;
32+ }
33+
34+ return globalConfig . collectCoverage ;
35+ }
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ const VALID_FANTOM_PRAGMAS = [
8585 'fantom_flags' ,
8686 'fantom_hermes_variant' ,
8787 'fantom_react_fb_flags' ,
88+ 'fantom_disable_coverage' ,
8889] ;
8990
9091export function getOverrides (
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import type {
2424
2525import { printBenchmarkResultsRanking } from './benchmarkUtils' ;
2626import { createBundle , createSourceMap } from './bundling' ;
27+ import { shouldCollectCoverage } from './coverageUtils' ;
2728import entrypointTemplate from './entrypoint-template' ;
2829import * as EnvironmentOptions from './EnvironmentOptions' ;
2930import { run as runHermesCompiler } from './executables/hermesc' ;
@@ -343,7 +344,11 @@ module.exports = async function runTest(
343344 sourceMap : true ,
344345 sourceMapUrl : sourceMapPath ,
345346 customTransformOptions : {
346- collectCoverage : globalConfig . collectCoverage ,
347+ collectCoverage : shouldCollectCoverage (
348+ testPath ,
349+ testContents ,
350+ globalConfig ,
351+ ) ,
347352 } ,
348353 } ;
349354
You can’t perform that action at this time.
0 commit comments