@@ -88,6 +88,7 @@ def test_no_force_target(self):
8888    @swiftTest  
8989    @skipIf (setting = ('symbols.use-swift-clangimporter' , 'false' )) 
9090    @skipIf (debug_info = decorators .no_match ("dsym" )) 
91+     @skipIf (macos_version = ["<" , "12" ]) 
9192    def  test_concurrency (self ):
9293        """Test that concurrency is available in playgrounds""" 
9394        self .launch (True )
@@ -100,8 +101,7 @@ def test_concurrency(self):
100101    def  test_import (self ):
101102        """Test that a dylib can be imported in playgrounds""" 
102103        self .launch (True )
103-         self .do_concurrency_test ()
104- 
104+         self .do_import_test ()
105105
106106    def  launch (self , force_target ):
107107        """Test that playgrounds work""" 
@@ -145,47 +145,56 @@ def launch(self, force_target):
145145        self .options .SetTryAllThreads (True )
146146
147147
148-     def  do_basic_test (self , force_target ):
149-         contents  =  "" 
150- 
151-         with  open ('Contents.swift' , 'r' ) as  contents_file :
148+     def  execute_code (self , input_file , expect_error = False ):
149+         contents  =  "syntax error" 
150+         with  open (input_file , 'r' ) as  contents_file :
152151            contents  =  contents_file .read ()
153- 
154-         self .frame ().EvaluateExpression (contents , self .options )
152+         res  =  self .frame ().EvaluateExpression (contents , self .options )
155153        ret  =  self .frame ().EvaluateExpression ("get_output()" )
154+         is_error  =  res .GetError ().Fail () and  not  (
155+                      res .GetError ().GetType () ==  1  and 
156+                      res .GetError ().GetError () ==  0x1001 )
156157        playground_output  =  ret .GetSummary ()
158+         with  recording (self , self .TraceOn ()) as  sbuf :
159+             print ("playground result: " , file = sbuf )
160+             print (str (res ), file = sbuf )
161+             if  is_error :
162+                 print ("error:" , file = sbuf )
163+                 print (str (res .GetError ()), file = sbuf )
164+             else :
165+                 print ("playground output:" , file = sbuf )
166+                 print (str (ret ), file = sbuf )
167+ 
168+         if  expect_error :
169+             self .assertTrue (is_error )
170+             return  playground_output 
171+         self .assertFalse (is_error )
172+         self .assertIsNotNone (playground_output )
173+         return  playground_output 
174+         
175+     def  do_basic_test (self , force_target ):
176+         playground_output  =  self .execute_code ('Contents.swift' , not  force_target )
157177        if  not  force_target :
158178            # This is expected to fail because the deployment target 
159179            # is less than the availability of the function being 
160180            # called. 
161181            self .assertEqual (playground_output , '""' )
162182            return 
163183
164-         self .assertTrue (playground_output  is  not None )
165-         self .assertTrue ("a=\\ '3\\ '"  in  playground_output )
166-         self .assertTrue ("b=\\ '5\\ '"  in  playground_output )
167-         self .assertTrue ("=\\ '8\\ '"  in  playground_output )
168-         self .assertTrue ("=\\ '11\\ '"  in  playground_output )
184+         self .assertIn ("a=\\ '3\\ '" , playground_output )
185+         self .assertIn ("b=\\ '5\\ '" , playground_output )
186+         self .assertIn ("=\\ '8\\ '" , playground_output )
187+         self .assertIn ("=\\ '11\\ '" , playground_output )
169188
170189    def  do_concurrency_test (self ):
171-         contents  =  "error" 
172-         with  open ('Concurrency.swift' , 'r' ) as  contents_file :
173-             contents  =  contents_file .read ()
174-         res  =  self .frame ().EvaluateExpression (contents , self .options )
175-         ret  =  self .frame ().EvaluateExpression ("get_output()" )
176-         playground_output  =  ret .GetSummary ()
177-         self .assertTrue (playground_output  is  not None )
190+         playground_output  =  self .execute_code ('Concurrency.swift' )
178191        self .assertIn ("=\\ '23\\ '" , playground_output )
179192
180193    def  do_import_test (self ):
181194        # Test importing a library that adds new Clang options. 
182195        log  =  self .getBuildArtifact ('types.log' )
183196        self .expect ('log enable lldb types -f '  +  log )
184-         contents  =  "import Dylib\n f()\n " 
185-         res  =  self .frame ().EvaluateExpression (contents , self .options )
186-         ret  =  self .frame ().EvaluateExpression ("get_output()" )
187-         playground_output  =  ret .GetSummary ()
188-         self .assertTrue (playground_output  is  not None )
197+         playground_output  =  self .execute_code ('Import.swift' )
189198        self .assertIn ("Hello from the Dylib" , playground_output )
190199
191200        # Scan through the types log to make sure the SwiftASTContext was poisoned. 
0 commit comments