4a8c6bf8692d81eeae26ec3380ef0554566d39f9ae87bfb8cac47c3619b5a77c2d7ddc37db6027f63ea2e216a13ddb54d6f94361f677b2e57e029c382386fb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python3
  2. """Unit tests for the xcode_emulation.py file."""
  3. from gyp.xcode_emulation import XcodeSettings
  4. import sys
  5. import unittest
  6. class TestXcodeSettings(unittest.TestCase):
  7. def setUp(self):
  8. if sys.platform != "darwin":
  9. self.skipTest("This test only runs on macOS")
  10. def test_GetCflags(self):
  11. target = {
  12. "type": "static_library",
  13. "configurations": {
  14. "Release": {},
  15. },
  16. }
  17. configuration_name = "Release"
  18. xcode_settings = XcodeSettings(target)
  19. cflags = xcode_settings.GetCflags(configuration_name, "arm64")
  20. # Do not quote `-arch arm64` with spaces in one string.
  21. self.assertEqual(
  22. cflags,
  23. ["-fasm-blocks", "-mpascal-strings", "-Os", "-gdwarf-2", "-arch", "arm64"],
  24. )
  25. def GypToBuildPath(self, path):
  26. return path
  27. def test_GetLdflags(self):
  28. target = {
  29. "type": "static_library",
  30. "configurations": {
  31. "Release": {},
  32. },
  33. }
  34. configuration_name = "Release"
  35. xcode_settings = XcodeSettings(target)
  36. ldflags = xcode_settings.GetLdflags(
  37. configuration_name, "PRODUCT_DIR", self.GypToBuildPath, "arm64"
  38. )
  39. # Do not quote `-arch arm64` with spaces in one string.
  40. self.assertEqual(ldflags, ["-arch", "arm64", "-LPRODUCT_DIR"])
  41. if __name__ == "__main__":
  42. unittest.main()