Skip to content

Commit 803035a

Browse files
authored
Merge pull request #67471 from apple/maxd/skip-crashing-wasi
test: disable crashing tests on WASI WASI doesn't support spawning a subprocess, so crash tests crashes the test harness itself. Those should be skipped until proper subprocess support is available.
2 parents d163261 + a7142c8 commit 803035a

9 files changed

+40
-2
lines changed

test/Concurrency/Runtime/actor_assert_precondition_executor.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ actor Someone {
7878
await MainFriend().callCheckMainActor()
7979
}
8080

81+
#if !os(WASI)
8182
tests.test("precondition on actor (main): wrongly assume the main executor, from actor on other executor") {
8283
expectCrashLater(withMessage: "Incorrect actor executor assumption; Expected 'MainActor' executor.")
8384
await Someone().callCheckMainActor()
8485
}
86+
#endif
8587

8688
// === Global actor -----------------------------------------------------
8789

@@ -94,4 +96,4 @@ actor Someone {
9496

9597
await runAllTestsAsync()
9698
}
97-
}
99+
}

test/Concurrency/Runtime/actor_assume_executor.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,17 @@ final class MainActorEcho {
115115
await MainFriend().callCheck(echo: echo)
116116
}
117117

118+
#if !os(WASI)
118119
tests.test("MainActor.assumeIsolated: wrongly assume the main executor, from actor on other executor") {
119120
expectCrashLater(withMessage: "Incorrect actor executor assumption; Expected 'MainActor' executor.")
120121
await Someone().callCheckMainActor(echo: echo)
121122
}
123+
#endif
122124

123125
// === some Actor -------------------------------------------------------
124126

125127
let someone = Someone()
128+
#if !os(WASI)
126129
tests.test("assumeOnActorExecutor: wrongly assume someone's executor, from 'main() async'") {
127130
expectCrashLater(withMessage: "Incorrect actor executor assumption; Expected same executor as a.Someone.")
128131
checkAssumeSomeone(someone: someone)
@@ -132,6 +135,7 @@ final class MainActorEcho {
132135
expectCrashLater(withMessage: "Incorrect actor executor assumption; Expected same executor as a.Someone.")
133136
checkAssumeSomeone(someone: someone)
134137
}
138+
#endif
135139

136140
tests.test("assumeOnActorExecutor: assume someone's executor, from Someone") {
137141
await someone.callCheckSomeone()
@@ -141,11 +145,12 @@ final class MainActorEcho {
141145
await SomeonesFriend(someone: someone).callCheckSomeone()
142146
}
143147

148+
#if !os(WASI)
144149
tests.test("assumeOnActorExecutor: wrongly assume the main executor, from actor on other executor") {
145150
expectCrashLater(withMessage: "Incorrect actor executor assumption; Expected same executor as a.Someone.")
146151
await CompleteStranger(someone: someone).callCheckSomeone()
147152
}
148-
153+
#endif
149154

150155
}
151156

test/Concurrency/Runtime/checked_continuation.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct TestError: Error {}
1616
var tests = TestSuite("CheckedContinuation")
1717

1818
if #available(SwiftStdlib 5.1, *) {
19+
#if !os(WASI)
1920
tests.test("trap on double resume non-throwing continuation") {
2021
expectCrashLater()
2122

@@ -42,6 +43,7 @@ struct TestError: Error {}
4243
}
4344
await task.get()
4445
}
46+
#endif
4547

