|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: cp -r %S/Inputs/imported_modules/ComplexModuleGraph2 %t/include |
| 3 | + |
| 4 | +// REQUIRES: objc_interop |
| 5 | + |
| 6 | +// Dependency graph: |
| 7 | +// |
| 8 | +// * CoreFilesystem - Swift module with generated ObjC header |
| 9 | +// * FilesystemKit - ObjC module without overlay, has #import <CoreFileystem-Generated.h> |
| 10 | +// * TestFilesystem - Swift module, has import CoreFilesystem or FilesystemKit. |
| 11 | +// |
| 12 | +// * CoreDaemon - ObjC module with overlay, the overlay has import DaemonKit |
| 13 | +// * DaemonKit - ObjC module without overlay, has #import <CoreDaemon.h> |
| 14 | +// * TestDaemon - Swift module, has import CoreDaemon or DaemonKit. |
| 15 | +// NOTE: This mimics the Darwin -> SwiftOverlayShims -> Darwin dependency "cycle". |
| 16 | +// |
| 17 | +// * CoreMemory - ObjC module with overlay and generated header for overlay, the overlay has import MemoryKit |
| 18 | +// * MemoryKit - ObjC module without overlay, has #import <CoreMemory-Generated.h> |
| 19 | +// * TestMemory - Swift module, has import CoreMemory or MemoryKit. |
| 20 | + |
| 21 | +// 1. CoreFilesystem - Build. |
| 22 | + |
| 23 | +// RUN: %target-swift-frontend %s -emit-module -o %t/include/CoreFilesystem.swiftmodule -DCoreFilesystem -module-name CoreFilesystem -emit-objc-header-path %t/include/CoreFilesystem-Generated.h -disable-objc-attr-requires-foundation-module |
| 24 | + |
| 25 | +#if CoreFilesystem |
| 26 | +@objc |
| 27 | +public class MyNode { |
| 28 | + public var number: Int |
| 29 | + public init(_ n: Int) { number = n } |
| 30 | +} |
| 31 | +#endif |
| 32 | + |
| 33 | +// 2. FilesystemKit - Nothing to do (pure Clang module). |
| 34 | + |
| 35 | +// 3. TestFilesystem - Check that CoreFilesystem and Filesytem can be imported. |
| 36 | + |
| 37 | +// RUN: %target-swift-frontend %s -typecheck -DTestFilesystem -DV1 -module-name TestFilesystemV1 -emit-loaded-module-trace-path %t/TestFilesystemV1.trace.json -I %t/include |
| 38 | +// RUN: %FileCheck %s --check-prefix=TESTFILESYSTEM < %t/TestFilesystemV1.trace.json |
| 39 | +// RUN: %target-swift-frontend %s -typecheck -DTestFilesystem -DV2 -module-name TestFilesystemV2 -emit-loaded-module-trace-path %t/TestFilesystemV2.trace.json -I %t/include |
| 40 | +// RUN: %FileCheck %s --check-prefix=TESTFILESYSTEM < %t/TestFilesystemV2.trace.json |
| 41 | +// RUN: %target-swift-frontend %s -typecheck -DTestFilesystem -DV3 -module-name TestFilesystemV3 -emit-loaded-module-trace-path %t/TestFilesystemV3.trace.json -I %t/include |
| 42 | +// RUN: %FileCheck %s --check-prefix=TESTFILESYSTEM < %t/TestFilesystemV3.trace.json |
| 43 | +// RUN: %target-swift-frontend %s -typecheck -DTestFilesystem -DV4 -module-name TestFilesystemV4 -emit-loaded-module-trace-path %t/TestFilesystemV4.trace.json -I %t/include |
| 44 | +// RUN: %FileCheck %s --check-prefix=TESTFILESYSTEM < %t/TestFilesystemV4.trace.json |
| 45 | + |
| 46 | +#if TestFilesystem |
| 47 | + #if V1 |
| 48 | + import CoreFilesystem |
| 49 | + #endif |
| 50 | + #if V2 |
| 51 | + import FilesystemKit |
| 52 | + public func noop(_: CoreFilesystem.MyNode) {} |
| 53 | + #endif |
| 54 | + #if V3 |
| 55 | + import CoreFilesystem |
| 56 | + import FilesystemKit |
| 57 | + #endif |
| 58 | + #if V4 |
| 59 | + import FilesystemKit |
| 60 | + import CoreFilesystem |
| 61 | + #endif |
| 62 | +#endif |
| 63 | + |
| 64 | +// FilesystemKit has no overlay, so it shouldn't show up. |
| 65 | +// TESTFILESYSTEM: "swiftmodulesDetailedInfo":[ |
| 66 | +// TESTFILESYSTEM-NOT: FilesystemKit |
| 67 | +// TESTFILESYSTEM-DAG: {"name":"CoreFilesystem","path":"{{[^"]*}}CoreFilesystem.swiftmodule","isImportedDirectly":true, |
| 68 | +// TESTFILESYSTEM: ] |
| 69 | + |
| 70 | +// 4. CoreDaemon - Build. |
| 71 | + |
| 72 | +// FIXME: Trace emission shouldn't crash. |
| 73 | +// RUN: %target-swift-frontend %s -emit-module -o %t/include/CoreDaemon.swiftmodule -DCoreDaemon -module-name CoreDaemon -I %t/include |
| 74 | +// RUN: not --crash %target-swift-frontend %s -typecheck -DCoreDaemon -module-name CoreDaemon -emit-loaded-module-trace-path %t/CoreDaemon.trace.json -I %t/include 2>/dev/null |
| 75 | +// SKIP: %FileCheck %s --check-prefix=COREDAEMON < %t/CoreDaemon.trace.json |
| 76 | + |
| 77 | +// * CoreDaemon - ObjC module with overlay, the overlay has import DaemonKit |
| 78 | +// * DaemonKit - ObjC module without overlay, has #import <CoreDaemon.h> |
| 79 | +// * TestDaemon - Swift module, has import CoreDaemon or DaemonKit. |
| 80 | + |
| 81 | +#if CoreDaemon |
| 82 | +@_exported import CoreDaemon |
| 83 | +import DaemonKit |
| 84 | + |
| 85 | +public func runBoth(_ pair: DaemonKit.DaemonPair) { |
| 86 | + let daemons : (CoreDaemon.Daemon, CoreDaemon.Daemon) = pair.daemons; |
| 87 | + daemons.0.run(0); |
| 88 | + daemons.1.run(1); |
| 89 | +} |
| 90 | +#endif |
| 91 | + |
| 92 | +// COREDAEMON: "swiftmodulesDetailedInfo":[ |
| 93 | +// COREDAEMON-NOT: CoreDaemon |
| 94 | +// COREDAEMON-NOT: DaemonKit |
| 95 | +// COREDAEMON: ] |
| 96 | + |
| 97 | +// 5. DaemonKit - Nothing to do (pure Clang module). |
| 98 | + |
| 99 | +// 6. TestCoreDaemon |
| 100 | + |
| 101 | +// RUN: %target-swift-frontend %s -typecheck -DTestDaemon -DV1 -module-name TestDaemonV1 -emit-loaded-module-trace-path %t/TestDaemonV1.trace.json -I %t/include |
| 102 | +// RUN: %FileCheck %s --check-prefix=TESTDAEMON < %t/TestDaemonV1.trace.json |
| 103 | + |
| 104 | +// FIXME: Trace emission shouldn't crash. |
| 105 | +// RUN: not --crash %target-swift-frontend %s -typecheck -DTestDaemon -DV2 -module-name TestDaemonV2 -emit-loaded-module-trace-path %t/TestDaemonV2.trace.json -I %t/include 2>/dev/null |
| 106 | +// SKIP: %FileCheck %s --check-prefix=TESTDAEMON < %t/TestDaemonV2.trace.json |
| 107 | + |
| 108 | +// RUN: %target-swift-frontend %s -typecheck -DTestDaemon -DV3 -module-name TestDaemonV3 -emit-loaded-module-trace-path %t/TestDaemonV3.trace.json -I %t/include |
| 109 | +// RUN: %FileCheck %s --check-prefix=TESTDAEMON < %t/TestDaemonV3.trace.json |
| 110 | + |
| 111 | +// FIXME: Trace emission shouldn't crash. |
| 112 | +// RUN: not --crash %target-swift-frontend %s -typecheck -DTestDaemon -DV4 -module-name TestDaemonV4 -emit-loaded-module-trace-path %t/TestDaemonV4.trace.json -I %t/include 2>/dev/null |
| 113 | +// SKIP: %FileCheck %s --check-prefix=TESTDAEMON < %t/TestDaemonV4.trace.json |
| 114 | + |
| 115 | +#if TestDaemon |
| 116 | + #if V1 |
| 117 | + import CoreDaemon |
| 118 | + #endif |
| 119 | + #if V2 |
| 120 | + import DaemonKit |
| 121 | + public func noop(_: CoreDaemon.Daemon) {} |
| 122 | + #endif |
| 123 | + #if V3 |
| 124 | + import CoreDaemon |
| 125 | + import DaemonKit |
| 126 | + #endif |
| 127 | + #if V4 |
| 128 | + import DaemonKit |
| 129 | + import CoreDaemon |
| 130 | + #endif |
| 131 | +#endif |
| 132 | + |
| 133 | +// DaemonKit has no overlay, so it shouldn't show up. |
| 134 | +// TESTDAEMON: "swiftmodulesDetailedInfo":[ |
| 135 | +// TESTDAEMON-NOT: DaemonKit |
| 136 | +// TESTDAEMON-DAG: {"name":"CoreDaemon","path":"{{[^"]*}}CoreDaemon.swiftmodule","isImportedDirectly":true, |
| 137 | +// TESTDAEMON: ] |
| 138 | + |
| 139 | +// 7. CoreMemory - Build. |
| 140 | + |
| 141 | +// RUN: %target-swift-frontend %s -emit-module -o %t/include/CoreMemory.swiftmodule -DCoreMemory -module-name CoreMemory -emit-objc-header-path %t/include/CoreMemory-Generated.h -disable-objc-attr-requires-foundation-module -I %t/include |
| 142 | + |
| 143 | +#if CoreMemory |
| 144 | +@_exported import CoreMemory |
| 145 | + |
| 146 | +@objc |
| 147 | +public class MemoryMapEntry { |
| 148 | + public var region: MemoryMapRegion |
| 149 | + public var permissions: Int = 0 |
| 150 | + public init(_ r: MemoryMapRegion) { region = r } |
| 151 | +} |
| 152 | +#endif |
| 153 | + |
| 154 | +// 8. MemoryKit - Nothing to do (pure Clang module). |
| 155 | + |
| 156 | +// 9. TestMemory - Check that CoreMemory and MemoryKit can be imported. |
| 157 | + |
| 158 | +// RUN: %target-swift-frontend %s -typecheck -DTestMemory -DV1 -module-name TestMemoryV1 -emit-loaded-module-trace-path %t/TestMemoryV1.trace.json -I %t/include |
| 159 | +// RUN: %FileCheck %s --check-prefix=TESTMEMORY < %t/TestMemoryV1.trace.json |
| 160 | +// RUN: %target-swift-frontend %s -typecheck -DTestMemory -DV2 -module-name TestMemoryV2 -emit-loaded-module-trace-path %t/TestMemoryV2.trace.json -I %t/include |
| 161 | +// RUN: %FileCheck %s --check-prefix=TESTMEMORY < %t/TestMemoryV2.trace.json |
| 162 | +// RUN: %target-swift-frontend %s -typecheck -DTestMemory -DV3 -module-name TestMemoryV3 -emit-loaded-module-trace-path %t/TestMemoryV3.trace.json -I %t/include |
| 163 | +// RUN: %FileCheck %s --check-prefix=TESTMEMORY < %t/TestMemoryV3.trace.json |
| 164 | +// RUN: %target-swift-frontend %s -typecheck -DTestMemory -DV4 -module-name TestMemoryV4 -emit-loaded-module-trace-path %t/TestMemoryV4.trace.json -I %t/include |
| 165 | +// RUN: %FileCheck %s --check-prefix=TESTMEMORY < %t/TestMemoryV4.trace.json |
| 166 | + |
| 167 | +#if TestMemory |
| 168 | + #if V1 |
| 169 | + import CoreMemory |
| 170 | + #endif |
| 171 | + #if V2 |
| 172 | + import MemoryKit |
| 173 | + public func noop(_: CoreMemory.MemoryMapRegion, _: CoreMemory.MemoryMapEntry) {} |
| 174 | + #endif |
| 175 | + #if V3 |
| 176 | + import CoreMemory |
| 177 | + import MemoryKit |
| 178 | + #endif |
| 179 | + #if V4 |
| 180 | + import MemoryKit |
| 181 | + import CoreMemory |
| 182 | + #endif |
| 183 | +#endif |
| 184 | + |
| 185 | +// MemoryKit has no overlay, so it shouldn't show up. |
| 186 | +// TESTMEMORY: "swiftmodulesDetailedInfo":[ |
| 187 | +// TESTMEMORY-NOT: MemoryKit |
| 188 | +// TESTMEMORY-DAG: {"name":"CoreMemory","path":"{{[^"]*}}CoreMemory.swiftmodule","isImportedDirectly":true, |
| 189 | +// TESTMEMORY: ] |
0 commit comments