11
11
//===----------------------------------------------------------------------===//
12
12
13
13
import Testing
14
+ import Foundation
14
15
15
16
import SWBCore
16
17
import SWBTestSupport
@@ -21,7 +22,7 @@ import SWBUtil
21
22
@Suite
22
23
fileprivate struct DebugInformationTests : CoreBasedTests {
23
24
/// Test the different DWARF version formats we support.
24
- @Test ( . requireSDKs( . macOS ) )
25
+ @Test ( . requireSDKs( . host ) , . skipHostOS ( . windows ) )
25
26
func debugInformationVersion( ) async throws {
26
27
let testProject = try await TestProject (
27
28
" aProject " ,
@@ -55,7 +56,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
55
56
let tester = try await TaskConstructionTester ( getCore ( ) , testProject)
56
57
57
58
// 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
59
60
// Check clang.
60
61
results. checkTask ( . matchRuleType( " CompileC " ) ) { task in
61
62
task. checkCommandLineContains ( [ " -g " ] )
@@ -75,7 +76,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
75
76
}
76
77
77
78
// 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
79
80
// Check clang.
80
81
results. checkTask ( . matchRuleType( " CompileC " ) ) { task in
81
82
task. checkCommandLineContains ( [ " -g " , " -gdwarf-4 " ] )
@@ -93,7 +94,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
93
94
}
94
95
95
96
// 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
97
98
// Check clang.
98
99
results. checkTask ( . matchRuleType( " CompileC " ) ) { task in
99
100
task. checkCommandLineContains ( [ " -g " , " -gdwarf-5 " ] )
@@ -111,7 +112,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
111
112
}
112
113
113
114
// 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
115
116
// Check clang.
116
117
results. checkTask ( . matchRuleType( " CompileC " ) ) { task in
117
118
task. checkCommandLineDoesNotContain ( " -g " )
@@ -132,7 +133,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
132
133
}
133
134
134
135
/// Check that we only generate dSYMs when appropriate.
135
- @Test ( . requireSDKs( . macOS ) )
136
+ @Test ( . requireSDKs( . host ) , . skipHostOS ( . windows ) )
136
137
func dSYMGeneration( ) async throws {
137
138
let testProject = TestProject (
138
139
" aProject " ,
@@ -158,7 +159,7 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
158
159
let tester = try await TaskConstructionTester ( getCore ( ) , testProject)
159
160
160
161
// 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
162
163
// There shouldn't be a dSYM task.
163
164
results. checkNoTask ( . matchRuleType( " GenerateDSYMFile " ) )
164
165
@@ -167,10 +168,14 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
167
168
}
168
169
169
170
// 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
171
172
// 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 " ) )
174
179
}
175
180
176
181
// Check there are no diagnostics.
@@ -179,26 +184,30 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
179
184
180
185
// Check install behavior with dSYMs enabled.
181
186
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: [
183
188
" DEBUG_INFORMATION_FORMAT " : " dwarf-with-dsym " ,
184
189
" BUILD_VARIANTS " : buildVariants. joined ( separator: " " ) ,
185
- ] ) , runDestination: . macOS ) { results in
190
+ ] ) , runDestination: . host ) { results in
186
191
// Check tasks for each build variant.
187
192
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
+ }
196
202
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
+ }
201
208
}
209
+ } else {
210
+ results. checkNoTask ( . matchRuleType( " GenerateDSYMFile " ) )
202
211
}
203
212
}
204
213
@@ -207,50 +216,58 @@ fileprivate struct DebugInformationTests: CoreBasedTests {
207
216
}
208
217
209
218
// 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: [
211
220
" DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT " : " YES " ,
212
221
" DEBUG_INFORMATION_FORMAT " : " dwarf-with-dsym " ,
213
222
" 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
+ }
220
230
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
+ }
225
235
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 " ] )
228
238
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
+ }
232
243
}
244
+ } else {
245
+ results. checkNoTask ( . matchRuleType( " GenerateDSYMFile " ) )
233
246
}
234
247
235
248
// Check there are no diagnostics.
236
249
results. checkNoDiagnostics ( )
237
250
}
238
251
239
252
// 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: [
241
254
" DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT " : " YES " ,
242
255
" DEBUG_INFORMATION_FORMAT " : " dwarf-with-dsym " ,
243
256
" 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
+ }
248
262
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
+ }
252
266
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
+ }
254
271
255
272
// Check there are no diagnostics.
256
273
results. checkNoDiagnostics ( )
0 commit comments