1111//===----------------------------------------------------------------------===//
1212
1313import Testing
14+ import Foundation
1415
1516import SWBCore
1617import SWBTestSupport
@@ -21,7 +22,7 @@ import SWBUtil
2122@Suite
2223fileprivate struct DebugInformationTests : CoreBasedTests {
2324 /// Test the different DWARF version formats we support.
24- @Test ( . requireSDKs( . macOS ) )
25+ @Test ( . requireSDKs( . host ) , . skipHostOS ( . windows ) )
2526 func debugInformationVersion( ) async throws {
2627 let testProject = try await TestProject (
2728 " aProject " ,
@@ -55,7 +56,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
5556 let tester = try await TaskConstructionTester ( getCore ( ) , testProject)
5657
5758 // Test the default version.
58- await tester. checkBuild ( BuildParameters ( configuration: " Config " ) , runDestination: . macOS ) { results in
59+ await tester. checkBuild ( BuildParameters ( configuration: " Config " ) , runDestination: . host ) { results in
5960 // Check clang.
6061 results. checkTask ( . matchRuleType( " CompileC " ) ) { task in
6162 task. checkCommandLineContains ( [ " -g " ] )
@@ -75,7 +76,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
7576 }
7677
7778 // Test explicitly setting to DWARF 4.
78- await tester. checkBuild ( BuildParameters ( configuration: " Config " , overrides: [ " DEBUG_INFORMATION_VERSION " : " dwarf4 " ] ) , runDestination: . macOS ) { results in
79+ await tester. checkBuild ( BuildParameters ( configuration: " Config " , overrides: [ " DEBUG_INFORMATION_VERSION " : " dwarf4 " ] ) , runDestination: . host ) { results in
7980 // Check clang.
8081 results. checkTask ( . matchRuleType( " CompileC " ) ) { task in
8182 task. checkCommandLineContains ( [ " -g " , " -gdwarf-4 " ] )
@@ -93,7 +94,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
9394 }
9495
9596 // Test explicitly setting to DWARF 5.
96- await tester. checkBuild ( BuildParameters ( configuration: " Config " , overrides: [ " DEBUG_INFORMATION_VERSION " : " dwarf5 " ] ) , runDestination: . macOS ) { results in
97+ await tester. checkBuild ( BuildParameters ( configuration: " Config " , overrides: [ " DEBUG_INFORMATION_VERSION " : " dwarf5 " ] ) , runDestination: . host ) { results in
9798 // Check clang.
9899 results. checkTask ( . matchRuleType( " CompileC " ) ) { task in
99100 task. checkCommandLineContains ( [ " -g " , " -gdwarf-5 " ] )
@@ -111,7 +112,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
111112 }
112113
113114 // Test disabling debug information.
114- await tester. checkBuild ( BuildParameters ( configuration: " Config " , overrides: [ " DEBUG_INFORMATION_FORMAT " : " " , " DEBUG_INFORMATION_VERSION " : " dwarf5 " ] ) , runDestination: . macOS ) { results in
115+ await tester. checkBuild ( BuildParameters ( configuration: " Config " , overrides: [ " DEBUG_INFORMATION_FORMAT " : " " , " DEBUG_INFORMATION_VERSION " : " dwarf5 " ] ) , runDestination: . host ) { results in
115116 // Check clang.
116117 results. checkTask ( . matchRuleType( " CompileC " ) ) { task in
117118 task. checkCommandLineDoesNotContain ( " -g " )
@@ -132,7 +133,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
132133 }
133134
134135 /// Check that we only generate dSYMs when appropriate.
135- @Test ( . requireSDKs( . macOS ) )
136+ @Test ( . requireSDKs( . host ) , . skipHostOS ( . windows ) )
136137 func dSYMGeneration( ) async throws {
137138 let testProject = TestProject (
138139 " aProject " ,
@@ -158,7 +159,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
158159 let tester = try await TaskConstructionTester ( getCore ( ) , testProject)
159160
160161 // Check behavior with dSYMs disabled.
161- await tester. checkBuild ( BuildParameters ( configuration: " Debug " , overrides: [ " DEBUG_INFORMATION_FORMAT " : " dwarf " ] ) , runDestination: . macOS ) { results in
162+ await tester. checkBuild ( BuildParameters ( configuration: " Debug " , overrides: [ " DEBUG_INFORMATION_FORMAT " : " dwarf " ] ) , runDestination: . host ) { results in
162163 // There shouldn't be a dSYM task.
163164 results. checkNoTask ( . matchRuleType( " GenerateDSYMFile " ) )
164165
@@ -167,10 +168,14 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
167168 }
168169
169170 // Check behavior with dSYMs enabled.
170- await tester. checkBuild ( BuildParameters ( configuration: " Debug " , overrides: [ " DEBUG_INFORMATION_FORMAT " : " dwarf-with-dsym " ] ) , runDestination: . macOS ) { results in
171+ try await tester. checkBuild ( BuildParameters ( configuration: " Debug " , overrides: [ " DEBUG_INFORMATION_FORMAT " : " dwarf-with-dsym " ] ) , runDestination: . host ) { results in
171172 // Check the expected dSYM task.
172- results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) ) { task in
173- task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework/Versions/A/CoreFoo " ] )
173+ if try ProcessInfo . processInfo. hostOperatingSystem ( ) == . macOS {
174+ results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) ) { task in
175+ task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework/Versions/A/CoreFoo " ] )
176+ }
177+ } else {
178+ results. checkNoTask ( . matchRuleType( " GenerateDSYMFile " ) )
174179 }
175180
176181 // Check there are no diagnostics.
@@ -179,26 +184,30 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
179184
180185 // Check install behavior with dSYMs enabled.
181186 let buildVariants = [ " debug " , " normal " ]
182- await tester. checkBuild ( BuildParameters ( action: . install, configuration: " Debug " , overrides: [
187+ try await tester. checkBuild ( BuildParameters ( action: . install, configuration: " Debug " , overrides: [
183188 " DEBUG_INFORMATION_FORMAT " : " dwarf-with-dsym " ,
184189 " BUILD_VARIANTS " : buildVariants. joined ( separator: " " ) ,
185- ] ) , runDestination: . macOS ) { results in
190+ ] ) , runDestination: . host ) { results in
186191 // Check tasks for each build variant.
187192 for buildVariant in buildVariants {
188- let binaryName = " CoreFoo " + ( buildVariant == " normal " ? " " : " _ \( buildVariant) " )
189-
190- // Check the dsymutil task for the build variant.
191- var dsymutilTask : ( any PlannedTask ) ? = nil
192- results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) , . matchRuleItemBasename( binaryName) ) { task in
193- task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/aProject.dst/Library/Frameworks/CoreFoo.framework/Versions/A/ \( binaryName) " ] )
194- dsymutilTask = task
195- }
193+ if try ProcessInfo . processInfo. hostOperatingSystem ( ) == . macOS {
194+ let binaryName = " CoreFoo " + ( buildVariant == " normal " ? " " : " _ \( buildVariant) " )
195+
196+ // Check the dsymutil task for the build variant.
197+ var dsymutilTask : ( any PlannedTask ) ? = nil
198+ results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) , . matchRuleItemBasename( binaryName) ) { task in
199+ task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/aProject.dst/Library/Frameworks/CoreFoo.framework/Versions/A/ \( binaryName) " ] )
200+ dsymutilTask = task
201+ }
196202
197- // Make sure the strip task for this build variant is ordered after the dsymutil task.
198- results. checkTask ( . matchRuleType( " Strip " ) , . matchRuleItemBasename( binaryName) ) { task in
199- if let dsymutilTask {
200- results. checkTaskFollows ( task, antecedent: dsymutilTask)
203+ // Make sure the strip task for this build variant is ordered after the dsymutil task.
204+ results. checkTask ( . matchRuleType( " Strip " ) , . matchRuleItemBasename( binaryName) ) { task in
205+ if let dsymutilTask {
206+ results. checkTaskFollows ( task, antecedent: dsymutilTask)
207+ }
201208 }
209+ } else {
210+ results. checkNoTask ( . matchRuleType( " GenerateDSYMFile " ) )
202211 }
203212 }
204213
@@ -207,50 +216,58 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
207216 }
208217
209218 // Check install behavior with `DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT` enabled.
210- await tester. checkBuild ( BuildParameters ( action: . install, configuration: " Debug " , overrides: [
219+ try await tester. checkBuild ( BuildParameters ( action: . install, configuration: " Debug " , overrides: [
211220 " DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT " : " YES " ,
212221 " DEBUG_INFORMATION_FORMAT " : " dwarf-with-dsym " ,
213222 " BUILD_VARIANTS " : buildVariants. joined ( separator: " " ) ,
214- ] ) , runDestination: . macOS) { results in
215- var dsymutilTasks = [ any PlannedTask ] ( )
216- results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) , . matchRuleItemBasename( " CoreFoo " ) ) { task in
217- task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/aProject.dst/Library/Frameworks/CoreFoo.framework/Versions/A/CoreFoo " ] )
218- dsymutilTasks. append ( task)
219- }
223+ ] ) , runDestination: . host) { results in
224+ if try ProcessInfo . processInfo. hostOperatingSystem ( ) == . macOS {
225+ var dsymutilTasks = [ any PlannedTask ] ( )
226+ results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) , . matchRuleItemBasename( " CoreFoo " ) ) { task in
227+ task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/aProject.dst/Library/Frameworks/CoreFoo.framework/Versions/A/CoreFoo " ] )
228+ dsymutilTasks. append ( task)
229+ }
220230
221- results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) , . matchRuleItemBasename( " CoreFoo_debug " ) ) { task in
222- task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/aProject.dst/Library/Frameworks/CoreFoo.framework/Versions/A/CoreFoo_debug " ] )
223- dsymutilTasks. append ( task)
224- }
231+ results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) , . matchRuleItemBasename( " CoreFoo_debug " ) ) { task in
232+ task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/aProject.dst/Library/Frameworks/CoreFoo.framework/Versions/A/CoreFoo_debug " ] )
233+ dsymutilTasks. append ( task)
234+ }
225235
226- results. checkTask ( . matchRuleType( " Copy " ) , . matchRuleItemBasename( " CoreFoo.framework.dSYM " ) ) { task in
227- task. checkCommandLine ( [ " builtin-copy " , " -exclude " , " .DS_Store " , " -exclude " , " CVS " , " -exclude " , " .svn " , " -exclude " , " .git " , " -exclude " , " .hg " , " -resolve-src-symlinks " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/aProject.dst/Library/Frameworks " ] )
236+ results. checkTask ( . matchRuleType( " Copy " ) , . matchRuleItemBasename( " CoreFoo.framework.dSYM " ) ) { task in
237+ task. checkCommandLine ( [ " builtin-copy " , " -exclude " , " .DS_Store " , " -exclude " , " CVS " , " -exclude " , " .svn " , " -exclude " , " .git " , " -exclude " , " .hg " , " -resolve-src-symlinks " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/aProject.dst/Library/Frameworks " ] )
228238
229- // Make sure this task follows the dSYM producer tasks.
230- for dsymutilTask in dsymutilTasks {
231- results. checkTaskDependsOn ( task, antecedent: dsymutilTask)
239+ // Make sure this task follows the dSYM producer tasks.
240+ for dsymutilTask in dsymutilTasks {
241+ results. checkTaskDependsOn ( task, antecedent: dsymutilTask)
242+ }
232243 }
244+ } else {
245+ results. checkNoTask ( . matchRuleType( " GenerateDSYMFile " ) )
233246 }
234247
235248 // Check there are no diagnostics.
236249 results. checkNoDiagnostics ( )
237250 }
238251
239252 // Check build behavior with `DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT` enabled.
240- await tester. checkBuild ( BuildParameters ( action: . build, configuration: " Debug " , overrides: [
253+ try await tester. checkBuild ( BuildParameters ( action: . build, configuration: " Debug " , overrides: [
241254 " DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT " : " YES " ,
242255 " DEBUG_INFORMATION_FORMAT " : " dwarf-with-dsym " ,
243256 " BUILD_VARIANTS " : buildVariants. joined ( separator: " " ) ,
244- ] ) , runDestination: . macOS) { results in
245- results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) , . matchRuleItemBasename( " CoreFoo " ) ) { task in
246- task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework/Versions/A/CoreFoo " ] )
247- }
257+ ] ) , runDestination: . host) { results in
258+ if try ProcessInfo . processInfo. hostOperatingSystem ( ) == . macOS {
259+ results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) , . matchRuleItemBasename( " CoreFoo " ) ) { task in
260+ task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework/Versions/A/CoreFoo " ] )
261+ }
248262
249- results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) , . matchRuleItemBasename( " CoreFoo_debug " ) ) { task in
250- task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework/Versions/A/CoreFoo_debug " ] )
251- }
263+ results. checkTask ( . matchRuleType( " GenerateDSYMFile " ) , . matchRuleItemBasename( " CoreFoo_debug " ) ) { task in
264+ task. checkRuleInfo ( [ " GenerateDSYMFile " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework.dSYM " , " /tmp/Test/aProject/build/Debug/CoreFoo.framework/Versions/A/CoreFoo_debug " ] )
265+ }
252266
253- results. checkNoTask ( . matchRuleType( " Copy " ) , . matchRuleItemBasename( " CoreFoo.framework.dSYM " ) )
267+ results. checkNoTask ( . matchRuleType( " Copy " ) , . matchRuleItemBasename( " CoreFoo.framework.dSYM " ) )
268+ } else {
269+ results. checkNoTask ( . matchRuleType( " GenerateDSYMFile " ) )
270+ }
254271
255272 // Check there are no diagnostics.
256273 results. checkNoDiagnostics ( )
0 commit comments