4648
tests.test("test withCheckedThrowingContinuation") {
4749
let task2 = detach {

test/Concurrency/Runtime/continuation_validation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// UNSUPPORTED: back_deploy_concurrency
1313
// UNSUPPORTED: use_os_stdlib
1414
// UNSUPPORTED: freestanding
15+
// UNSUPPORTED: OS=wasi
1516

1617
import StdlibUnittest
1718

test/stdlib/Error.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ ErrorTests.test("test dealloc empty error box") {
207207
}
208208
}
209209

210+
#if !os(WASI)
210211
var errors: [Error] = []
211212

212213
@inline(never)
@@ -249,6 +250,7 @@ ErrorTests.test("willThrow") {
249250
expectEqual(2, errors.count)
250251
expectEqual(SillyError.self, type(of: errors.last!))
251252
}
253+
#endif
252254
253255
runAllTests()
254256

test/stdlib/StringAPI.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ StringTests.test("SameTypeComparisons") {
342342
expectFalse(xs != xs)
343343
}
344344

345+
#if !os(WASI)
345346
StringTests.test("CompareStringsWithUnpairedSurrogates")
346347
.xfail(
347348
.always("<rdar://problem/18029104> Strings referring to underlying " +
@@ -357,6 +358,7 @@ StringTests.test("CompareStringsWithUnpairedSurrogates")
357358
]
358359
)
359360
}
361+
#endif
360362

