@@ -345,8 +345,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
345345 }
346346 }
347347
348- @Test ( . requireSDKs( . host) , . skipHostOS( . windows, " toolchain too old " ) , . skipHostOS( . linux, " toolchain too old " ) )
349- func validateModuleDependenciesSwift( ) async throws {
348+ func validateModuleDependenciesSwift( explicitModules: Bool ) async throws {
350349 try await withTemporaryDirectory { tmpDir in
351350 let testWorkspace = try await TestWorkspace (
352351 " Test " ,
@@ -366,8 +365,8 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
366365 buildSettings: [
367366 " PRODUCT_NAME " : " $(TARGET_NAME) " ,
368367 " CLANG_ENABLE_MODULES " : " YES " ,
369- " CLANG_ENABLE_EXPLICIT_MODULES " : " YES " ,
370- " SWIFT_ENABLE_EXPLICIT_MODULES " : " YES " ,
368+ " CLANG_ENABLE_EXPLICIT_MODULES " : explicitModules ? " YES " : " NO " ,
369+ " SWIFT_ENABLE_EXPLICIT_MODULES " : explicitModules ? " YES " : " NO " ,
371370 " SWIFT_UPCOMING_FEATURE_INTERNAL_IMPORTS_BY_DEFAULT " : " YES " ,
372371 " SWIFT_VERSION " : swiftVersion,
373372 " DEFINES_MODULE " : " YES " ,
@@ -418,50 +417,58 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
418417 let projectXCConfigFinalLineNumber = projectXCConfigLines. count
419418 let projectXCConfigFinalColumnNumber = ( projectXCConfigLines. last? . count ?? 0 ) + 1
420419
421- let expectedDiagsByTarget : [ String : [ Diagnostic ] ] = [
422- " TargetA " : [
423- Diagnostic (
424- behavior: . error,
425- location: Diagnostic . Location. path ( projectXCConfigPath, line: 1 , column: 47 ) ,
426- data: DiagnosticData ( " Missing entries in MODULE_DEPENDENCIES: Foundation " ) ,
427- fixIts: [
428- Diagnostic . FixIt (
429- sourceRange: Diagnostic . SourceRange ( path: projectXCConfigPath, startLine: 1 , startColumn: 47 , endLine: 1 , endColumn: 47 ) ,
430- newText: " \\ \n Foundation " ) ,
431- ] ,
432- childDiagnostics: [
433- Diagnostic (
434- behavior: . error,
435- location: Diagnostic . Location. path ( swiftSourcePath, line: 1 , column: 8 ) ,
436- data: DiagnosticData ( " Missing entry in MODULE_DEPENDENCIES: Foundation " ) ,
437- fixIts: [ Diagnostic . FixIt (
420+ let expectedDiagsByTarget : [ String : [ Diagnostic ] ]
421+ if explicitModules {
422+ expectedDiagsByTarget = [
423+ " TargetA " : [
424+ Diagnostic (
425+ behavior: . error,
426+ location: Diagnostic . Location. path ( projectXCConfigPath, line: 1 , column: 47 ) ,
427+ data: DiagnosticData ( " Missing entries in MODULE_DEPENDENCIES: Foundation " ) ,
428+ fixIts: [
429+ Diagnostic . FixIt (
438430 sourceRange: Diagnostic . SourceRange ( path: projectXCConfigPath, startLine: 1 , startColumn: 47 , endLine: 1 , endColumn: 47 ) ,
439- newText: " \\ \n Foundation " ) ] ,
440- ) ,
441- ] ) ,
442- ] ,
443- " TargetB " : [
444- Diagnostic (
445- behavior : . error ,
446- location : Diagnostic . Location . path ( projectXCConfigPath , line : projectXCConfigFinalLineNumber , column : projectXCConfigFinalColumnNumber ) ,
447- data : DiagnosticData ( " Missing entries in MODULE_DEPENDENCIES: Foundation " ) ,
448- fixIts : [
449- Diagnostic . FixIt (
450- sourceRange : Diagnostic . SourceRange ( path : projectXCConfigPath , startLine : projectXCConfigFinalLineNumber , startColumn : projectXCConfigFinalColumnNumber , endLine : projectXCConfigFinalLineNumber , endColumn : projectXCConfigFinalColumnNumber ) ,
451- newText : " \n MODULE_DEPENDENCIES[target=TargetB] = $(inherited) \\ \n Foundation \n " ) ,
452- ] ,
453- childDiagnostics : [
454- Diagnostic (
455- behavior : . error ,
456- location : Diagnostic . Location . path ( swiftSourcePath , line : 1 , column : 8 ) ,
457- data : DiagnosticData ( " Missing entry in MODULE_DEPENDENCIES: Foundation " ) ,
458- fixIts : [ Diagnostic . FixIt (
431+ newText: " \\ \n Foundation " ) ,
432+ ] ,
433+ childDiagnostics : [
434+ Diagnostic (
435+ behavior : . error ,
436+ location : Diagnostic . Location . path ( swiftSourcePath , line : 1 , column : 8 ) ,
437+ data : DiagnosticData ( " Missing entry in MODULE_DEPENDENCIES: Foundation " ) ,
438+ fixIts : [ Diagnostic . FixIt (
439+ sourceRange : Diagnostic . SourceRange ( path : projectXCConfigPath , startLine : 1 , startColumn : 47 , endLine : 1 , endColumn : 47 ) ,
440+ newText : " \\ \n Foundation " ) ] ,
441+ ) ,
442+ ] ) ,
443+ ] ,
444+ " TargetB " : [
445+ Diagnostic (
446+ behavior : . error ,
447+ location : Diagnostic . Location . path ( projectXCConfigPath , line : projectXCConfigFinalLineNumber , column : projectXCConfigFinalColumnNumber ) ,
448+ data : DiagnosticData ( " Missing entries in MODULE_DEPENDENCIES: Foundation " ) ,
449+ fixIts : [
450+ Diagnostic . FixIt (
459451 sourceRange: Diagnostic . SourceRange ( path: projectXCConfigPath, startLine: projectXCConfigFinalLineNumber, startColumn: projectXCConfigFinalColumnNumber, endLine: projectXCConfigFinalLineNumber, endColumn: projectXCConfigFinalColumnNumber) ,
460- newText: " \n MODULE_DEPENDENCIES[target=TargetB] = $(inherited) \\ \n Foundation \n " ) ] ,
461- ) ,
462- ] ) ,
463- ] ,
464- ]
452+ newText: " \n MODULE_DEPENDENCIES[target=TargetB] = $(inherited) \\ \n Foundation \n " ) ,
453+ ] ,
454+ childDiagnostics: [
455+ Diagnostic (
456+ behavior: . error,
457+ location: Diagnostic . Location. path ( swiftSourcePath, line: 1 , column: 8 ) ,
458+ data: DiagnosticData ( " Missing entry in MODULE_DEPENDENCIES: Foundation " ) ,
459+ fixIts: [ Diagnostic . FixIt (
460+ sourceRange: Diagnostic . SourceRange ( path: projectXCConfigPath, startLine: projectXCConfigFinalLineNumber, startColumn: projectXCConfigFinalColumnNumber, endLine: projectXCConfigFinalLineNumber, endColumn: projectXCConfigFinalColumnNumber) ,
461+ newText: " \n MODULE_DEPENDENCIES[target=TargetB] = $(inherited) \\ \n Foundation \n " ) ] ,
462+ ) ,
463+ ] ) ,
464+ ] ,
465+ ]
466+ } else {
467+ expectedDiagsByTarget = [
468+ " TargetA " : [ ] ,
469+ " TargetB " : [ ] ,
470+ ]
471+ }
465472
466473 for (targetName, expectedDiags) in expectedDiagsByTarget {
467474 let target = try #require( tester. workspace. projects. only? . targets. first { $0. name == targetName } )
@@ -482,6 +489,16 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
482489 }
483490 }
484491
492+ @Test ( . requireSDKs( . host) , . skipHostOS( . windows, " toolchain too old " ) , . skipHostOS( . linux, " toolchain too old " ) )
493+ func validateModuleDependenciesSwift( ) async throws {
494+ try await validateModuleDependenciesSwift ( explicitModules: true )
495+ }
496+
497+ @Test ( . requireSDKs( . host) , . skipHostOS( . windows, " toolchain too old " ) , . skipHostOS( . linux, " toolchain too old " ) )
498+ func validateModuleDependenciesSwiftExplicitModulesOff( ) async throws {
499+ try await validateModuleDependenciesSwift ( explicitModules: false )
500+ }
501+
485502 @Test ( . requireSDKs( . host) , . requireClangFeatures( . printHeadersDirectPerFile) )
486503 func validateModuleDependenciesClang( ) async throws {
487504 try await withTemporaryDirectory { tmpDir async throws -> Void in
0 commit comments