Files
react-native/private/react-native-fantom/runner/formatFantomConfig.js
T
Rubén NorteandFacebook GitHub Bot 082db1e0a7 Remove static_hermes_staging variant for Fantom tests (#52861)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52861

Changelog: [internal]

We added this mode recently to support all local Hermes variants, but this doubles the number of build type combinations which regresses test execution time and give us little benefit, so we're removing it.

Reviewed By: rshest

Differential Revision: D79080370

fbshipit-source-id: e1b536427acb98ec01edfd44829e2fef9be9b18d
2025-07-28 06:35:49 -07:00

80 lines
2.2 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import type {FeatureFlagValue} from '../../../packages/react-native/scripts/featureflags/types';
import type {FantomTestConfig} from '../runner/getFantomTestConfigs';
import type {HermesVariant} from '../runner/utils';
import {
FantomTestConfigHermesVariant,
FantomTestConfigMode,
} from '../runner/getFantomTestConfigs';
import {getOverrides} from './getFantomTestConfigs';
function formatFantomMode(mode: FantomTestConfigMode): string {
switch (mode) {
case FantomTestConfigMode.DevelopmentWithSource:
return 'mode 🐛';
case FantomTestConfigMode.DevelopmentWithBytecode:
return 'mode 🐛🔢';
case FantomTestConfigMode.Optimized:
return 'mode 🚀';
}
}
function formatFantomHermesVariant(hermesVariant: HermesVariant): string {
switch (hermesVariant) {
case FantomTestConfigHermesVariant.Hermes:
return 'hermes';
case FantomTestConfigHermesVariant.StaticHermesStable:
return 'shermes 🆕';
case FantomTestConfigHermesVariant.StaticHermesExperimental:
return 'shermes 🧪';
}
}
function formatFantomFeatureFlag(
flagName: string,
flagValue: FeatureFlagValue,
): string {
if (typeof flagValue === 'boolean') {
return `${flagName} ${flagValue ? '✅' : '🛑'}`;
}
return `🔐 ${flagName} = ${flagValue}`;
}
export default function formatFantomConfig(config: FantomTestConfig): string {
const overrides = getOverrides(config);
const parts = [];
if (overrides.mode) {
parts.push(formatFantomMode(overrides.mode));
}
if (overrides.hermesVariant) {
parts.push(formatFantomHermesVariant(overrides.hermesVariant));
}
if (overrides.flags) {
for (const flagType of ['common', 'jsOnly', 'reactInternal'] as const) {
if (overrides.flags[flagType]) {
for (const [flagName, flagValue] of Object.entries(
overrides.flags[flagType],
)) {
parts.push(formatFantomFeatureFlag(flagName, flagValue));
}
}
}
}
return parts.join(', ');
}