@@ -4518,7 +4518,7 @@ fileprivate struct SwiftDriverTests: CoreBasedTests {
4518
4518
}
4519
4519
}
4520
4520
4521
- @Test ( . requireSDKs( . macOS) , . disabled ( if : getEnvironmentVariable ( " CI " ) ? . isEmpty == false , " Test relies on timing which would require costly delays in CI " ) )
4521
+ @Test ( . requireSDKs( . macOS) )
4522
4522
func diagnosingMissingTargetDependencies( ) async throws {
4523
4523
try await withTemporaryDirectory { tmpDir in
4524
4524
let testWorkspace = try await TestWorkspace (
@@ -4565,8 +4565,6 @@ fileprivate struct SwiftDriverTests: CoreBasedTests {
4565
4565
" Framework3 " ,
4566
4566
type: . framework,
4567
4567
buildPhases: [
4568
- // Ensure that we always happen to build the targets in the right order, even though the dependency is missing.
4569
- TestShellScriptBuildPhase ( name: " Sleep " , originalObjectID: " A " , contents: " sleep 10 " , alwaysOutOfDate: true ) ,
4570
4568
TestSourcesBuildPhase ( [ " file_3.swift " ] ) ,
4571
4569
] ) ,
4572
4570
] ) ] )
@@ -4610,7 +4608,7 @@ fileprivate struct SwiftDriverTests: CoreBasedTests {
4610
4608
4611
4609
for warningLevel in [ BooleanWarningLevel . yes, . yesError] {
4612
4610
let parameters = BuildParameters ( configuration: " Debug " , overrides: [ " DIAGNOSE_MISSING_TARGET_DEPENDENCIES " : warningLevel. rawValue] )
4613
- let buildRequest = BuildRequest ( parameters: parameters, buildTargets: tester. workspace. projects [ 0 ] . targets. map ( { BuildRequest . BuildTargetInfo ( parameters: parameters, target: $0) } ) , continueBuildingAfterErrors: false , useParallelTargets: true , useImplicitDependencies: false , useDryRun: false )
4611
+ let buildRequest = BuildRequest ( parameters: parameters, buildTargets: tester. workspace. projects [ 0 ] . targets. map ( { BuildRequest . BuildTargetInfo ( parameters: parameters, target: $0) } ) , continueBuildingAfterErrors: false , useParallelTargets: false , useImplicitDependencies: false , useDryRun: false )
4614
4612
4615
4613
try await tester. checkBuild ( runDestination: . macOS, buildRequest: buildRequest, persistent: true ) { results in
4616
4614
switch warningLevel {
@@ -4631,6 +4629,99 @@ fileprivate struct SwiftDriverTests: CoreBasedTests {
4631
4629
}
4632
4630
}
4633
4631
4632
+ @Test ( . requireSDKs( . macOS) )
4633
+ func diagnosingMissingTargetDependenciesWithDependencyDomains( ) async throws {
4634
+ try await withTemporaryDirectory { tmpDir in
4635
+ let testWorkspace = try await TestWorkspace (
4636
+ " Test " ,
4637
+ sourceRoot: tmpDir. join ( " Test " ) ,
4638
+ projects: [
4639
+ TestProject (
4640
+ " aProject " ,
4641
+ groupTree: TestGroup (
4642
+ " Sources " ,
4643
+ children: [
4644
+ TestFile ( " Framework1.h " ) ,
4645
+ TestFile ( " file_1.c " ) ,
4646
+ TestFile ( " file_2.swift " ) ,
4647
+ ] ) ,
4648
+ buildConfigurations: [ TestBuildConfiguration (
4649
+ " Debug " ,
4650
+ buildSettings: [
4651
+ " PRODUCT_NAME " : " $(TARGET_NAME) " ,
4652
+ " CLANG_ENABLE_MODULES " : " YES " ,
4653
+ " _EXPERIMENTAL_CLANG_EXPLICIT_MODULES " : " YES " ,
4654
+ " SWIFT_ENABLE_EXPLICIT_MODULES " : " YES " ,
4655
+ " SWIFT_VERSION " : swiftVersion,
4656
+ " DEFINES_MODULE " : " YES " ,
4657
+ " VALID_ARCHS " : " arm64 " ,
4658
+ " DSTROOT " : tmpDir. join ( " dstroot " ) . str,
4659
+ " DIAGNOSE_MISSING_TARGET_DEPENDENCIES " : " YES " ,
4660
+ ] ) ] ,
4661
+ targets: [
4662
+ TestStandardTarget (
4663
+ " Framework1 " ,
4664
+ type: . framework,
4665
+ buildConfigurations: [ TestBuildConfiguration (
4666
+ " Debug " ,
4667
+ buildSettings: [
4668
+ " IMPLICIT_DEPENDENCY_DOMAIN " : " One "
4669
+ ] ) ] ,
4670
+ buildPhases: [
4671
+ TestHeadersBuildPhase ( [ TestBuildFile ( " Framework1.h " , headerVisibility: . public) ] ) ,
4672
+ TestSourcesBuildPhase ( [ " file_1.c " ] ) ,
4673
+ ] ) ,
4674
+ TestStandardTarget (
4675
+ " Framework2 " ,
4676
+ type: . framework,
4677
+ buildConfigurations: [ TestBuildConfiguration (
4678
+ " Debug " ,
4679
+ buildSettings: [
4680
+ " IMPLICIT_DEPENDENCY_DOMAIN " : " Two "
4681
+ ] ) ] ,
4682
+ buildPhases: [
4683
+ TestSourcesBuildPhase ( [ " file_2.swift " ] ) ,
4684
+ ] ) ,
4685
+ ] ) ] )
4686
+
4687
+ let tester = try await BuildOperationTester ( getCore ( ) , testWorkspace, simulated: false )
4688
+
4689
+ try await tester. fs. writeFileContents ( testWorkspace. sourceRoot. join ( " aProject/Framework1.h " ) ) { stream in
4690
+ stream <<<
4691
+ """
4692
+ void foo(void);
4693
+ """
4694
+ }
4695
+
4696
+ try await tester. fs. writeFileContents ( testWorkspace. sourceRoot. join ( " aProject/file_1.c " ) ) { stream in
4697
+ stream <<<
4698
+ """
4699
+ #include <Framework1/Framework1.h>
4700
+ void foo(void) {}
4701
+ """
4702
+ }
4703
+
4704
+ try await tester. fs. writeFileContents ( testWorkspace. sourceRoot. join ( " aProject/file_2.swift " ) ) { stream in
4705
+ stream <<<
4706
+ """
4707
+ import Framework1
4708
+ public func baz() {
4709
+ foo()
4710
+ }
4711
+ """
4712
+ }
4713
+
4714
+ let parameters = BuildParameters ( configuration: " Debug " )
4715
+ let buildRequest = BuildRequest ( parameters: parameters, buildTargets: tester. workspace. projects [ 0 ] . targets. map ( { BuildRequest . BuildTargetInfo ( parameters: parameters, target: $0) } ) , continueBuildingAfterErrors: false , useParallelTargets: false , useImplicitDependencies: false , useDryRun: false )
4716
+
4717
+ try await tester. checkBuild ( runDestination: . macOS, buildRequest: buildRequest, persistent: true ) { results in
4718
+ // Normally, we would report "'Framework2' is missing a dependency on 'Framework1' because dependency scan of Swift module 'Framework2' discovered a dependency on 'Framework1'"
4719
+ // However, because the targets are in different domains, we shouldn't report any diagnostics.
4720
+ results. checkNoDiagnostics ( )
4721
+ }
4722
+ }
4723
+ }
4724
+
4634
4725
@Test ( . requireSDKs( . macOS) )
4635
4726
func explicitPCMDeduplicationWithBuildVariant( ) async throws {
4636
4727
try await withTemporaryDirectory { tmpDirPath async throws -> Void in
0 commit comments