@@ -120,11 +120,14 @@ if lit_config.params.get("have-network"):
120120
121121# Get the package path.
122122package_path = lit_config .params .get ("package-path" )
123+ if package_path is None :
124+ # If a package wasn't provided, use the current selected toolchain on Darwin.
125+ if platform .system () == "Darwin" :
126+ package_path = os .path .abspath (
127+ os .path .join (subprocess .check_output (["xcrun" , "--find" , "swift" ]).strip (), "../../../" ))
123128if package_path is None :
124129 lit_config .fatal ("'--param package-path=PATH' is required" )
125130package_path = os .path .abspath (package_path )
126- # if platform.system() == "Darwin":
127- # package_path = os.path.join(package_path, "Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain")
128131lit_config .note ("testing package: %r" % (package_path ,))
129132
130133# Find the path to FileCheck. We just pick any one out of the build directory.
@@ -177,7 +180,10 @@ if not os.path.exists(swiftc_path):
177180if not os .path .exists (filecheck_path ):
178181 lit_config .fatal ("filecheck does not exist!" )
179182if not os .path .exists (lldb_path ):
180- lit_config .fatal ("lldb does not exist!" )
183+ if platform .system () == "Darwin" :
184+ lldb_path = subprocess .check_output (["xcrun" , "--find" , "lldb" ]).strip ()
185+ else :
186+ lit_config .fatal ("lldb does not exist!" )
181187
182188# Define our supported substitutions.
183189config .substitutions .append ( ('%{not}' , os .path .join (srcroot , "not" )) )
@@ -186,13 +192,17 @@ config.substitutions.append( ('%{swift}', swift_path) )
186192config .substitutions .append ( ('%{swiftc}' , swiftc_path ) )
187193config .substitutions .append ( ('%{FileCheck}' , filecheck_path ) )
188194
189- # Add a substitution for swiftpm build directory. This is useful for
190- # running the integration tests locally, for e.g. by changing:
191- # %{swift} build -> %{swiftpm_build}/swift-build
195+ # Add substitutions for swiftpm executables.
192196swiftpm_build = lit_config .params .get ("swiftpm-build" )
193197if swiftpm_build is not None :
194- config .substitutions .append ( ('%{swiftpm_build}' , swiftpm_build ) )
195198 lit_config .note ("testing using swiftpm build directory: {}" .format (swiftpm_build ))
199+ config .substitutions .append ( ('%{swift-build}' , os .path .join (swiftpm_build , "swift-build" )) )
200+ config .substitutions .append ( ('%{swift-test}' , os .path .join (swiftpm_build , "swift-test" )) )
201+ config .substitutions .append ( ('%{swift-run}' , os .path .join (swiftpm_build , "swift-run" )) )
202+ else :
203+ config .substitutions .append ( ('%{swift-build}' , swift_path + ' build' ) )
204+ config .substitutions .append ( ('%{swift-test}' , swift_path + ' test' ) )
205+ config .substitutions .append ( ('%{swift-run}' , swift_path + ' run' ) )
196206
197207###
198208
0 commit comments