Skip to content

Commit 622eb49

Browse files
authored
Merge pull request #42232 from glessard/rdar90336023
[test] expectCrashLater(withMessage:) reliability workaround
2 parents 388b139 + 8e3a476 commit 622eb49

File tree

1 file changed

+20
-50
lines changed

1 file changed

+20
-50
lines changed

test/stdlib/StringAPICString.swift

Lines changed: 20 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,10 @@ CStringTests.test("String.cString.with.Array.UInt8.input") {
239239
}
240240
}
241241
// no need to test every case; that is covered in other tests
242-
#if os(Linux)
243-
expectCrashLater()
244-
#else
245242
expectCrashLater(
246-
withMessage: "input of String.init(cString:) must be null-terminated"
243+
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
244+
// withMessage: "input of String.init(cString:) must be null-terminated"
247245
)
248-
#endif
249246
_ = String(cString: [] as [UInt8])
250247
expectUnreachable()
251248
}
@@ -265,13 +262,10 @@ CStringTests.test("String.cString.with.Array.CChar.input") {
265262
}
266263
}
267264
// no need to test every case; that is covered in other tests
268-
#if os(Linux)
269-
expectCrashLater()
270-
#else
271265
expectCrashLater(
272-
withMessage: "input of String.init(cString:) must be null-terminated"
266+
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
267+
// withMessage: "input of String.init(cString:) must be null-terminated"
273268
)
274-
#endif
275269
_ = String(cString: [] as [CChar])
276270
expectUnreachable()
277271
}
@@ -294,13 +288,10 @@ CStringTests.test("String.cString.with.inout.UInt8.conversion") {
294288
var str = String(cString: &c)
295289
expectTrue(str.isEmpty)
296290
c = 100
297-
#if os(Linux)
298-
expectCrashLater()
299-
#else
300291
expectCrashLater(
301-
withMessage: "input of String.init(cString:) must be null-terminated"
292+
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
293+
// withMessage: "input of String.init(cString:) must be null-terminated"
302294
)
303-
#endif
304295
str = String(cString: &c)
305296
expectUnreachable()
306297
}
@@ -310,13 +301,10 @@ CStringTests.test("String.cString.with.inout.CChar.conversion") {
310301
var str = String(cString: &c)
311302
expectTrue(str.isEmpty)
312303
c = 100
313-
#if os(Linux)
314-
expectCrashLater()
315-
#else
316304
expectCrashLater(
317-
withMessage: "input of String.init(cString:) must be null-terminated"
305+
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
306+
// withMessage: "input of String.init(cString:) must be null-terminated"
318307
)
319-
#endif
320308
str = String(cString: &c)
321309
expectUnreachable()
322310
}
@@ -337,13 +325,10 @@ CStringTests.test("String.validatingUTF8.with.Array.input") {
337325
}
338326
}
339327
// no need to test every case; that is covered in other tests
340-
#if os(Linux)
341-
expectCrashLater()
342-
#else
343328
expectCrashLater(
344-
withMessage: "input of String.init(validatingUTF8:) must be null-terminated"
329+
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
330+
// withMessage: "input of String.init(validatingUTF8:) must be null-terminated"
345331
)
346-
#endif
347332
_ = String(validatingUTF8: [])
348333
expectUnreachable()
349334
}
@@ -369,13 +354,10 @@ CStringTests.test("String.validatingUTF8.with.inout.conversion") {
369354
expectNotNil(str)
370355
expectEqual(str?.isEmpty, true)
371356
c = 100
372-
#if os(Linux)
373-
expectCrashLater()
374-
#else
375357
expectCrashLater(
376-
withMessage: "input of String.init(validatingUTF8:) must be null-terminated"
358+
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
359+
// withMessage: "input of String.init(validatingUTF8:) must be null-terminated"
377360
)
378-
#endif
379361
str = String(validatingUTF8: &c)
380362
expectUnreachable()
381363
}
@@ -397,13 +379,10 @@ CStringTests.test("String.decodeCString.with.Array.input") {
397379
}
398380
}
399381
// no need to test every case; that is covered in other tests
400-
#if os(Linux)
401-
expectCrashLater()
402-
#else
403382
expectCrashLater(
404-
withMessage: "input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated"
383+
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
384+
// withMessage: "input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated"
405385
)
406-
#endif
407386
_ = String.decodeCString([], as: Unicode.UTF8.self)
408387
expectUnreachable()
409388
}
@@ -436,13 +415,10 @@ CStringTests.test("String.decodeCString.with.inout.conversion") {
436415
expectEqual(result?.result.isEmpty, true)
437416
expectEqual(result?.repairsMade, false)
438417
c = 100
439-
#if os(Linux)
440-
expectCrashLater()
441-
#else
442418
expectCrashLater(
443-
withMessage: "input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated"
419+
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
420+
// withMessage: "input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated"
444421
)
445-
#endif
446422
result = String.decodeCString(&c, as: Unicode.UTF8.self)
447423
expectUnreachable()
448424
}
@@ -462,13 +438,10 @@ CStringTests.test("String.init.decodingCString.with.Array.input") {
462438
}
463439
}
464440
// no need to test every case; that is covered in other tests
465-
#if os(Linux)
466-
expectCrashLater()
467-
#else
468441
expectCrashLater(
469-
withMessage: "input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated"
442+
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
443+
// withMessage: "input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated"
470444
)
471-
#endif
472445
_ = String(decodingCString: [], as: Unicode.UTF8.self)
473446
expectUnreachable()
474447
}
@@ -491,13 +464,10 @@ CStringTests.test("String.init.decodingCString.with.inout.conversion") {
491464
var str = String(decodingCString: &c, as: Unicode.UTF8.self)
492465
expectEqual(str.isEmpty, true)
493466
c = 100
494-
#if os(Linux)
495-
expectCrashLater()
496-
#else
497467
expectCrashLater(
498-
withMessage: "input of String.init(decodingCString:as:) must be null-terminated"
468+
// Workaround for https://bugs.swift.org/browse/SR-16103 (rdar://91365967)
469+
// withMessage: "input of String.init(decodingCString:as:) must be null-terminated"
499470
)
500-
#endif
501471
str = String(decodingCString: &c, as: Unicode.UTF8.self)
502472
expectUnreachable()
503473
}

0 commit comments

Comments
 (0)