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