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
|
import SomeModule
print(someFunc())
// UNIT: Record | system | SomeModule |
// SKIP-NOT: Record | system | SomeModule |
// RUN: %empty-directory(%t)
//
// RUN: echo 'public func someFunc() -> Int { return 42; }' >%t/some-module.swift
// RUN: echo 'public struct XWrapper {' >>%t/some-module.swift
// RUN: echo ' public let x: Int' >>%t/some-module.swift
// RUN: echo ' public init(x: Int) {' >>%t/some-module.swift
// RUN: echo ' self.x = x' >>%t/some-module.swift
// RUN: echo ' }' >>%t/some-module.swift
// RUN: echo '}' >>%t/some-module.swift
//
// -----------------------------------------------------------------------------
// --- Prepare SDK (.swiftmodule).
// RUN: %empty-directory(%t/SDK)
// RUN: mkdir -p %t/SDK/Frameworks/SomeModule.framework/Modules/SomeModule.swiftmodule
// RUN: %target-swift-frontend \
// RUN: -emit-module \
// RUN: -module-name SomeModule \
// RUN: -o %t/SDK/Frameworks/SomeModule.framework/Modules/SomeModule.swiftmodule/%module-target-triple.swiftmodule \
// RUN: -swift-version 5 \
// RUN: %t/some-module.swift
// -----------------------------------------------------------------------------
// Test-1 - '.swiftmodule' - Normal index-while-building.
//
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
//
// --- Built with indexing
// RUN: %target-swift-frontend \
// RUN: -typecheck \
// RUN: -index-system-modules \
// RUN: -index-ignore-stdlib \
// RUN: -index-store-path %t/idx \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: %s
//
// --- Check the index.
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s
//
// --- Built with indexing, SomeModule is outside of the SDK so it's skipped.
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
// RUN: %target-swift-frontend \
// RUN: -typecheck \
// RUN: -index-system-modules \
// RUN: -index-ignore-stdlib \
// RUN: -index-store-path %t/idx \
// RUN: -sdk %t/NotTheActualSDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: %s
//
// --- Check the index.
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=SKIP %s
// --- Built with indexing, without an SDK path SomeModule is indexed.
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
// RUN: %target-swift-frontend \
// RUN: -typecheck \
// RUN: -index-system-modules \
// RUN: -index-ignore-stdlib \
// RUN: -index-store-path %t/idx \
// RUN: -sdk "" \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: %s
//
// --- Check the index.
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s
// -----------------------------------------------------------------------------
// --- Prepare SDK (.swiftinterface).
// RUN: %empty-directory(%t/SDK)
// RUN: mkdir -p %t/SDK/Frameworks/SomeModule.framework/Modules/SomeModule.swiftmodule
// RUN: %target-swift-frontend \
// RUN: -emit-module \
// RUN: -module-name SomeModule \
// RUN: -emit-module-interface-path %t/SDK/Frameworks/SomeModule.framework/Modules/SomeModule.swiftmodule/%module-target-triple.swiftinterface \
// RUN: -o /dev/null \
// RUN: -swift-version 5 \
// RUN: -enable-library-evolution \
// RUN: %t/some-module.swift
// -----------------------------------------------------------------------------
// Test-2 - '.swiftinterface' - Normal index-while-building.
//
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
//
// --- Built with indexing
// RUN: %target-swift-frontend \
// RUN: -typecheck \
// RUN: -index-system-modules \
// RUN: -index-ignore-stdlib \
// RUN: -index-store-path %t/idx \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: %s
//
// --- Check the index.
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s
// -----------------------------------------------------------------------------
// Test-3 - '.swiftinterface' - Build once to populate modulecache, then index-while-building.
//
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
//
// --- Build without indexing
// RUN: %target-swift-frontend \
// RUN: -typecheck \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: %s
//
// --- Ensure module cache is populated.
// RUN: ls %t/modulecache/SomeModule-*.swiftmodule
//
// --- Built with indexing
// RUN: %target-swift-frontend \
// RUN: -typecheck \
// RUN: -index-system-modules \
// RUN: -index-ignore-stdlib \
// RUN: -index-store-path %t/idx \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: %s
//
// --- Check the index.
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s
// -----------------------------------------------------------------------------
// Test-4 - '.swiftinterface' - Prebuild module in prebuilt-module-cache-path
//
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
// RUN: %empty-directory(%t/prebuiltcache)
//
// --- Prebuild SDK module.
// RUN: mkdir -p %t/prebuiltcache/SomeModule.swiftmodule
// RUN: %target-swift-frontend \
// RUN: -compile-module-from-interface \
// RUN: -module-name SomeModule \
// RUN: -o %t/prebuiltcache/SomeModule.swiftmodule/%module-target-triple.swiftmodule \
// RUN: %t/SDK/Frameworks/SomeModule.framework/Modules/SomeModule.swiftmodule/%module-target-triple.swiftinterface
//
// --- Build main file with indexing.
// RUN: %target-swift-frontend \
// RUN: -typecheck \
// RUN: -index-system-modules \
// RUN: -index-ignore-stdlib \
// RUN: -index-store-path %t/idx \
// RUN: -sdk %t/SDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: -prebuilt-module-cache-path %t/prebuiltcache \
// RUN: %s
//
// --- Check the index.
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s
|