21
21
import os .path
22
22
import platform
23
23
import unittest2
24
+ from lldbsuite .test .builders .darwin import get_triple
24
25
25
26
import sys
26
27
if sys .version_info .major == 2 :
27
28
import commands as subprocess
28
29
else :
29
30
import subprocess
30
31
32
+
31
33
def execute_command (command ):
32
34
(exit_status , output ) = subprocess .getstatusoutput (command )
33
35
return exit_status
@@ -37,12 +39,42 @@ class TestSwiftPlaygrounds(TestBase):
37
39
38
40
mydir = TestBase .compute_mydir (__file__ )
39
41
42
+ def get_build_triple (self ):
43
+ """We want to build the file with a deployment target earlier than the
44
+ availability set in the source file."""
45
+ if lldb .remote_platform :
46
+ arch = self .getArchitecture ()
47
+ vendor , os , version , _ = get_triple ()
48
+ # This is made slightly more complex by watchOS having misaligned
49
+ # version numbers.
50
+ if os == 'watchos' :
51
+ version = '5.0'
52
+ else :
53
+ version = '7.0'
54
+ triple = '{}-{}-{}{}' .format (arch , vendor , os , version )
55
+ else :
56
+ triple = 'x86_64-apple-macosx10.10'
57
+ return triple
58
+
59
+ def get_run_triple (self ):
60
+ if lldb .remote_platform :
61
+ arch = self .getArchitecture ()
62
+ vendor , os , version , _ = get_triple ()
63
+ triple = '{}-{}-{}{}' .format (arch , vendor , os , version )
64
+ else :
65
+ version , _ , machine = platform .mac_ver ()
66
+ triple = '{}-apple-macosx{}' .format (machine , version )
67
+ return triple
68
+
40
69
@skipUnlessDarwin
41
70
@swiftTest
42
71
@skipIf (debug_info = decorators .no_match ("dsym" ))
43
72
def test_cross_module_extension (self ):
44
73
"""Test that playgrounds work"""
45
- self .build ()
74
+ self .build (dictionary = {
75
+ 'ARCH_SWIFTFLAGS' :
76
+ '-target {}' .format (self .get_build_triple ()),
77
+ })
46
78
self .do_test (True )
47
79
self .do_test (False )
48
80
@@ -59,15 +91,14 @@ def do_test(self, force_target):
59
91
60
92
# Create the target
61
93
if force_target :
62
- # FIXME: Construct the triple for remote runs.
63
- version , _ , machine = platform .mac_ver ()
64
- triple = '%s-apple-macosx%s' % (machine , version )
65
- target = self .dbg .CreateTargetWithFileAndArch (exe , str (triple ))
94
+ target = self .dbg .CreateTargetWithFileAndArch (
95
+ exe , self .get_run_triple ())
66
96
else :
67
97
target = self .dbg .CreateTarget (exe )
68
98
69
99
self .assertTrue (target , VALID_TARGET )
70
- self .registerSharedLibrariesWithTarget (target , ['libPlaygroundsRuntime.dylib' ])
100
+ self .registerSharedLibrariesWithTarget (target ,
101
+ ['libPlaygroundsRuntime.dylib' ])
71
102
72
103
# Set the breakpoints
73
104
breakpoint = target .BreakpointCreateBySourceRegex (
@@ -108,4 +139,3 @@ def do_test(self, force_target):
108
139
self .assertTrue ("b=\\ '5\\ '" in playground_output )
109
140
self .assertTrue ("=\\ '8\\ '" in playground_output )
110
141
self .assertTrue ("=\\ '11\\ '" in playground_output )
111
-
0 commit comments