From 29704b1f02103b7312c1e6df7fb163570bbcfcd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Wed, 18 Jun 2025 09:36:36 -0700 Subject: [PATCH] Add support for Static Hermes staging in Fantom (#52105) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52105 Changelog: [internal] I just learnt there's a Hermes variant that we don't support (staging) so this adds support for it. Reviewed By: christophpurrer Differential Revision: D76897715 fbshipit-source-id: 3113edde3c785d71ad4a57dd435f16e13ab46976 --- .../runner/formatFantomConfig.js | 8 +++++--- .../runner/getFantomTestConfigs.js | 16 ++++++++++------ private/react-native-fantom/runner/utils.js | 11 ++++++++--- .../FantomHermesVariantStaticHermes-itest.js | 4 ++-- ...omHermesVariantStaticHermesStaging-itest.js | 18 ++++++++++++++++++ 5 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 private/react-native-fantom/src/__tests__/FantomHermesVariantStaticHermesStaging-itest.js diff --git a/private/react-native-fantom/runner/formatFantomConfig.js b/private/react-native-fantom/runner/formatFantomConfig.js index 649750802ca..a76f3235e56 100644 --- a/private/react-native-fantom/runner/formatFantomConfig.js +++ b/private/react-native-fantom/runner/formatFantomConfig.js @@ -35,10 +35,12 @@ function formatFantomHermesVariant(hermesVariant: HermesVariant): string { switch (hermesVariant) { case FantomTestConfigHermesVariant.Hermes: return 'hermes'; - case FantomTestConfigHermesVariant.StaticHermes: - return 'hermes ๐Ÿ†•'; + case FantomTestConfigHermesVariant.StaticHermesStable: + return 'shermes ๐Ÿ†•'; + case FantomTestConfigHermesVariant.StaticHermesStaging: + return 'shermes โญ๏ธ'; case FantomTestConfigHermesVariant.StaticHermesExperimental: - return 'hermes ๐Ÿงช'; + return 'shermes ๐Ÿงช'; } } diff --git a/private/react-native-fantom/runner/getFantomTestConfigs.js b/private/react-native-fantom/runner/getFantomTestConfigs.js index 4bf783dd883..027074a7e42 100644 --- a/private/react-native-fantom/runner/getFantomTestConfigs.js +++ b/private/react-native-fantom/runner/getFantomTestConfigs.js @@ -90,7 +90,7 @@ const MAX_FANTOM_CONFIGURATION_VARIATIONS = 12; * /** * * @flow strict-local * * @fantom_mode opt - * * @fantom_hermes_variant static_hermes + * * @fantom_hermes_variant static_hermes_stable * * @fantom_flags commonTestFlag:true * * @fantom_flags jsOnlyTestFlag:true * * @fantom_react_fb_flags reactInternalFlag:true @@ -101,8 +101,8 @@ const MAX_FANTOM_CONFIGURATION_VARIATIONS = 12; * - `fantom_mode`: specifies the level of optimization to compile the test * with. Valid values are `dev`, `dev-bytecode` and `opt`. * - `fantom_hermes_variant`: specifies the Hermes variant to use to run the - * test. Valid values are `hermes`, `static_hermes` and - * `static_hermes_experimental`. + * test. Valid values are `hermes`, `static_hermes_stable`, + * `static_hermes_staging` and `static_hermes_experimental`. * - `fantom_flags`: specifies the configuration for common and JS-only feature * flags. They can be specified in the same pragma or in different ones, and * the format is `:`. @@ -187,8 +187,11 @@ export default function getFantomTestConfigs( case 'hermes': config.hermesVariant = HermesVariant.Hermes; break; - case 'static_hermes': - config.hermesVariant = HermesVariant.StaticHermes; + case 'static_hermes_stable': + config.hermesVariant = HermesVariant.StaticHermesStable; + break; + case 'static_hermes_staging': + config.hermesVariant = HermesVariant.StaticHermesStaging; break; case 'static_hermes_experimental': config.hermesVariant = HermesVariant.StaticHermesExperimental; @@ -196,7 +199,8 @@ export default function getFantomTestConfigs( case '*': configVariations.push([ {hermesVariant: HermesVariant.Hermes}, - {hermesVariant: HermesVariant.StaticHermes}, + {hermesVariant: HermesVariant.StaticHermesStable}, + {hermesVariant: HermesVariant.StaticHermesStaging}, {hermesVariant: HermesVariant.StaticHermesExperimental}, ]); break; diff --git a/private/react-native-fantom/runner/utils.js b/private/react-native-fantom/runner/utils.js index ba4664a8e77..0fbc80f7060 100644 --- a/private/react-native-fantom/runner/utils.js +++ b/private/react-native-fantom/runner/utils.js @@ -20,7 +20,8 @@ const BUCK_ISOLATION_DIR = 'react-native-fantom-buck-out'; export enum HermesVariant { Hermes, - StaticHermes, // Static Hermes Stable + StaticHermesStable, // Static Hermes Stable + StaticHermesStaging, // Static Hermes Staging StaticHermesExperimental, // Static Hermes Trunk } @@ -30,8 +31,10 @@ export function getBuckOptionsForHermes( switch (variant) { case HermesVariant.Hermes: return []; - case HermesVariant.StaticHermes: + case HermesVariant.StaticHermesStable: return ['-c hermes.static_hermes=stable']; + case HermesVariant.StaticHermesStaging: + return ['-c hermes.static_hermes=staging']; case HermesVariant.StaticHermesExperimental: return ['-c hermes.static_hermes=trunk']; } @@ -41,8 +44,10 @@ export function getHermesCompilerTarget(variant: HermesVariant): string { switch (variant) { case HermesVariant.Hermes: return '//xplat/hermes/tools/hermesc:hermesc'; - case HermesVariant.StaticHermes: + case HermesVariant.StaticHermesStable: return '//xplat/shermes/stable:hermesc'; + case HermesVariant.StaticHermesStaging: + return '//xplat/shermes/staging:hermesc'; case HermesVariant.StaticHermesExperimental: return '//xplat/static_h:hermesc'; } diff --git a/private/react-native-fantom/src/__tests__/FantomHermesVariantStaticHermes-itest.js b/private/react-native-fantom/src/__tests__/FantomHermesVariantStaticHermes-itest.js index 2f4f555b903..820b189172b 100644 --- a/private/react-native-fantom/src/__tests__/FantomHermesVariantStaticHermes-itest.js +++ b/private/react-native-fantom/src/__tests__/FantomHermesVariantStaticHermes-itest.js @@ -6,12 +6,12 @@ * * @flow strict-local * @format - * @fantom_hermes_variant static_hermes + * @fantom_hermes_variant static_hermes_stable */ declare var HermesInternal: $HermesInternalType; -describe('"@fantom_hermes_variant static_hermes" in docblock', () => { +describe('"@fantom_hermes_variant static_hermes_stable" in docblock', () => { it('should use Static Hermes', () => { expect(HermesInternal.getRuntimeProperties?.()['Static Hermes']).toBe(true); }); diff --git a/private/react-native-fantom/src/__tests__/FantomHermesVariantStaticHermesStaging-itest.js b/private/react-native-fantom/src/__tests__/FantomHermesVariantStaticHermesStaging-itest.js new file mode 100644 index 00000000000..a0ffdb11948 --- /dev/null +++ b/private/react-native-fantom/src/__tests__/FantomHermesVariantStaticHermesStaging-itest.js @@ -0,0 +1,18 @@ +/** + * 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 + * @fantom_hermes_variant static_hermes_staging + */ + +declare var HermesInternal: $HermesInternalType; + +describe('"@fantom_hermes_variant static_hermes_staging" in docblock', () => { + it('should use Static Hermes', () => { + expect(HermesInternal.getRuntimeProperties?.()['Static Hermes']).toBe(true); + }); +});