Files
react-native/packages/react-native-fantom/runner/formatFantomConfig.js
T
Rubén Norte cc9be3048a Add support multi-config test runs (#51542)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51542

Changelog: [internal]

This adds support for Fantom to run specific test suites with different combinations of options/flags, using wildcards as values.

See the new documentation for this feature in this diff for more details.

Reviewed By: rshest

Differential Revision: D75231299

fbshipit-source-id: 0e953e6de68f004944ee29206af49770c8b7dd9b
2025-05-23 04:24:44 -07:00

79 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 {
DEFAULT_FEATURE_FLAGS,
DEFAULT_HERMES_VARIANT,
DEFAULT_MODE,
FantomTestConfigHermesVariant,
FantomTestConfigMode,
} from '../runner/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.StaticHermes:
return 'hermes 🆕';
case FantomTestConfigHermesVariant.StaticHermesExperimental:
return 'hermes 🧪';
}
}
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 parts = [];
if (config.mode !== DEFAULT_MODE) {
parts.push(formatFantomMode(config.mode));
}
if (config.hermesVariant !== DEFAULT_HERMES_VARIANT) {
parts.push(formatFantomHermesVariant(config.hermesVariant));
}
for (const flagType of ['common', 'jsOnly', 'reactInternal'] as const) {
for (const [flagName, flagValue] of Object.entries(
config.flags[flagType],
)) {
if (flagValue !== DEFAULT_FEATURE_FLAGS[flagType][flagName]) {
parts.push(formatFantomFeatureFlag(flagName, flagValue));
}
}
}
return parts.join(', ');
}