7
7
8
8
import StdlibUnittest
9
9
10
+ #if os(WASI)
11
+ let enableCrashTests = false
12
+ #else
13
+ let enableCrashTests = true
14
+ #endif
15
+
10
16
var CStringTests = TestSuite ( " CStringTests " )
11
17
12
18
func getNullUTF8( ) -> UnsafeMutablePointer < UInt8 > ? {
@@ -239,6 +245,7 @@ CStringTests.test("String.cString.with.Array.UInt8.input") {
239
245
}
240
246
}
241
247
}
248
+ guard enableCrashTests else { return }
242
249
// no need to test every case; that is covered in other tests
243
250
expectCrashLater (
244
251
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
@@ -263,6 +270,7 @@ CStringTests.test("String.cString.with.Array.CChar.input") {
263
270
}
264
271
}
265
272
}
273
+ guard enableCrashTests else { return }
266
274
// no need to test every case; that is covered in other tests
267
275
expectCrashLater (
268
276
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
@@ -292,6 +300,7 @@ CStringTests.test("String.cString.with.inout.UInt8.conversion") {
292
300
var str = String ( cString: & c)
293
301
expectTrue ( str. isEmpty)
294
302
c = 100
303
+ guard enableCrashTests else { return }
295
304
expectCrashLater (
296
305
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
297
306
// withMessage: "input of String.init(cString:) must be null-terminated"
@@ -306,6 +315,7 @@ CStringTests.test("String.cString.with.inout.CChar.conversion") {
306
315
var str = String ( cString: & c)
307
316
expectTrue ( str. isEmpty)
308
317
c = 100
318
+ guard enableCrashTests else { return }
309
319
expectCrashLater (
310
320
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
311
321
// withMessage: "input of String.init(cString:) must be null-terminated"
@@ -330,6 +340,7 @@ CStringTests.test("String.validatingUTF8.with.Array.input") {
330
340
}
331
341
}
332
342
}
343
+ guard enableCrashTests else { return }
333
344
// no need to test every case; that is covered in other tests
334
345
expectCrashLater (
335
346
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
@@ -362,6 +373,7 @@ CStringTests.test("String.validatingUTF8.with.inout.conversion") {
362
373
expectNotNil ( str)
363
374
expectEqual ( str? . isEmpty, true )
364
375
c = 100
376
+ guard enableCrashTests else { return }
365
377
expectCrashLater (
366
378
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
367
379
// withMessage: "input of String.init(validatingUTF8:) must be null-terminated"
@@ -387,6 +399,7 @@ CStringTests.test("String.decodeCString.with.Array.input") {
387
399
}
388
400
}
389
401
}
402
+ guard enableCrashTests else { return }
390
403
// no need to test every case; that is covered in other tests
391
404
expectCrashLater (
392
405
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
@@ -426,6 +439,7 @@ CStringTests.test("String.decodeCString.with.inout.conversion") {
426
439
expectEqual ( result? . result. isEmpty, true )
427
440
expectEqual ( result? . repairsMade, false )
428
441
c = 100
442
+ guard enableCrashTests else { return }
429
443
expectCrashLater (
430
444
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
431
445
// withMessage: "input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated"
@@ -449,6 +463,7 @@ CStringTests.test("String.init.decodingCString.with.Array.input") {
449
463
}
450
464
}
451
465
}
466
+ guard enableCrashTests else { return }
452
467
// no need to test every case; that is covered in other tests
453
468
expectCrashLater (
454
469
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
@@ -478,6 +493,7 @@ CStringTests.test("String.init.decodingCString.with.inout.conversion") {
478
493
var str = String ( decodingCString: & c, as: Unicode . UTF8. self)
479
494
expectEqual ( str. isEmpty, true )
480
495
c = 100
496
+ guard enableCrashTests else { return }
481
497
expectCrashLater (
482
498
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
483
499
// withMessage: "input of String.init(decodingCString:as:) must be null-terminated"
0 commit comments