diff --git a/scripts/cocoapods/__tests__/jsengine-test.rb b/scripts/cocoapods/__tests__/jsengine-test.rb index 303e99949dc9e0..14c76d0c6d810c 100644 --- a/scripts/cocoapods/__tests__/jsengine-test.rb +++ b/scripts/cocoapods/__tests__/jsengine-test.rb @@ -14,8 +14,10 @@ class JSEngineTests < Test::Unit::TestCase :react_native_path def setup + File.enable_testing_mode! @react_native_path = "../.." podSpy_cleanUp() + end def teardown @@ -25,6 +27,8 @@ def teardown Pod::UI.reset() podSpy_cleanUp() ENV['USE_HERMES'] = '1' + ENV['CI'] = nil + File.reset() end # =============== # @@ -125,16 +129,26 @@ def test_setupHermes_installsPods_installsFabricSubspecWhenFabricEnabled # TEST - isBuildingHermesFromSource # # ================================= # def test_isBuildingHermesFromSource_whenTarballIsNilAndVersionIsNotNightly_returnTrue - assert_true(is_building_hermes_from_source("1000.0.0")) + assert_true(is_building_hermes_from_source("1000.0.0", '../..')) + end + + def test_isBuildingHermesFromSource_whenTarballIsNilAndInReleaseBranch_returnTrue + ENV['CI'] = 'true' + File.mocked_existing_files(['../../sdks/.hermesversion']) + assert_true(is_building_hermes_from_source("0.999.0", '../..')) end def test_isBuildingHermesFromSource_whenTarballIsNotNil_returnFalse ENV['HERMES_ENGINE_TARBALL_PATH'] = "~/Downloads/hermes-ios-debug.tar.gz" - assert_false(is_building_hermes_from_source("1000.0.0")) + assert_false(is_building_hermes_from_source("1000.0.0", '../..')) end def test_isBuildingHermesFromSource_whenIsNigthly_returnsFalse - assert_false(is_building_hermes_from_source("0.0.0-")) + assert_false(is_building_hermes_from_source("0.0.0-", '../..')) + end + + def test_isBuildingHermesFromSource_whenIsStbleRelease_returnsFalse + assert_false(is_building_hermes_from_source("0.71.0", '../..')) end end diff --git a/scripts/cocoapods/jsengine.rb b/scripts/cocoapods/jsengine.rb index 9c82e1d8618539..48a20e6a156307 100644 --- a/scripts/cocoapods/jsengine.rb +++ b/scripts/cocoapods/jsengine.rb @@ -65,12 +65,17 @@ def remove_hermesc_build_dir(react_native_path) end def is_building_hermes_from_source(react_native_version, react_native_path) + if ENV['HERMES_ENGINE_TARBALL_PATH'] != nil + return false + end + isInMain = react_native_version.include?('1000.0.0') hermestag_file = File.join(react_native_path, "sdks", ".hermesversion") isInCI = ENV['CI'] === 'true' - isReleaseBranch = File.exists?(hermestag_file) && isInCI + isReleaseBranch = File.exist?(hermestag_file) && isInCI + return isInMain || isReleaseBranch end diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 910213464d0cce..dbd8e0d102a5d0 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -205,7 +205,7 @@ def react_native_post_install(installer, react_native_path = "../node_modules/re package = JSON.parse(File.read(File.join(react_native_path, "package.json"))) version = package['version'] - if ReactNativePodsUtils.has_pod(installer, 'hermes-engine') && is_building_hermes_from_source(version) + if ReactNativePodsUtils.has_pod(installer, 'hermes-engine') && is_building_hermes_from_source(version, react_native_path) add_copy_hermes_framework_script_phase(installer, react_native_path) else remove_copy_hermes_framework_script_phase(installer, react_native_path)