1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
// RUN: %empty-directory(%t)
// RUN: split-file %s %t
/// Setup the SDK composed of SecretModule, SystemModule, SystemDepA, SystemDepB, and SystemDepCommon
// RUN: %empty-directory(%t/SDK)
// RUN: mkdir -p %t/SDK/Frameworks/SecretModule.framework/Modules/SecretModule.swiftmodule
// RUN: %target-swift-frontend -emit-module -module-name SecretModule \
// RUN: -swift-version 5 -enable-library-evolution -parse-stdlib \
// RUN: -o %t/SDK/Frameworks/SecretModule.framework/Modules/SecretModule.swiftmodule/%module-target-triple.swiftmodule \
// RUN: -emit-module-interface-path %t/SDK/Frameworks/SecretModule.framework/Modules/SecretModule.swiftmodule/%module-target-triple.swiftinterface \
// RUN: %t/SecretModule.swift
// RUN: mkdir -p %t/SDK/Frameworks/SystemDepCommon.framework/Modules/SystemDepCommon.swiftmodule
// RUN: %target-swift-frontend -emit-module -module-name SystemDepCommon \
// RUN: -swift-version 5 -enable-library-evolution -parse-stdlib \
// RUN: -o %t/SDK/Frameworks/SystemDepCommon.framework/Modules/SystemDepCommon.swiftmodule/%module-target-triple.swiftmodule \
// RUN: -emit-module-interface-path %t/SDK/Frameworks/SystemDepCommon.framework/Modules/SystemDepCommon.swiftmodule/%module-target-triple.swiftinterface \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: %t/SystemDepCommon.swift
// RUN: mkdir -p %t/SDK/Frameworks/SystemDepA.framework/Modules/SystemDepA.swiftmodule
// RUN: %target-swift-frontend -emit-module -module-name SystemDepA \
// RUN: -swift-version 5 -enable-library-evolution -parse-stdlib \
// RUN: -o %t/SDK/Frameworks/SystemDepA.framework/Modules/SystemDepA.swiftmodule/%module-target-triple.swiftmodule \
// RUN: -emit-module-interface-path %t/SDK/Frameworks/SystemDepA.framework/Modules/SystemDepA.swiftmodule/%module-target-triple.swiftinterface \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: %t/SystemDepA.swift
// RUN: mkdir -p %t/SDK/Frameworks/SystemDepB.framework/Modules/SystemDepB.swiftmodule
// RUN: %target-swift-frontend -emit-module -module-name SystemDepB \
// RUN: -swift-version 5 -enable-library-evolution -parse-stdlib \
// RUN: -o %t/SDK/Frameworks/SystemDepB.framework/Modules/SystemDepB.swiftmodule/%module-target-triple.swiftmodule \
// RUN: -emit-module-interface-path %t/SDK/Frameworks/SystemDepB.framework/Modules/SystemDepB.swiftmodule/%module-target-triple.swiftinterface \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: %t/SystemDepB.swift
// RUN: mkdir -p %t/SDK/Frameworks/SystemModule.framework/Modules/SystemModule.swiftmodule
// RUN: %target-swift-frontend -emit-module -module-name SystemModule \
// RUN: -swift-version 5 -enable-library-evolution -parse-stdlib \
// RUN: -o %t/SDK/Frameworks/SystemModule.framework/Modules/SystemModule.swiftmodule/%module-target-triple.swiftmodule \
// RUN: -emit-module-interface-path %t/SDK/Frameworks/SystemModule.framework/Modules/SystemModule.swiftmodule/%module-target-triple.swiftinterface \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: %t/SystemModule.swift
/// Index a client of SystemModule reading from the swiftinterface.
/// Because of disable-deserialization-recovery and leakyFunc, reading from
/// the swiftmodule would crash.
// RUN: %target-swift-frontend -typecheck -parse-stdlib -swift-version 5 \
// RUN: -index-system-modules \
// RUN: -index-store-path %t/idx \
// RUN: -index-ignore-stdlib \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: -Rindexing-system-module -Rmodule-loading \
// RUN: %t/Client.swift -disable-deserialization-recovery \
// RUN: 2>&1 | %FileCheck -check-prefix=SYSTEM-INDEX %s
// SYSTEM-INDEX: loaded module 'SystemDepCommon'; source: '{{.*}}SystemDepCommon.swiftmodule{{.*}}.swiftinterface'
// SYSTEM-INDEX: loaded module 'SystemDepCommon'; source: '{{.*}}SystemDepCommon.swiftmodule{{.*}}.swiftinterface'
// SYSTEM-INDEX-NOT: loaded module {{.*}}SystemDepCommon
// SYSTEM-INDEX: indexing system module {{.*}}SystemDepCommon.swiftmodule{{.*}}.swiftinterface
// SYSTEM-INDEX-NOT: loaded module {{.*}}SystemDepCommon
// SYSTEM-INDEX-NOT: indexing system module {{.*}}SystemDepCommon
/// The index should have the public API of SystemModule
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s
// UNIT: Unit | system | SystemModule |
// UNIT: Record | system | SystemModule |
// RUN: c-index-test core -print-record %t/idx | %FileCheck -check-prefix=RECORD %s
// RECORD: function/Swift | systemFunc()
/// Now rebuild the same module. We should not reload or re-index any of the
/// system modules.
// RUN: %target-swift-frontend -typecheck -parse-stdlib -swift-version 5 \
// RUN: -index-system-modules \
// RUN: -index-store-path %t/idx \
// RUN: -index-ignore-stdlib \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: -Rindexing-system-module -Rmodule-loading \
// RUN: %t/Client.swift -disable-deserialization-recovery \
// RUN: 2>&1 | %FileCheck -check-prefix=SECOND-SYSTEM-INDEX %s
// SECOND-SYSTEM-INDEX: loaded module 'SystemDepCommon'; source: '{{.*}}SystemDepCommon.swiftmodule{{.*}}.swiftinterface'
// SECOND-SYSTEM-INDEX-NOT: loaded module {{.*}}SystemDepCommon
// SECOND-SYSTEM-INDEX-NOT: indexing system module {{.*}}SystemDepCommon
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s
// RUN: c-index-test core -print-record %t/idx | %FileCheck -check-prefix=RECORD %s
/// Rebuild again, but this time remove the index. We should re-index, but not
/// reload the module as it was already built.
// RUN: %empty-directory(%t/idx)
// RUN: %target-swift-frontend -typecheck -parse-stdlib -swift-version 5 \
// RUN: -index-system-modules \
// RUN: -index-store-path %t/idx \
// RUN: -index-ignore-stdlib \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: -Rindexing-system-module -Rmodule-loading \
// RUN: %t/Client.swift -disable-deserialization-recovery \
// RUN: 2>&1 | %FileCheck -check-prefix=THIRD-SYSTEM-INDEX %s
// THIRD-SYSTEM-INDEX: loaded module 'SystemDepCommon'; source: '{{.*}}SystemDepCommon.swiftmodule{{.*}}.swiftinterface'
// THIRD-SYSTEM-INDEX-NOT: loaded module {{.*}}SystemDepCommon
// THIRD-SYSTEM-INDEX: indexing system module {{.*}}SystemDepCommon.swiftmodule{{.*}}.swiftinterface
// THIRD-SYSTEM-INDEX-NOT: loaded module {{.*}}SystemDepCommon
// THIRD-SYSTEM-INDEX-NOT: indexing system module {{.*}}SystemDepCommon
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s
// RUN: c-index-test core -print-record %t/idx | %FileCheck -check-prefix=RECORD %s
/// Index a client reading from a broken swiftinterface
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
// RUN: echo "breaking_the_swiftinterface" >> %t/SDK/Frameworks/SystemModule.framework/Modules/SystemModule.swiftmodule/%module-target-triple.swiftinterface
// RUN: %target-swift-frontend -typecheck -parse-stdlib \
// RUN: -index-system-modules \
// RUN: -index-store-path %t/idx \
// RUN: -index-ignore-stdlib \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: -Rindexing-system-module \
// RUN: %t/Client.swift \
// RUN: 2>&1 | %FileCheck -check-prefix=BROKEN-BUILD %s
/// We don't expect to see the swiftinterface error for indexing
// BROKEN-BUILD-NOT: error
// BROKEN-BUILD-NOT: breaking_the_swiftinterface
// BROKEN-BUILD: indexing system module {{.*}} skipping
/// We don't expect SystemModule to be indexed with a broken swiftinterface
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=BROKEN-UNIT %s
// BROKEN-UNIT: Unit | system | SystemModule |
// BROKEN-UNIT-NOT: Record | system | SystemModule |
// RUN: c-index-test core -print-record %t/idx | %FileCheck -check-prefix=BROKEN-RECORD %s
// BROKEN-RECORD-NOT: function/Swift | systemFunc()
/// Subsequent builds won't attempt to index the broken swiftinterface again
// RUN: %target-swift-frontend -typecheck -parse-stdlib \
// RUN: -index-system-modules \
// RUN: -index-store-path %t/idx \
// RUN: -index-ignore-stdlib \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: -Rindexing-system-module \
// RUN: %t/Client.swift \
// RUN: 2>&1 | %FileCheck -check-prefix=BROKEN-BUILD-2 --allow-empty %s
// BROKEN-BUILD-2-NOT: indexing system module
/// Local errors should be preserved even when indexing against a broken swiftinterface
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
// RUN: not %target-swift-frontend -typecheck -parse-stdlib \
// RUN: -index-system-modules \
// RUN: -index-store-path %t/idx \
// RUN: -index-ignore-stdlib \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: %t/ClientWithError.swift 2> %t/client-with-error.err
// RUN: cat %t/client-with-error.err | %FileCheck -check-prefix=WITH-ERROR %s
// WITH-ERROR: cannot convert return expression of type 'U' to return type 'T'
//--- SecretModule.swift
public struct SecretType {}
//--- SystemModule.swift
// Use this dependency to hit an easy deserialization failure when recovery is disabled.
@_implementationOnly import SecretModule
// Both these import SystemDepCommon - we want to check that it is only indexed
// once.
import SystemDepA
import SystemDepB
public func systemFunc() {}
func leakyFunc(_ a: SecretType) {}
// Currently requires salvaging, which we need to make sure runs when the
// interface is rebuilt (as it produces a solution), we'll crash if it isn't.
public struct SysA { public init() {} }
public struct SysB { public init() {} }
@available(macOS, unavailable)
public func forceDisjunction() -> SysA { return SysA() }
public func forceDisjunction() -> SysB { return SysB() }
@available(macOS, unavailable)
@inlinable
public func requireSalvage() -> SysA {
return forceDisjunction()
}
//--- SystemDepA.swift
import SystemDepCommon
public func systemDepAFunc() {}
//--- SystemDepB.swift
import SystemDepCommon
public func systemDepBFunc() {}
//--- SystemDepCommon.swift
public func systemDepCommonFunc() {}
//--- Client.swift
import SystemModule
public func clientFunc() {}
//--- ClientWithError.swift
import SystemModule
public func clientFunc() {}
struct T {}
struct U {}
func f() -> T { return U() }
|