361363
StringTests.test("[String].joined() -> String") {
362364
let s = ["hello", "world"].joined()

test/stdlib/StringAPICString.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88
import StdlibUnittest
99

10+
#if os(WASI)
11+
let enableCrashTests = false
12+
#else
13+
let enableCrashTests = true
14+
#endif
15+
1016
var CStringTests = TestSuite("CStringTests")
1117

1218
func getNullUTF8() -> UnsafeMutablePointer<UInt8>? {
@@ -239,6 +245,7 @@ CStringTests.test("String.cString.with.Array.UInt8.input") {
239245
}
240246
}
241247
}
248+
guard enableCrashTests else { return }
242249
// no need to test every case; that is covered in other tests
243250
expectCrashLater(
244251
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
@@ -263,6 +270,7 @@ CStringTests.test("String.cString.with.Array.CChar.input") {
263270
}
264271
}
265272
}
273+
guard enableCrashTests else { return }
266274
// no need to test every case; that is covered in other tests
267275
expectCrashLater(
268276
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
@@ -292,6 +300,7 @@ CStringTests.test("String.cString.with.inout.UInt8.conversion") {
292300
var str = String(cString: &c)
293301
expectTrue(str.isEmpty)
294302
c = 100
303+
guard enableCrashTests else { return }
295304
expectCrashLater(
296305
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
297306
// withMessage: "input of String.init(cString:) must be null-terminated"
@@ -306,6 +315,7 @@ CStringTests.test("String.cString.with.inout.CChar.conversion") {
306315
var str = String(cString: &c)
307316
expectTrue(str.isEmpty)
308317
c = 100
318+
guard enableCrashTests else { return }
309319
expectCrashLater(
310320
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
311321
// withMessage: "input of String.init(cString:) must be null-terminated"
@@ -330,6 +340,7 @@ CStringTests.test("String.validatingUTF8.with.Array.input") {
330340
}
331341
}
332342
}
343+
guard enableCrashTests else { return }
333344
// no need to test every case; that is covered in other tests
334345
expectCrashLater(
335346
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
@@ -362,6 +373,7 @@ CStringTests.test("String.validatingUTF8.with.inout.conversion") {
362373
expectNotNil(str)
363374
expectEqual(str?.isEmpty, true)
364375
c = 100
376+
guard enableCrashTests else { return }
365377
expectCrashLater(
366378
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
367379
// withMessage: "input of String.init(validatingUTF8:) must be null-terminated"
@@ -387,6 +399,7 @@ CStringTests.test("String.decodeCString.with.Array.input") {
387399
}
388400
}
389401
}
402+
guard enableCrashTests else { return }
390403
// no need to test every case; that is covered in other tests
391404
expectCrashLater(
392405
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
@@ -426,6 +439,7 @@ CStringTests.test("String.decodeCString.with.inout.conversion") {
426439
expectEqual(result?.result.isEmpty, true)
427440
expectEqual(result?.repairsMade, false)
428441
c = 100
442+
guard enableCrashTests else { return }
429443
expectCrashLater(
430444
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
431445
// withMessage: "input of decodeCString(_:as:repairingInvalidCodeUnits:) must be null-terminated"
@@ -449,6 +463,7 @@ CStringTests.test("String.init.decodingCString.with.Array.input") {
449463
}
450464
}
451465
}
466+
guard enableCrashTests else { return }
452467
// no need to test every case; that is covered in other tests
453468
expectCrashLater(
454469
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
@@ -478,6 +493,7 @@ CStringTests.test("String.init.decodingCString.with.inout.conversion") {
478493
var str = String(decodingCString: &c, as: Unicode.UTF8.self)
479494
expectEqual(str.isEmpty, true)
480495
c = 100
496+
guard enableCrashTests else { return }
481497
expectCrashLater(
482498
// Workaround for https://github.com/apple/swift/issues/58362 (rdar://91365967)
483499
// withMessage: "input of String.init(decodingCString:as:) must be null-terminated"

test/stdlib/TemporaryAllocation.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ TemporaryAllocationTestSuite.test("untypedEmptyAllocationIsStackAllocated") {
7070
}
7171
}
7272

73+
#if !os(WASI)
7374
TemporaryAllocationTestSuite.test("crashOnNegativeByteCount") {
7475
expectCrash {
7576
let byteCount = Int.random(in: -2 ..< -1)
@@ -83,6 +84,7 @@ TemporaryAllocationTestSuite.test("crashOnNegativeAlignment") {
8384
withUnsafeTemporaryAllocation(byteCount: 16, alignment: alignment) { _ in }
8485
}
8586
}
87+
#endif
8688

8789
TemporaryAllocationTestSuite.test("untypedAllocationIsAligned") {
8890
withUnsafeTemporaryAllocation(byteCount: 1, alignment: 8) { buffer in
@@ -136,12 +138,14 @@ TemporaryAllocationTestSuite.test("voidAllocationIsStackAllocated") {
136138
}
137139
}
138140

141+
#if !os(WASI)
139142
TemporaryAllocationTestSuite.test("crashOnNegativeValueCount") {
140143
expectCrash {
141144
let capacity = Int.random(in: -2 ..< -1)
142145
withUnsafeTemporaryAllocation(of: Int.self, capacity: capacity) { _ in }
143146
}
144147
}
148+
#endif
145149

146150
TemporaryAllocationTestSuite.test("typedAllocationIsAligned") {
147151
withUnsafeTemporaryAllocation(of: Int.self, capacity: 1) { buffer in

test/stdlib/UnsafeRawPointer.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ UnsafeMutableRawPointerExtraTestSuite.test("load.unaligned")
131131
expectEqual(result, 0xffff_0000)
132132
}
133133

134+
#if !os(WASI)
134135
UnsafeMutableRawPointerExtraTestSuite.test("load.invalid")
135136
.skip(.custom({ !_isDebugAssertConfiguration() },
136137
reason: "This tests a debug precondition.."))
@@ -154,6 +155,7 @@ UnsafeMutableRawPointerExtraTestSuite.test("load.invalid.mutable")
154155
}
155156
expectUnreachable()
156157
}
158+
#endif
157159

158160
UnsafeMutableRawPointerExtraTestSuite.test("store.unaligned")
159161
.skip(.custom({
@@ -184,6 +186,7 @@ UnsafeMutableRawPointerExtraTestSuite.test("store.unaligned")
184186
0)
185187
}
186188

189+
#if !os(WASI)
187190
UnsafeMutableRawPointerExtraTestSuite.test("store.invalid")
188191
.skip(.custom({ !_isDebugAssertConfiguration() },
189192
reason: "This tests a debug precondition.."))
@@ -203,6 +206,7 @@ UnsafeMutableRawPointerExtraTestSuite.test("store.invalid")
203206
p1.storeBytes(of: m, as: Missile.self)
204207
expectUnreachable()
205208
}
209+
#endif
206210

207211
UnsafeMutableRawPointerExtraTestSuite.test("copyMemory") {
208212
let sizeInBytes = 4 * MemoryLayout<Int>.stride

0 commit comments

Comments
 (0)