@@ -30,19 +30,34 @@ fileprivate struct ClangStaticAnalyzerTests: CoreBasedTests {
3030 TestFile ( " foo.c " ) ,
3131 TestFile ( " bar.s " ) ,
3232 ] ) ,
33- targets: [ TestStandardTarget ( " Lib " , type: . dynamicLibrary,
34- buildPhases: [
35- TestSourcesBuildPhase ( [
36- " foo.c " ,
37- " bar.s " , // should not get analyzed
38- ] ) ] ) ] )
33+ buildConfigurations: [
34+ TestBuildConfiguration ( " Debug " , buildSettings: [
35+ " PRODUCT_NAME " : " $(TARGET_NAME) " ,
36+ // Workaround for CI which have Intel hosts.
37+ " MACOSX_DEPLOYMENT_TARGET " : " 26.0 " ,
38+ ] )
39+ ] ,
40+ targets: [
41+ TestStandardTarget (
42+ " Lib " ,
43+ type: . dynamicLibrary,
44+ buildPhases: [
45+ TestSourcesBuildPhase ( [
46+ " foo.c " ,
47+ " bar.s " , // should not get analyzed
48+ ] )
49+ ]
50+ )
51+ ]
52+ )
3953 let testWorkspace = TestWorkspace ( " aWorkspace " , projects: [ testProject] )
4054 let tester = try await TaskConstructionTester ( getCore ( ) , testWorkspace)
4155 let SRCROOT = tester. workspace. projects [ 0 ] . sourceRoot. str
56+ let runDestination : RunDestinationInfo = . host
4257
4358 // Test basics.
4459 // CLANG_STATIC_ANALYZER_MODE defaults to "shallow".
45- await tester. checkBuild ( BuildParameters ( configuration: " Debug " , overrides: [ " RUN_CLANG_STATIC_ANALYZER " : " YES " , " CLANG_USE_RESPONSE_FILE " : " NO " ] ) , runDestination: . host ) { results in
60+ await tester. checkBuild ( BuildParameters ( configuration: " Debug " , overrides: [ " RUN_CLANG_STATIC_ANALYZER " : " YES " , " CLANG_USE_RESPONSE_FILE " : " NO " ] ) , runDestination: runDestination ) { results in
4661 results. checkTarget ( " Lib " ) { target in
4762 let effectivePlatformName = results. builtProductsDirSuffix ( target)
4863 let arch = results. runDestinationTargetArchitecture
@@ -62,7 +77,7 @@ fileprivate struct ClangStaticAnalyzerTests: CoreBasedTests {
6277 }
6378 // CLANG_STATIC_ANALYZER_MODE = "deep" and "" are synonymous.
6479 for mode in [ " deep " , " " ] {
65- await tester. checkBuild ( BuildParameters ( configuration: " Debug " , overrides: [ " RUN_CLANG_STATIC_ANALYZER " : " YES " , " CLANG_STATIC_ANALYZER_MODE " : mode] ) , runDestination: . host ) { results in
80+ await tester. checkBuild ( BuildParameters ( configuration: " Debug " , overrides: [ " RUN_CLANG_STATIC_ANALYZER " : " YES " , " CLANG_STATIC_ANALYZER_MODE " : mode] ) , runDestination: runDestination ) { results in
6681 results. checkTarget ( " Lib " ) { target in
6782 let effectivePlatformName = results. builtProductsDirSuffix ( target)
6883 let arch = results. runDestinationTargetArchitecture
@@ -81,7 +96,6 @@ fileprivate struct ClangStaticAnalyzerTests: CoreBasedTests {
8196 results. checkNoDiagnostics ( )
8297 }
8398 }
84- let runDestination : RunDestinationInfo = . host
8599 let architectures : [ String ] = switch runDestination {
86100 case . macOS:
87101 [ " armv7 " , " x86_64 " ]
@@ -101,7 +115,7 @@ fileprivate struct ClangStaticAnalyzerTests: CoreBasedTests {
101115 " VALID_ARCHS " : architectures. joined ( separator: " " ) ,
102116 " MACOSX_DEPLOYMENT_TARGET " : " 26.0 " ,
103117 ]
104- await tester. checkBuild ( BuildParameters ( configuration: " Debug " , overrides: overrides) , runDestination: . host ) { results in
118+ await tester. checkBuild ( BuildParameters ( configuration: " Debug " , overrides: overrides) , runDestination: runDestination ) { results in
105119 results. checkTarget ( " Lib " ) { target in
106120 results. checkNoTask ( . matchTarget( target) , . matchRule( [ " Analyze " , Path ( SRCROOT) . join ( " bar.s " ) . str] ) )
107121
@@ -112,11 +126,9 @@ fileprivate struct ClangStaticAnalyzerTests: CoreBasedTests {
112126 }
113127
114128 // For each file, we should have two compile tasks, one for each arch.
115- results. checkTasks ( . matchTarget( target) , . matchRuleType( " CompileC " ) , . matchRuleItem( Path ( SRCROOT) . join ( " foo.c " ) . str) ) { tasks in
116- #expect( tasks. count == 2 )
117- }
118- results. checkTasks ( . matchTarget( target) , . matchRuleType( " CompileC " ) , . matchRuleItem( Path ( SRCROOT) . join ( " bar.s " ) . str) ) { tasks in
119- #expect( tasks. count == 2 )
129+ for arch in architectures {
130+ results. checkTask ( . matchTarget( target) , . matchRuleType( " CompileC " ) , . matchRuleItem( Path ( SRCROOT) . join ( " foo.c " ) . str) , . matchRuleItem( arch) ) { _ in }
131+ results. checkTask ( . matchTarget( target) , . matchRuleType( " CompileC " ) , . matchRuleItem( Path ( SRCROOT) . join ( " bar.s " ) . str) , . matchRuleItem( arch) ) { _ in }
120132 }
121133 }
122134 results. checkNoDiagnostics ( )
0 commit comments