Skip to content

Commit

Permalink
Fix ruby unit tests (facebook#48498)
Browse files Browse the repository at this point in the history
Summary:
As a prerequisite of enabling running unit tests on CI again, this PR suggests changes needed to the Ruby unit tests.

I've added comments on the code below, justifying changes where I deem a justification might be needed.

For use internally, I suggest accessing the folly_config and boost_config directly via the `Helpers` class instead of the `get_folly_config` and `get_boost_config` because these global functions are defined in `react_native_pods` which would be result in circular requires. An alternative would be to move these global functions to a separate file.

## Changelog:

[INTERNAL] [FIXED] - Fix Ruby unit tests.

Pull Request resolved: facebook#48498

Test Plan:
- `cd packages/react-native`
- `./scripts/run_ruby_tests.sh`

Reviewed By: rshest

Differential Revision: D67852809

Pulled By: cipolleschi

fbshipit-source-id: 54d8bd708a9e3fd9aef3569ac89ec6ddcd244437
  • Loading branch information
kraenhansen authored and facebook-github-bot committed Jan 6, 2025
1 parent 5ce0738 commit 7a85b91
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,10 @@ def get_podspec_no_fabric_no_script
'source' => { :git => '' },
'header_mappings_dir' => './',
'platforms' => {
:ios => '13.4',
:ios => '15.1',
},
'source_files' => "**/*.{h,mm,cpp}",
'exclude_files' => "RCTAppDependencyProvider.{h,mm}",
'pod_target_xcconfig' => {
"FRAMEWORK_SEARCH_PATHS" => [],
"HEADER_SEARCH_PATHS" =>
Expand All @@ -530,6 +531,17 @@ def get_podspec_no_fabric_no_script
"\"$(PODS_ROOT)/Headers/Private/React-RCTFabric\"",
"\"$(PODS_ROOT)/Headers/Private/Yoga\"",
"\"$(PODS_TARGET_SRCROOT)\"",
].join(' '),
'OTHER_CPLUSPLUSFLAGS' => [
'$(inherited)',
'-DFOLLY_NO_CONFIG',
'-DFOLLY_MOBILE=1',
'-DFOLLY_USE_LIBCPP=1',
'-DFOLLY_CFG_NO_COROUTINES=1',
'-DFOLLY_HAVE_CLOCK_GETTIME=1',
'-Wno-comma',
'-Wno-shorten-64-to-32',
'-Wno-documentation'
].join(' ')
},
'dependencies': {
Expand All @@ -544,6 +556,7 @@ def get_podspec_no_fabric_no_script
"ReactCommon/turbomodule/core": [],
"hermes-engine": [],
"React-NativeModulesApple": [],
'React-RCTAppDelegate': [],
"glog": [],
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
require_relative "./test_utils/SpecMock.rb"
require_relative "./test_utils/FileMock.rb"

def get_folly_config()
return Helpers::Constants.folly_config
end

## Monkey patching to reset properly static props of the Helper.
class NewArchitectureHelper
def self.reset
Expand Down
8 changes: 4 additions & 4 deletions packages/react-native/scripts/cocoapods/codegen_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ def generate_react_codegen_podspec!(spec, codegen_output_dir, file_manager: File
# - hermes_enabled: whether hermes is enabled or not.
# - script_phases: whether we want to add some build script phases or not.
# - file_manager: a class that implements the `File` interface. Defaults to `File`, the Dependency can be injected for testing purposes.
def get_react_codegen_spec(package_json_file, folly_version: get_folly_config()[:version], hermes_enabled: true, script_phases: nil, file_manager: File, logger: CodegenUtils::UI)
def get_react_codegen_spec(package_json_file, folly_version: Helpers::Constants.folly_config[:version], hermes_enabled: true, script_phases: nil, file_manager: File, logger: CodegenUtils::UI)
package = JSON.parse(file_manager.read(package_json_file))
version = package['version']
use_frameworks = ENV['USE_FRAMEWORKS'] != nil

folly_compiler_flags = get_folly_config()[:compiler_flags]
boost_compiler_flags = get_boost_config()[:compiler_flags]
folly_compiler_flags = Helpers::Constants.folly_config[:compiler_flags]
boost_compiler_flags = Helpers::Constants.boost_config[:compiler_flags]

header_search_paths = [
"\"$(PODS_ROOT)/boost\"",
Expand Down Expand Up @@ -282,7 +282,7 @@ def use_react_native_codegen_discovery!(
config_file_dir: '',
codegen_output_dir: 'build/generated/ios',
config_key: 'codegenConfig',
folly_version: get_folly_config()[:version],
folly_version: Helpers::Constants.folly_config[:version],
codegen_utils: CodegenUtils.new(),
file_manager: File,
logger: CodegenUtils::UI
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native/scripts/cocoapods/new_architecture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def self.modify_flags_for_new_architecture(installer, is_new_arch_enabled)
end
end

def self.install_modules_dependencies(spec, new_arch_enabled, folly_version = get_folly_config()[:version])
def self.install_modules_dependencies(spec, new_arch_enabled, folly_version = Helpers::Constants.folly_config[:version])
# Pod::Specification does not have getters so, we have to read
# the existing values from a hash representation of the object.
folly_config = get_folly_config()
folly_config = Helpers::Constants.folly_config
folly_compiler_flags = folly_config[:compiler_flags]

hash = spec.to_hash
Expand Down Expand Up @@ -145,7 +145,7 @@ def self.install_modules_dependencies(spec, new_arch_enabled, folly_version = ge
end

def self.folly_compiler_flags
folly_config = get_folly_config()
folly_config = Helpers::Constants.folly_config
return folly_config[:compiler_flags]
end

Expand Down

0 comments on commit 7a85b91

Please sign in to comment.