Skip to content

Commit 172f3ca

Browse files
committed
tests: make tests more resilient to optimizations by passing values to _blackHole
Without `_blackHole`, the optimizer may remove or make assumptions about values, which are not intended by the test. This fixes the tests when running them in optimize mode and when OSSA modules are enabled. This is part of rdar://140229560.
1 parent 66e801b commit 172f3ca

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

validation-test/stdlib/Arrays.swift.gyb

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ let CopyToNativeArrayBufferTests = TestSuite("CopyToNativeArrayBufferTests")
1616

1717
extension Array {
1818
func _rawIdentifier() -> Int {
19+
_blackHole(self)
1920
return unsafeBitCast(self, to: Int.self)
2021
}
2122
}

validation-test/stdlib/Set.swift

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Foundation
1616

1717
extension Set {
1818
func _rawIdentifier() -> Int {
19+
_blackHole(self)
1920
return unsafeBitCast(self, to: Int.self)
2021
}
2122
}

validation-test/stdlib/SetAnyHashableExtensions.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ SetTests.test("insert<Hashable>(_:)/CastTrap")
145145
}
146146

147147
expectCrashLater()
148-
_ = s.insert(TestHashableDerivedB(1010, identity: 3))
148+
let (_, old) = s.insert(TestHashableDerivedB(1010, identity: 3))
149+
_blackHole(old)
149150
}
150151

151152
SetTests.test("update<Hashable>(with:)") {

0 commit comments

Comments
 (0)