From 2df19cec8288abc71d413908c5e43cdf591ba1b9 Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Tue, 27 Jun 2023 16:06:54 -0700 Subject: [PATCH] convert ProjectMock path type from string to Pathname (#38085) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38085 Changelog: [Internal] the path instance attribute on `Project` is not actually supposed to be `String`, but `Pathname`: https://www.rubydoc.info/github/CocoaPods/Xcodeproj/Xcodeproj/Project#path-instance_method i need this actually to be a pathname, so doing the refactor in this diff Reviewed By: cipolleschi Differential Revision: D47041355 fbshipit-source-id: 8b43c3a6f1cbc0f930749f380bd9d06ed44c0c37 --- .../__tests__/test_utils/InstallerMock.rb | 2 +- .../cocoapods/__tests__/test_utils/PathnameMock.rb | 3 +++ .../scripts/cocoapods/__tests__/utils-test.rb | 14 +++++++------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb b/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb index 7c1c95de4d4..9b96f82a22b 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/test_utils/InstallerMock.rb @@ -119,7 +119,7 @@ class UserProjectMock def initialize(path = "/test/path.xcproj", build_configurations = [], native_targets: []) - @path = path + @path = Pathname.new(path) @build_configurations = build_configurations @native_targets = native_targets @save_invocation_count = 0 diff --git a/packages/react-native/scripts/cocoapods/__tests__/test_utils/PathnameMock.rb b/packages/react-native/scripts/cocoapods/__tests__/test_utils/PathnameMock.rb index 0e4078fa034..19e9a5b282c 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/test_utils/PathnameMock.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/test_utils/PathnameMock.rb @@ -34,6 +34,9 @@ class Pathname return @@pwd_invocation_count end + def to_s + return @path + end def self.reset() @@pwd = "" diff --git a/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb b/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb index 82209f2dc1d..39a74d189a6 100644 --- a/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb +++ b/packages/react-native/scripts/cocoapods/__tests__/utils-test.rb @@ -324,7 +324,7 @@ class UtilsTests < Test::Unit::TestCase first_target = prepare_target("FirstTarget") second_target = prepare_target("SecondTarget") third_target = prepare_target("ThirdTarget") - user_project_mock = UserProjectMock.new("a/path", [ + user_project_mock = UserProjectMock.new("/a/path", [ prepare_config("Debug"), prepare_config("Release"), ], @@ -434,7 +434,7 @@ class UtilsTests < Test::Unit::TestCase first_target = prepare_target("FirstTarget") second_target = prepare_target("SecondTarget") third_target = prepare_target("ThirdTarget", "com.apple.product-type.bundle") - user_project_mock = UserProjectMock.new("a/path", [ + user_project_mock = UserProjectMock.new("/a/path", [ prepare_config("Debug"), prepare_config("Release"), ], @@ -492,7 +492,7 @@ class UtilsTests < Test::Unit::TestCase }), ], nil) - user_project_mock = UserProjectMock.new("a/path", [ + user_project_mock = UserProjectMock.new("/a/path", [ prepare_config("Debug"), prepare_config("Release"), ], @@ -644,7 +644,7 @@ class UtilsTests < Test::Unit::TestCase DependencyMock.new("React-ImageManager"), ]) third_target = prepare_target("ThirdTarget", "com.apple.product-type.bundle") - user_project_mock = UserProjectMock.new("a/path", [ + user_project_mock = UserProjectMock.new("/a/path", [ prepare_config("Debug"), prepare_config("Release"), ], @@ -688,7 +688,7 @@ class UtilsTests < Test::Unit::TestCase first_target = prepare_target("FirstTarget") second_target = prepare_target("SecondTarget") third_target = prepare_target("ThirdTarget", "com.apple.product-type.bundle") - user_project_mock = UserProjectMock.new("a/path", [ + user_project_mock = UserProjectMock.new("/a/path", [ prepare_config("Debug"), prepare_config("Release"), ], @@ -750,7 +750,7 @@ class UtilsTests < Test::Unit::TestCase first_target = prepare_target("FirstTarget") second_target = prepare_target("SecondTarget") third_target = prepare_target("ThirdTarget", "com.apple.product-type.bundle") - user_project_mock = UserProjectMock.new("a/path", [ + user_project_mock = UserProjectMock.new("/a/path", [ prepare_config("Debug"), prepare_config("Release"), ], @@ -779,7 +779,7 @@ end # ===== # def prepare_empty_user_project_mock - return UserProjectMock.new("a/path", [ + return UserProjectMock.new("/a/path", [ BuildConfigurationMock.new("Debug"), BuildConfigurationMock.new("Release"), ])