mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
A number of tests exercise features only available in Apple OSes that shipped with Swift 5.0 in the OS; this includes the following versions: - macOS 10.14.4 - iOS 12.2 - tvOS 12.2 - watchOS 5.2 Previously these tests were restricted to running on macOS only, with an explicit -target x86_64-apple-macosx10.14.4. To get better test coverage, add a new %target-stable-abi-triple substitution which expands to a triple with the correct OS version on all Apple platforms. On non-Apple platforms, this is the same as %target-variant-triple, but for now any test that uses this exercises Apple platform features anyway. One caveat is that since iOS 12.2 does not have a 32-bit slice, we have to skip any tests that use -target %target-stable-abi-triple on this platform. A new swift_stable_abi feature flag can be tested with 'REQUIRES: swift_stable_abi'. To get maximum test coverage, I split off a 'stable_abi' version of a few tests that build with both an old and new deployment target. This allows the old deployment target case to still be tested on 32-bit iOS.
51 lines
1.6 KiB
Swift
51 lines
1.6 KiB
Swift
// RUN: %empty-directory(%t)
|
|
|
|
// RUN: %target-build-swift-dylib(%t/%target-library-name(resilient_struct)) -enable-library-evolution %S/../../test/Inputs/resilient_struct.swift -emit-module -emit-module-path %t/resilient_struct.swiftmodule -module-name resilient_struct
|
|
// RUN: %target-codesign %t/%target-library-name(resilient_struct)
|
|
|
|
// RUN: %target-build-swift %s -L %t -I %t -lresilient_struct -o %t/main %target-rpath(%t) -target %target-stable-abi-triple
|
|
// RUN: %target-codesign %t/main
|
|
|
|
// RUN: %target-run %t/main %t/%target-library-name(resilient_struct) %t/libresilient_class%{target-shared-library-suffix}
|
|
|
|
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: objc_interop
|
|
// REQUIRES: OS=macosx
|
|
// REQUIRES: CPU=x86_64
|
|
|
|
// Test that on an old Objective-C runtime we crash if attempting to use a
|
|
// class that requires the update callback and does not have a fragile layout.
|
|
|
|
import StdlibUnittest
|
|
import resilient_struct
|
|
|
|
var ClassTestSuite = TestSuite("Update callback")
|
|
|
|
public class ClassWithResilientField {
|
|
var x = ResilientInt(i: 0)
|
|
}
|
|
|
|
@_optimize(none) func blackHole<T>(_: T) {}
|
|
|
|
@_optimize(none) func forceMetadata() {
|
|
blackHole(ClassWithResilientField())
|
|
}
|
|
|
|
if #available(macOS 10.14.4, iOS 12.2, tvOS 12.2, watchOS 5.2, *) {
|
|
ClassTestSuite.test("RealizeResilientClass") {
|
|
print("Nothing to test. We have the new Objective-C runtime.")
|
|
forceMetadata()
|
|
}
|
|
} else {
|
|
ClassTestSuite.test("RealizeResilientClass")
|
|
.crashOutputMatches("class ClassWithResilientField does not have a fragile layout")
|
|
.code {
|
|
expectCrashLater()
|
|
print("About to crash...")
|
|
forceMetadata()
|
|
}
|
|
}
|
|
|
|
runAllTests()
|