Skip to content

Commit 4c28e82

Browse files
committed
[test] Fix expected error message with backdeployed runtimes
1 parent 245745b commit 4c28e82

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

validation-test/stdlib/ArrayTrapsObjC.swift

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ ArrayTraps.test("bounds_with_downcast")
8383
_ = da[2]
8484
}
8585

86+
func hasBackdeployedConcurrencyRuntime() -> Bool {
87+
// If the stdlib we've loaded predates Swift 5.5, then we're running on a back
88+
// deployed concurrency runtime, which has the side effect of disabling
89+
// regular runtime exclusivity checks.
90+
//
91+
// This makes the two tests below fall back to older, higher-level exclusivity
92+
// checks in the stdlib, which will still trap, but with a different message.
93+
if #available(SwiftStdlib 5.5, *) { return false }
94+
return true
95+
}
96+
8697
var ArraySemanticOptzns = TestSuite("ArraySemanticOptzns" + testSuiteSuffix)
8798

8899
class BaseClass {
@@ -131,8 +142,11 @@ ArraySemanticOptzns.test("inout_rule_violated_isNativeBuffer")
131142
.skip(.custom(
132143
{ _isFastAssertConfiguration() },
133144
reason: "this trap is not guaranteed to happen in -Ounchecked"))
134-
.crashOutputMatches(_isDebugAssertConfiguration() ?
135-
"Fatal access conflict detected." : "")
145+
.crashOutputMatches(
146+
!_isDebugAssertConfiguration() ? ""
147+
: hasBackdeployedConcurrencyRuntime() ? "inout rules were violated"
148+
: "Fatal access conflict detected."
149+
)
136150
.code {
137151
let v = ViolateInoutSafetySwitchToObjcBuffer()
138152
expectCrashLater()
@@ -174,8 +188,11 @@ ArraySemanticOptzns.test("inout_rule_violated_needsElementTypeCheck")
174188
.skip(.custom(
175189
{ _isFastAssertConfiguration() },
176190
reason: "this trap is not guaranteed to happen in -Ounchecked"))
177-
.crashOutputMatches(_isDebugAssertConfiguration() ?
178-
"Fatal access conflict detected." : "")
191+
.crashOutputMatches(
192+
!_isDebugAssertConfiguration() ? ""
193+
: hasBackdeployedConcurrencyRuntime() ? "inout rules were violated"
194+
: "Fatal access conflict detected."
195+
)
179196
.code {
180197
let v = ViolateInoutSafetyNeedElementTypeCheck()
181198
expectCrashLater()

0 commit comments

Comments
 (0)