|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | + |
| 3 | +// RUN: %target-build-swift-dylib(%t/libresil.%target-dylib-extension) -Xfrontend -enable-resilience %S/Inputs/resilient_generic_struct_v1.swift -emit-module -emit-module-path %t/resil.swiftmodule -module-name resil |
| 4 | +// RUN: %target-codesign %t/libresil.%target-dylib-extension |
| 5 | + |
| 6 | +// RUN: %target-build-swift %s -L %t -I %t -lresil -o %t/main -Xlinker -rpath -Xlinker %t |
| 7 | + |
| 8 | +// RUN: %target-build-swift-dylib(%t/libresil.%target-dylib-extension) -Xfrontend -enable-resilience %S/Inputs/resilient_generic_struct_v2.swift -emit-module -emit-module-path %t/resil.swiftmodule -module-name resil |
| 9 | +// RUN: %target-codesign %t/libresil.%target-dylib-extension |
| 10 | + |
| 11 | +// RUN: %target-run %t/main %t/libresil.%target-dylib-extension |
| 12 | + |
| 13 | +import StdlibUnittest |
| 14 | + |
| 15 | +// We build this code against a version of 'resil' where |
| 16 | +// ResilientGenericStruct<T> doesn't store a T, then switch the |
| 17 | +// dynamic library to a new version where it does, introducing |
| 18 | +// an unresolvable dynamic cycle. |
| 19 | +// |
| 20 | +// It would also be sufficient to demonstrate this crash if the |
| 21 | +// compiler *actually* didn't know about the internal implementation |
| 22 | +// details of 'resil' when building this file, but since it currently |
| 23 | +// still does, it'll report a cycle immediately if we don't pull |
| 24 | +// this switcharoo. |
| 25 | +import resil |
| 26 | + |
| 27 | +var DynamicMetadataCycleTests = |
| 28 | + TestSuite("Unresolvable dynamic metadata cycle tests") |
| 29 | + |
| 30 | +enum test0_Node { |
| 31 | + case link(ResilientGenericStruct<test0_Node>) |
| 32 | + |
| 33 | + static func test() -> [test0_Node] { |
| 34 | + return [] |
| 35 | + } |
| 36 | +} |
| 37 | +DynamicMetadataCycleTests.test("cycle through enum") |
| 38 | + .crashOutputMatches("runtime error: unresolvable type metadata dependency cycle detected") |
| 39 | + .crashOutputMatches(" main.test0_Node") |
| 40 | + .crashOutputMatches(" depends on layout of resil.ResilientGenericStruct<main.test0_Node") |
| 41 | + .crashOutputMatches(" depends on layout of main.test0_Node") |
| 42 | + .code { |
| 43 | + expectCrashLater() |
| 44 | + _ = test0_Node.test() |
| 45 | + } |
| 46 | + |
| 47 | +runAllTests() |
0 commit comments