|
| 1 | +/// Test the logic printing the export_as name in public swiftinterfaces |
| 2 | +/// and the real source module name in the private swiftinterfaces. |
| 3 | + |
| 4 | +// RUN: %empty-directory(%t) |
| 5 | +// RUN: split-file %s %t |
| 6 | + |
| 7 | +/// Build lib with an export_as. |
| 8 | +// RUN: %target-swift-frontend -emit-module %t/Exported.swift \ |
| 9 | +// RUN: -module-name Exported -swift-version 5 -I %t \ |
| 10 | +// RUN: -enable-library-evolution \ |
| 11 | +// RUN: -emit-module-path %t/Exported.swiftmodule \ |
| 12 | +// RUN: -emit-module-interface-path %t/Exported.swiftinterface \ |
| 13 | +// RUN: -emit-private-module-interface-path %t/Exported.private.swiftinterface \ |
| 14 | +// RUN: -enable-experimental-feature ModuleInterfaceExportAs |
| 15 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Exported.private.swiftinterface) -module-name Exported -I %t |
| 16 | +// RUN: cat %t/Exported.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s |
| 17 | +// RUN: cat %t/Exported.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s |
| 18 | + |
| 19 | +/// The public swiftinterface only builds under the name of Exporter. |
| 20 | +// RUN: sed -e "s/module-name Exported/module-name Exporter/" -ibk %t/Exported.swiftinterface |
| 21 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Exported.swiftinterface) -I %t -module-name Exporter |
| 22 | + |
| 23 | +/// Build lib with an @exported import of the exported one. |
| 24 | +/// Default/old behavior. |
| 25 | +// RUN: %target-swift-frontend -emit-module %t/Exporter.swift \ |
| 26 | +// RUN: -module-name Exporter -swift-version 5 -I %t \ |
| 27 | +// RUN: -enable-library-evolution \ |
| 28 | +// RUN: -emit-module-path %t/Exporter.swiftmodule \ |
| 29 | +// RUN: -emit-module-interface-path %t/Exporter.swiftinterface \ |
| 30 | +// RUN: -emit-private-module-interface-path %t/Exporter.private.swiftinterface |
| 31 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.swiftinterface) -I %t |
| 32 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.private.swiftinterface) -module-name Exporter -I %t |
| 33 | +// RUN: cat %t/Exporter.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s |
| 34 | +// RUN: cat %t/Exporter.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s |
| 35 | + |
| 36 | +/// Build lib with an @exported import of the exported one. |
| 37 | +/// New behavior via flag. |
| 38 | +// RUN: %target-swift-frontend -emit-module %t/Exporter.swift \ |
| 39 | +// RUN: -module-name Exporter -swift-version 5 -I %t \ |
| 40 | +// RUN: -enable-library-evolution \ |
| 41 | +// RUN: -emit-module-path %t/Exporter.swiftmodule \ |
| 42 | +// RUN: -emit-module-interface-path %t/Exporter.swiftinterface \ |
| 43 | +// RUN: -emit-private-module-interface-path %t/Exporter.private.swiftinterface \ |
| 44 | +// RUN: -enable-experimental-feature ModuleInterfaceExportAs |
| 45 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.swiftinterface) -I %t |
| 46 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.private.swiftinterface) -module-name Exporter -I %t |
| 47 | +// RUN: cat %t/Exporter.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s |
| 48 | +// RUN: cat %t/Exporter.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s |
| 49 | + |
| 50 | +/// Build lib with an @exported import of the exported one. |
| 51 | +/// New behavior via env var. |
| 52 | +// RUN: env SWIFT_DEBUG_USE_EXPORTED_MODULE_NAME_IN_PUBLIC_ONLY=1 \ |
| 53 | +// RUN: %target-swift-frontend -emit-module %t/Exporter.swift \ |
| 54 | +// RUN: -module-name Exporter -swift-version 5 -I %t \ |
| 55 | +// RUN: -enable-library-evolution \ |
| 56 | +// RUN: -emit-module-path %t/Exporter.swiftmodule \ |
| 57 | +// RUN: -emit-module-interface-path %t/Exporter.swiftinterface \ |
| 58 | +// RUN: -emit-private-module-interface-path %t/Exporter.private.swiftinterface |
| 59 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.swiftinterface) -I %t |
| 60 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.private.swiftinterface) -module-name Exporter -I %t |
| 61 | +// RUN: cat %t/Exporter.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s |
| 62 | +// RUN: cat %t/Exporter.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s |
| 63 | + |
| 64 | +/// Build a client of the exporter lib. |
| 65 | +// RUN: %target-swift-frontend -emit-module %t/Client.swift \ |
| 66 | +// RUN: -module-name Client -swift-version 5 -I %t \ |
| 67 | +// RUN: -enable-library-evolution \ |
| 68 | +// RUN: -emit-module-path %t/Client.swiftmodule \ |
| 69 | +// RUN: -emit-module-interface-path %t/Client.swiftinterface \ |
| 70 | +// RUN: -emit-private-module-interface-path %t/Client.private.swiftinterface \ |
| 71 | +// RUN: -enable-experimental-feature ModuleInterfaceExportAs |
| 72 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Client.swiftinterface) -I %t |
| 73 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Client.private.swiftinterface) -module-name Client -I %t |
| 74 | +// RUN: cat %t/Client.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s |
| 75 | +// RUN: cat %t/Client.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s |
| 76 | + |
| 77 | +/// Build a client of the exporter lib. |
| 78 | +// RUN: rm %t/Exporter.private.swiftinterface %t/Exporter.swiftmodule |
| 79 | +// RUN: %target-swift-frontend -emit-module %t/Client.swift \ |
| 80 | +// RUN: -module-name Client -swift-version 5 -I %t \ |
| 81 | +// RUN: -enable-library-evolution \ |
| 82 | +// RUN: -emit-module-path %t/Client.swiftmodule \ |
| 83 | +// RUN: -emit-module-interface-path %t/Client.swiftinterface \ |
| 84 | +// RUN: -emit-private-module-interface-path %t/Client.private.swiftinterface \ |
| 85 | +// RUN: -enable-experimental-feature ModuleInterfaceExportAs |
| 86 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Client.swiftinterface) -I %t |
| 87 | +// RUN: %target-swift-typecheck-module-from-interface(%t/Client.private.swiftinterface) -module-name Client -I %t |
| 88 | +// RUN: cat %t/Client.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s |
| 89 | +// RUN: cat %t/Client.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s |
| 90 | + |
| 91 | +//--- module.modulemap |
| 92 | +module Exported { |
| 93 | + export_as Exporter |
| 94 | + header "Exported.h" |
| 95 | +} |
| 96 | + |
| 97 | +//--- Exported.h |
| 98 | +struct exportedClangType {}; |
| 99 | + |
| 100 | +//--- Exported.swift |
| 101 | +@_exported import Exported |
| 102 | + |
| 103 | +public func foo(a: exportedClangType) {} |
| 104 | +// CHECK-USE-EXPORTED: Exported.exportedClangType |
| 105 | +// CHECK-USE-EXPORTER: Exporter.exportedClangType |
| 106 | + |
| 107 | +//--- Exporter.swift |
| 108 | +@_exported import Exported |
| 109 | + |
| 110 | +public func foo(a: exportedClangType) {} |
| 111 | + |
| 112 | +//--- Client.swift |
| 113 | +import Exporter |
| 114 | + |
| 115 | +public func foo(a: exportedClangType) {} |
0 commit comments