|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %empty-directory(%t/modulecache) |
| 3 | +// RUN: split-file %s %t |
| 4 | + |
| 5 | +/// Setup the SDK composed of SecretModule and SystemModule |
| 6 | +// RUN: %empty-directory(%t/SDK) |
| 7 | +// RUN: mkdir -p %t/SDK/Frameworks/SecretModule.framework/Modules/SecretModule.swiftmodule |
| 8 | +// RUN: %target-swift-frontend -emit-module -module-name SecretModule \ |
| 9 | +// RUN: -swift-version 5 -enable-library-evolution -parse-stdlib \ |
| 10 | +// RUN: -o %t/SDK/Frameworks/SecretModule.framework/Modules/SecretModule.swiftmodule/%module-target-triple.swiftmodule \ |
| 11 | +// RUN: -emit-module-interface-path %t/SDK/Frameworks/SecretModule.framework/Modules/SecretModule.swiftmodule/%module-target-triple.swiftinterface \ |
| 12 | +// RUN: %t/SecretModule.swift |
| 13 | +// RUN: mkdir -p %t/SDK/Frameworks/SystemModule.framework/Modules/SystemModule.swiftmodule |
| 14 | +// RUN: %target-swift-frontend -emit-module -module-name SystemModule \ |
| 15 | +// RUN: -swift-version 5 -enable-library-evolution -parse-stdlib \ |
| 16 | +// RUN: -o %t/SDK/Frameworks/SystemModule.framework/Modules/SystemModule.swiftmodule/%module-target-triple.swiftmodule \ |
| 17 | +// RUN: -emit-module-interface-path %t/SDK/Frameworks/SystemModule.framework/Modules/SystemModule.swiftmodule/%module-target-triple.swiftinterface \ |
| 18 | +// RUN: -Fsystem %t/SDK/Frameworks \ |
| 19 | +// RUN: %t/SystemModule.swift |
| 20 | + |
| 21 | +/// Index a client of SystemModule reading from the swiftinterface. |
| 22 | +/// Because of disable-deserialization-recovery and leakyFunc, reading from |
| 23 | +/// the swiftmodule would crash. |
| 24 | +// RUN: %empty-directory(%t/idx) |
| 25 | +// RUN: %target-swift-frontend -typecheck -parse-stdlib -swift-version 5 \ |
| 26 | +// RUN: -index-system-modules \ |
| 27 | +// RUN: -index-store-path %t/idx \ |
| 28 | +// RUN: -index-ignore-stdlib \ |
| 29 | +// RUN: -sdk %t/SDK \ |
| 30 | +// RUN: -Fsystem %t/SDK/Frameworks \ |
| 31 | +// RUN: -module-cache-path %t/modulecache \ |
| 32 | +// RUN: %t/Client.swift -disable-deserialization-recovery |
| 33 | + |
| 34 | +/// The index should have the public API of SystemModule |
| 35 | +// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s |
| 36 | +// UNIT: Unit | system | SystemModule | |
| 37 | +// UNIT: Record | system | SystemModule | |
| 38 | +// RUN: c-index-test core -print-record %t/idx | %FileCheck -check-prefix=RECORD %s |
| 39 | +// RECORD: function/Swift | systemFunc() |
| 40 | + |
| 41 | +/// Index a client reading from a broken swiftinterface |
| 42 | +// RUN: %empty-directory(%t/idx) |
| 43 | +// RUN: %empty-directory(%t/modulecache) |
| 44 | +// RUN: echo "breaking_the_swifinterface" >> %t/SDK/Frameworks/SystemModule.framework/Modules/SystemModule.swiftmodule/%module-target-triple.swiftinterface |
| 45 | +// RUN: %target-swift-frontend -typecheck -parse-stdlib \ |
| 46 | +// RUN: -index-system-modules \ |
| 47 | +// RUN: -index-store-path %t/idx \ |
| 48 | +// RUN: -index-ignore-stdlib \ |
| 49 | +// RUN: -sdk %t/SDK \ |
| 50 | +// RUN: -Fsystem %t/SDK/Frameworks \ |
| 51 | +// RUN: -module-cache-path %t/modulecache \ |
| 52 | +// RUN: %t/Client.swift \ |
| 53 | +// RUN: 2>&1 | %FileCheck -check-prefix=BROKEN-BUILD --allow-empty %s |
| 54 | + |
| 55 | +/// We don't expect so see the swiftinterface error for indexing |
| 56 | +// BROKEN-BUILD-NOT: error |
| 57 | +// BROKEN-BUILD-NOT: breaking_the_swifinterface |
| 58 | + |
| 59 | +/// We don't expect SystemModule to be indexed with a broken swiftinterface |
| 60 | +// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=BROKEN-UNIT %s |
| 61 | +// BROKEN-UNIT: Unit | system | SystemModule | |
| 62 | +// BROKEN-UNIT-NOT: Record | system | SystemModule | |
| 63 | +// RUN: c-index-test core -print-record %t/idx | %FileCheck -check-prefix=BROKEN-RECORD %s |
| 64 | +// BROKEN-RECORD-NOT: function/Swift | systemFunc() |
| 65 | + |
| 66 | +//--- SecretModule.swift |
| 67 | +public struct SecretType {} |
| 68 | + |
| 69 | +//--- SystemModule.swift |
| 70 | +// Use this dependency to hit an easy deserialization failure when recovery is disabled. |
| 71 | +@_implementationOnly import SecretModule |
| 72 | + |
| 73 | +public func systemFunc() { } |
| 74 | +func leakyFunc(_ a: SecretType) { } |
| 75 | + |
| 76 | +//--- Client.swift |
| 77 | +import SystemModule |
| 78 | + |
| 79 | +public func clientFunc() {} |
0 commit comments