diff --git a/pylib/gyp/xcode_emulation_test.py b/pylib/gyp/xcode_emulation_test.py new file mode 100644 index 00000000..98b02320 --- /dev/null +++ b/pylib/gyp/xcode_emulation_test.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 + +"""Unit tests for the xcode_emulation.py file.""" + +from gyp.xcode_emulation import XcodeSettings +import sys +import unittest + + +class TestXcodeSettings(unittest.TestCase): + def setUp(self): + if sys.platform != "darwin": + self.skipTest("This test only runs on macOS") + + def test_GetCflags(self): + target = { + "type": "static_library", + "configurations": { + "Release": {}, + }, + } + configuration_name = "Release" + xcode_settings = XcodeSettings(target) + cflags = xcode_settings.GetCflags(configuration_name, "arm64") + + # Do not quote `-arch arm64` with spaces in one string. + self.assertEqual( + cflags, + ["-fasm-blocks", "-mpascal-strings", "-Os", "-gdwarf-2", "-arch", "arm64"], + ) + + def GypToBuildPath(self, path): + return path + + def test_GetLdflags(self): + target = { + "type": "static_library", + "configurations": { + "Release": {}, + }, + } + configuration_name = "Release" + xcode_settings = XcodeSettings(target) + ldflags = xcode_settings.GetLdflags( + configuration_name, "PRODUCT_DIR", self.GypToBuildPath, "arm64" + ) + + # Do not quote `-arch arm64` with spaces in one string. + self.assertEqual(ldflags, ["-arch", "arm64", "-LPRODUCT_DIR"]) + + +if __name__ == "__main__": + unittest.main() diff --git a/pyproject.toml b/pyproject.toml index 0c25d0b3..9dc79419 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ classifiers = [ ] [project.optional-dependencies] -dev = ["flake8", "ruff", "pytest"] +dev = ["flake8", "ruff == 0.3.0", "pytest"] [project.scripts] gyp = "gyp:script_main"