@@ -382,6 +382,124 @@ fileprivate struct BuildOperationTests: CoreBasedTests {
382
382
}
383
383
}
384
384
385
+ @Test ( . requireSDKs( . host) )
386
+ func commandLineTool_whitespaceEscaping( ) async throws {
387
+ try await withTemporaryDirectory { ( tmpDir: Path ) in
388
+ let tmpDir = tmpDir. join ( " has whitespace " )
389
+ let testProject = try await TestProject (
390
+ " TestProject " ,
391
+ sourceRoot: tmpDir,
392
+ groupTree: TestGroup (
393
+ " SomeFiles " ,
394
+ children: [
395
+ TestFile ( " main.swift " ) ,
396
+ TestFile ( " dynamic.swift " ) ,
397
+ TestFile ( " static.swift " ) ,
398
+ ] ) ,
399
+ buildConfigurations: [
400
+ TestBuildConfiguration ( " Debug " , buildSettings: [
401
+ " ARCHS " : " $(ARCHS_STANDARD) " ,
402
+ " CODE_SIGNING_ALLOWED " : ProcessInfo . processInfo. hostOperatingSystem ( ) == . macOS ? " YES " : " NO " ,
403
+ " CODE_SIGN_IDENTITY " : " - " ,
404
+ " CODE_SIGN_ENTITLEMENTS " : " Entitlements.plist " ,
405
+ " DEFINES_MODULE " : " YES " ,
406
+ " PRODUCT_NAME " : " $(TARGET_NAME) " ,
407
+ " SDKROOT " : " $(HOST_PLATFORM) " ,
408
+ " SUPPORTED_PLATFORMS " : " $(HOST_PLATFORM) " ,
409
+ " SWIFT_VERSION " : swiftVersion,
410
+ " GCC_GENERATE_DEBUGGING_SYMBOLS " : " YES " ,
411
+ ] )
412
+ ] ,
413
+ targets: [
414
+ TestStandardTarget (
415
+ " tool " ,
416
+ type: . commandLineTool,
417
+ buildConfigurations: [
418
+ TestBuildConfiguration ( " Debug " , buildSettings: [
419
+ " LD_RUNPATH_SEARCH_PATHS " : " @loader_path/ " ,
420
+ ] )
421
+ ] ,
422
+ buildPhases: [
423
+ TestSourcesBuildPhase ( [ " main.swift " ] ) ,
424
+ TestFrameworksBuildPhase ( [
425
+ TestBuildFile ( . target( " dynamiclib " ) ) ,
426
+ TestBuildFile ( . target( " staticlib " ) ) ,
427
+ ] )
428
+ ] ,
429
+ dependencies: [
430
+ " dynamiclib " ,
431
+ " staticlib " ,
432
+ ]
433
+ ) ,
434
+ TestStandardTarget (
435
+ " dynamiclib " ,
436
+ type: . dynamicLibrary,
437
+ buildConfigurations: [
438
+ TestBuildConfiguration ( " Debug " , buildSettings: [
439
+ " DYLIB_INSTALL_NAME_BASE " : " $ORIGIN " ,
440
+ " DYLIB_INSTALL_NAME_BASE[sdk=macosx*] " : " @rpath " ,
441
+
442
+ // FIXME: Find a way to make these default
443
+ " EXECUTABLE_PREFIX " : " lib " ,
444
+ " EXECUTABLE_PREFIX[sdk=windows*] " : " " ,
445
+ ] )
446
+ ] ,
447
+ buildPhases: [
448
+ TestSourcesBuildPhase ( [ " dynamic.swift " ] ) ,
449
+ ]
450
+ ) ,
451
+ TestStandardTarget (
452
+ " staticlib " ,
453
+ type: . staticLibrary,
454
+ buildConfigurations: [
455
+ TestBuildConfiguration ( " Debug " , buildSettings: [
456
+ // FIXME: Find a way to make these default
457
+ " EXECUTABLE_PREFIX " : " lib " ,
458
+ " EXECUTABLE_PREFIX[sdk=windows*] " : " " ,
459
+ ] )
460
+ ] ,
461
+ buildPhases: [
462
+ TestSourcesBuildPhase ( [ " static.swift " ] ) ,
463
+ ]
464
+ ) ,
465
+ ] )
466
+ let core = try await getCore ( )
467
+ let tester = try await BuildOperationTester ( core, testProject, simulated: false )
468
+
469
+ let projectDir = tester. workspace. projects [ 0 ] . sourceRoot
470
+
471
+ try await tester. fs. writeFileContents ( projectDir. join ( " main.swift " ) ) { stream in
472
+ stream <<< " import dynamiclib \n "
473
+ stream <<< " import staticlib \n "
474
+ stream <<< " dynamicLib() \n "
475
+ stream <<< " dynamicLib() \n "
476
+ stream <<< " staticLib() \n "
477
+ stream <<< " print( \" Hello world \" ) \n "
478
+ }
479
+
480
+ try await tester. fs. writeFileContents ( projectDir. join ( " dynamic.swift " ) ) { stream in
481
+ stream <<< " public func dynamicLib() { } "
482
+ }
483
+
484
+ try await tester. fs. writeFileContents ( projectDir. join ( " static.swift " ) ) { stream in
485
+ stream <<< " public func staticLib() { } "
486
+ }
487
+
488
+ try await tester. fs. writePlist ( projectDir. join ( " Entitlements.plist " ) , . plDict( [ : ] ) )
489
+
490
+ let provisioningInputs = [
491
+ " dynamiclib " : ProvisioningTaskInputs ( identityHash: " - " , signedEntitlements: . plDict( [ : ] ) , simulatedEntitlements: . plDict( [ : ] ) ) ,
492
+ " staticlib " : ProvisioningTaskInputs ( identityHash: " - " , signedEntitlements: . plDict( [ : ] ) , simulatedEntitlements: . plDict( [ : ] ) ) ,
493
+ " tool " : ProvisioningTaskInputs ( identityHash: " - " , signedEntitlements: . plDict( [ : ] ) , simulatedEntitlements: . plDict( [ : ] ) )
494
+ ]
495
+
496
+ let destination : RunDestinationInfo = . host
497
+ try await tester. checkBuild ( runDestination: destination, persistent: true , signableTargets: Set ( provisioningInputs. keys) , signableTargetInputs: provisioningInputs) { results in
498
+ results. checkNoErrors ( )
499
+ }
500
+ }
501
+ }
502
+
385
503
@Test ( . requireSDKs( . macOS) )
386
504
func unitTestWithGeneratedEntryPointViaMacOSOverride( ) async throws {
387
505
try await withTemporaryDirectory ( removeTreeOnDeinit: false ) { ( tmpDir: Path ) in
0 commit comments