Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move utilities out of react_native_pods - Part 2 #33982

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@
"scripts/react_native_pods_utils/script_phases.rb",
"scripts/react_native_pods_utils/script_phases.sh",
"scripts/react_native_pods.rb",
"scripts/cocoapods/codegen.rb",
"scripts/cocoapods/fabric.rb",
"scripts/cocoapods/flipper.rb",
"scripts/cocoapods/new_architecture.rb",
"scripts/cocoapods",
"scripts/react-native-xcode.sh",
"sdks/.hermesversion",
"sdks/hermes-engine",
Expand Down
21 changes: 21 additions & 0 deletions scripts/cocoapods/__tests__/test_utils/EnvironmentMock.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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.

# Mock object for the Environment
class Environment
@@RUBY_PLATFORM = "arm64-darwin21"

def ruby_platform
return @@RUBY_PLATFORM
end

def self.set_ruby_platform(newPlatform)
@@RUBY_PLATFORM = newPlatform
end

def self.reset()
@@RUBY_PLATFORM = "arm64-darwin21"
end
end
29 changes: 27 additions & 2 deletions scripts/cocoapods/__tests__/test_utils/InstallerMock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,27 @@ def target_with_name(name)

class PodsProjectMock
attr_reader :targets
attr_reader :native_targets
attr_reader :path
attr_reader :build_configurations
@pod_group
attr_reader :save_invocation_count

def initialize(targets = [])
def initialize(targets = [], pod_group = {}, path = "test/path-pod.xcodeproj", build_configurations = [], native_targets: [])
@targets = targets
@pod_group = pod_group
@path = path
@build_configurations = build_configurations
@save_invocation_count = 0
@native_targets = native_targets
end

def pod_group(name)
return @pod_group[name]
end

def save()
@save_invocation_count += 1
end
end

Expand All @@ -71,13 +89,20 @@ def initialize(user_project = UserProjectMock.new)
class UserProjectMock
attr_reader :path
attr_reader :build_configurations
attr_reader :native_targets

attr_reader :save_invocation_count


def initialize(path = "/test/path.xcproj", build_configurations = [])
def initialize(path = "/test/path.xcproj", build_configurations = [], native_targets: [])
@path = path
@build_configurations = build_configurations
@native_targets = native_targets
@save_invocation_count = 0
end

def save()
@save_invocation_count += 1
end
end

Expand Down
10 changes: 10 additions & 0 deletions scripts/cocoapods/__tests__/test_utils/PodMock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,27 @@ def relative_path_from(path)
class UI

@@collected_messages = []
@@collected_warns = []

def self.puts(message)
@@collected_messages.push(message)
end

def self.warn(warn)
@@collected_warns.push(warn)
end

def self.collected_messages()
return @@collected_messages
end

def self.collected_warns()
return @@collected_warns
end

def self.reset()
@@collected_messages = []
@@collected_warns = []
end
end

Expand Down
21 changes: 21 additions & 0 deletions scripts/cocoapods/__tests__/test_utils/SysctlCheckerMock.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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.

# Mock object for SysctlChecker
class SysctlChecker
@@call_sysctl_arm64_return_value = 1

def call_sysctl_arm64
return @@call_sysctl_arm64_return_value
end

def self.set_call_sysctl_arm64_return_value(newValue)
@@call_sysctl_arm64_return_value = newValue
end

def self.reset()
@@call_sysctl_arm64_return_value = 1
end
end
Loading