|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | + |
| 3 | +// NOTE: the two tests below look like a lot of copy-pasting, but the only thing that's varying between |
| 4 | +// the two checks is whether "-D DELEGATES" is passed when compiling MysteryInit and whether the check-prefix when running the executable matches that or not. |
| 5 | + |
| 6 | +/// ----------------------------------------------------------------------- |
| 7 | +/// Check if the actor init in the library can change from delegating to non-delegating |
| 8 | +/// ----------------------------------------------------------------------- |
| 9 | + |
| 10 | +// ------> first library DOES delegate |
| 11 | +// RUN: %target-build-swift-dylib(%t/%target-library-name(MysteryInit)) -D DELEGATES -Xfrontend -disable-availability-checking -enable-library-evolution %S/Inputs/MysteryInit.swift -emit-module -emit-module-path %t/MysteryInit.swiftmodule -module-name MysteryInit |
| 12 | +// RUN: %target-codesign %t/%target-library-name(MysteryInit) |
| 13 | + |
| 14 | + |
| 15 | +// ------> make sure that works |
| 16 | +// RUN: %target-build-swift -parse-as-library -Xfrontend -disable-availability-checking %s -lMysteryInit -I %t -L %t -o %t/main %target-rpath(%t) |
| 17 | +// RUN: %target-codesign %t/main |
| 18 | +// RUN: %target-run %t/main %t/%target-library-name(MysteryInit) | %FileCheck --check-prefix=CHECK-DELEGATES %s |
| 19 | + |
| 20 | +// ------> do a little internal sanity check on this test itself |
| 21 | +// RUN: %target-run %t/main %t/%target-library-name(MysteryInit) | not %FileCheck --check-prefix=CHECK-NO-DELEGATES %s |
| 22 | + |
| 23 | +// ------> now recompile that library's init so it DOES NOT delegate, without recompiling executable |
| 24 | +// RUN: %target-build-swift-dylib(%t/%target-library-name(MysteryInit)) -Xfrontend -disable-availability-checking -enable-library-evolution %S/Inputs/MysteryInit.swift -emit-module -emit-module-path %t/MysteryInit.swiftmodule -module-name MysteryInit |
| 25 | +// RUN: %target-codesign %t/%target-library-name(MysteryInit) |
| 26 | + |
| 27 | +// ------> re-run executable |
| 28 | +// RUN: %target-run %t/main %t/%target-library-name(MysteryInit) | %FileCheck --check-prefix=CHECK-NO-DELEGATES %s |
| 29 | + |
| 30 | + |
| 31 | +/// ----------------------------------------------------------------------- |
| 32 | +/// now, other direction: Check if the actor init can change from non-delegating to delegating |
| 33 | +/// ----------------------------------------------------------------------- |
| 34 | + |
| 35 | +// ------> library currently DOES NOT delegate. recompile executable to match. |
| 36 | +// RUN: %target-build-swift -parse-as-library -Xfrontend -disable-availability-checking %s -lMysteryInit -I %t -L %t -o %t/main %target-rpath(%t) |
| 37 | +// RUN: %target-codesign %t/main |
| 38 | +// RUN: %target-run %t/main %t/%target-library-name(MysteryInit) | %FileCheck --check-prefix=CHECK-NO-DELEGATES %s |
| 39 | + |
| 40 | +// ------> now recompile that library's init so it DOES delegate, without recompiling executable |
| 41 | +// RUN: %target-build-swift-dylib(%t/%target-library-name(MysteryInit)) -D DELEGATES -Xfrontend -disable-availability-checking -enable-library-evolution %S/Inputs/MysteryInit.swift -emit-module -emit-module-path %t/MysteryInit.swiftmodule -module-name MysteryInit |
| 42 | +// RUN: %target-codesign %t/%target-library-name(MysteryInit) |
| 43 | + |
| 44 | +// ------> re-run executable |
| 45 | +// RUN: %target-run %t/main %t/%target-library-name(MysteryInit) | %FileCheck --check-prefix=CHECK-DELEGATES %s |
| 46 | + |
| 47 | + |
| 48 | +// REQUIRES: executable_test |
| 49 | +// REQUIRES: concurrency |
| 50 | + |
| 51 | +// rdar://76038845 |
| 52 | +// REQUIRES: concurrency_runtime |
| 53 | +// UNSUPPORTED: back_deployment_runtime |
| 54 | + |
| 55 | +import MysteryInit |
| 56 | + |
| 57 | +@main |
| 58 | +struct Main { |
| 59 | + static func main() { |
| 60 | + switch BigFoot() { |
| 61 | + case .none: |
| 62 | + print("bigfoot is myth") |
| 63 | + // CHECK-NO-DELEGATES: bigfoot is myth |
| 64 | + default: |
| 65 | + print("bigfoot is real") |
| 66 | + // CHECK-DELEGATES: bigfoot is real |
| 67 | + } |
| 68 | + } |
| 69 | +} |
0 commit comments