diff --git a/scripts/react_native_pods_utils/__tests__/script_phases.snap.rb b/scripts/react_native_pods_utils/__tests__/script_phases.snap.rb new file mode 100644 index 00000000000..b0b5ce13fd7 --- /dev/null +++ b/scripts/react_native_pods_utils/__tests__/script_phases.snap.rb @@ -0,0 +1,43 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +def snap_get_script_phases_with_codegen_discovery() + return <<~EOS + pushd "$PODS_ROOT/../" > /dev/null + RCT_SCRIPT_POD_INSTALLATION_ROOT=$(pwd) + popd >/dev/null + + export RCT_SCRIPT_RN_DIR=$RCT_SCRIPT_POD_INSTALLATION_ROOT/../.. + export RCT_SCRIPT_APP_PATH=$RCT_SCRIPT_POD_INSTALLATION_ROOT/ + export RCT_SCRIPT_CONFIG_FILE_DIR=$RCT_SCRIPT_POD_INSTALLATION_ROOT/node_modules + export RCT_SCRIPT_OUTPUT_DIR=$RCT_SCRIPT_POD_INSTALLATION_ROOT + export RCT_SCRIPT_FABRIC_ENABLED=true + export RCT_SCRIPT_TYPE=withCodegenDiscovery + + SCRIPT_PHASES_SCRIPT=\"$RCT_SCRIPT_RN_DIR/scripts/react_native_pods_utils/script_phases.sh\" + /bin/sh -c \"$SCRIPT_PHASES_SCRIPT\" + EOS +end + +def snap_get_script_phases_no_codegen_discovery() + return <<~EOS + pushd "$PODS_ROOT/../" > /dev/null + RCT_SCRIPT_POD_INSTALLATION_ROOT=$(pwd) + popd >/dev/null + + export RCT_SCRIPT_RN_DIR=${PODS_TARGET_SRCROOT}/../../.. + export RCT_SCRIPT_LIBRARY_NAME=ScreenshotmanagerSpec + export RCT_SCRIPT_OUTPUT_DIR=$RCT_SCRIPT_POD_INSTALLATION_ROOT/build/generated/ios + export RCT_SCRIPT_LIBRARY_TYPE=modules + export RCT_SCRIPT_JS_SRCS_PATTERN=Native*.js + export RCT_SCRIPT_JS_SRCS_DIR=./ + export RCT_SCRIPT_CODEGEN_MODULE_DIR=. + export RCT_SCRIPT_CODEGEN_COMPONENT_DIR=react/renderer/components + export RCT_SCRIPT_FILE_LIST=\"[\\\".//NativeScreenshotManager.js\\\"]\" + + SCRIPT_PHASES_SCRIPT=\"$RCT_SCRIPT_RN_DIR/scripts/react_native_pods_utils/script_phases.sh\" + /bin/sh -c \"$SCRIPT_PHASES_SCRIPT\" + EOS +end diff --git a/scripts/react_native_pods_utils/__tests__/script_phases.test.rb b/scripts/react_native_pods_utils/__tests__/script_phases.test.rb new file mode 100644 index 00000000000..2216bd58a7e --- /dev/null +++ b/scripts/react_native_pods_utils/__tests__/script_phases.test.rb @@ -0,0 +1,36 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +require_relative "../script_phases" +require_relative "./script_phases.snap" +require 'minitest/autorun' + +class TestScriptPhases < Minitest::Test + + def test_get_script_phases_with_codegen_discovery + result = get_script_phases_with_codegen_discovery( + react_native_path: '../..', + relative_app_root: '', + relative_config_file_dir: 'node_modules', + fabric_enabled: true) + assert_equal snap_get_script_phases_with_codegen_discovery, result + end + + def test_get_script_phases_no_codegen_discovery() + result = get_script_phases_no_codegen_discovery( + react_native_path: '../../..', + codegen_output_dir: 'build/generated/ios', + codegen_module_dir: '.', + codegen_component_dir: 'react/renderer/components', + library_name: 'ScreenshotmanagerSpec', + library_type: 'modules', + js_srcs_pattern: 'Native*.js', + js_srcs_dir: './', + file_list: '[".//NativeScreenshotManager.js"]' + ) + assert_equal snap_get_script_phases_no_codegen_discovery, result + end + + end