|
| 1 | +// Binary swiftmodules are restricted to a channel when set in the compiler. |
| 2 | + |
| 3 | +// RUN: %empty-directory(%t/cache) |
| 4 | +// RUN: %empty-directory(%t/build) |
| 5 | +// RUN: split-file %s %t --leading-lines |
| 6 | + |
| 7 | +//--- Lib.swift |
| 8 | +public func foo() {} |
| 9 | + |
| 10 | +/// Build Lib as a resilient and non-resilient swiftmodule |
| 11 | +// RUN: %target-swift-frontend -emit-module %t/Lib.swift -swift-version 5 \ |
| 12 | +// RUN: -o %t/build -parse-stdlib -module-cache-path %t/cache \ |
| 13 | +// RUN: -module-name ResilientLib -enable-library-evolution \ |
| 14 | +// RUN: -emit-module-interface-path %t/build/ResilientLib.swiftinterface |
| 15 | +// RUN: %target-swift-frontend -emit-module %t/Lib.swift -swift-version 5 \ |
| 16 | +// RUN: -o %t/build -parse-stdlib -module-cache-path %t/cache \ |
| 17 | +// RUN: -module-name NonResilientLib |
| 18 | + |
| 19 | +/// Build a channel restricted Lib. |
| 20 | +// RUN: env SWIFT_FORCE_SWIFTMODULE_CHANNEL=restricted-channel \ |
| 21 | +// RUN: %target-swift-frontend -emit-module %t/Lib.swift -swift-version 5 \ |
| 22 | +// RUN: -o %t/build -parse-stdlib -module-cache-path %t/cache \ |
| 23 | +// RUN: -module-name ChannelLib -enable-library-evolution |
| 24 | + |
| 25 | + |
| 26 | +/// 2. Test importing the non-resilient no-channel library from a channel compiler. |
| 27 | +//--- NonResilientClient.swift |
| 28 | +import NonResilientLib // expected-error {{compiled module was created for a different distribution channel '' than the local compiler 'restricted-channel', please ensure 'NonResilientLib' is found from the expected path:}} |
| 29 | +foo() |
| 30 | + |
| 31 | +/// Building a NonResilientLib client should reject the import for a tagged compiler |
| 32 | +// RUN: env SWIFT_FORCE_SWIFTMODULE_CHANNEL=restricted-channel \ |
| 33 | +// RUN: %target-swift-frontend -typecheck %t/NonResilientClient.swift \ |
| 34 | +// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache \ |
| 35 | +// RUN: -verify -verify-ignore-unknown |
| 36 | + |
| 37 | + |
| 38 | +/// 3. Test importing the resilient no-channel library. |
| 39 | +//--- ResilientClient.swift |
| 40 | +import ResilientLib // expected-reject-error {{compiled module was created for a different distribution channel '' than the local compiler 'restricted-channel', please ensure 'ResilientLib' is found from the expected path:}} |
| 41 | + // expected-rebuild-remark @-1 {{rebuilding module 'ResilientLib' from interface}} |
| 42 | + // expected-rebuild-note @-2 {{compiled module is out of date}} |
| 43 | + // expected-rebuild-note @-3 {{compiled for a different distribution channel}} |
| 44 | +foo() |
| 45 | + |
| 46 | +/// ResilientLib client should rebuild from swiftinterface when available. |
| 47 | +// RUN: env SWIFT_FORCE_SWIFTMODULE_CHANNEL=restricted-channel \ |
| 48 | +// RUN: %target-swift-frontend -typecheck %t/ResilientClient.swift \ |
| 49 | +// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache \ |
| 50 | +// RUN: -verify -verify-additional-prefix rebuild- -Rmodule-interface-rebuild |
| 51 | + |
| 52 | +/// Importing for a different channel should rebuild without cache collision. |
| 53 | +// RUN: env SWIFT_FORCE_SWIFTMODULE_CHANNEL=other-channel \ |
| 54 | +// RUN: %target-swift-frontend -typecheck %t/ResilientClient.swift \ |
| 55 | +// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache \ |
| 56 | +// RUN: -verify -verify-additional-prefix rebuild- -Rmodule-interface-rebuild |
| 57 | +// RUN: env SWIFT_FORCE_SWIFTMODULE_CHANNEL=restricted-channel \ |
| 58 | +// RUN: %target-swift-frontend -typecheck %t/ResilientClient.swift \ |
| 59 | +// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache \ |
| 60 | +// RUN: -verify -Rmodule-interface-rebuild |
| 61 | + |
| 62 | +// RUN: rm %t/build/ResilientLib.swiftinterface |
| 63 | +// RUN: %empty-directory(%t/cache) |
| 64 | + |
| 65 | +/// Building a ResilientLib client should succeed in no-channel / dev mode. |
| 66 | +// RUN: %target-swift-frontend -typecheck %t/ResilientClient.swift \ |
| 67 | +// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache |
| 68 | + |
| 69 | +/// Building a ResilientLib client should reject the import for a channel compiler. |
| 70 | +// RUN: env SWIFT_FORCE_SWIFTMODULE_CHANNEL=restricted-channel \ |
| 71 | +// RUN: %target-swift-frontend -typecheck %t/ResilientClient.swift \ |
| 72 | +// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache \ |
| 73 | +// RUN: -verify -verify-ignore-unknown -verify-additional-prefix reject- |
| 74 | + |
| 75 | +/// Building a ResilientLib client should succeed for a channel compiler with SWIFT_IGNORE_SWIFTMODULE_REVISION |
| 76 | +// RUN: env SWIFT_FORCE_SWIFTMODULE_CHANNEL=restricted-channel SWIFT_IGNORE_SWIFTMODULE_REVISION=true \ |
| 77 | +// RUN: %target-swift-frontend -typecheck %t/ResilientClient.swift \ |
| 78 | +// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache |
| 79 | + |
| 80 | + |
| 81 | +/// 4. Test importing the channel restricted library |
| 82 | +//--- ChannelClient.swift |
| 83 | +import ChannelLib // expected-reject-error {{compiled module was created for a different distribution channel 'restricted-channel' than the local compiler 'other-channel', please ensure 'ChannelLib' is found from the expected path}} |
| 84 | +foo() |
| 85 | + |
| 86 | +/// Importing ChannelLib should succeed with the same channel. |
| 87 | +// RUN: env SWIFT_FORCE_SWIFTMODULE_CHANNEL=restricted-channel \ |
| 88 | +// RUN: %target-swift-frontend -typecheck %t/ChannelClient.swift \ |
| 89 | +// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache |
| 90 | + |
| 91 | +/// Importing ChannelLib should succeed with a dev compiler. |
| 92 | +// RUN: %target-swift-frontend -typecheck %t/ChannelClient.swift \ |
| 93 | +// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache |
| 94 | + |
| 95 | +/// Importing ChannelLib from a different channel should be rejected. |
| 96 | +// RUN: env SWIFT_FORCE_SWIFTMODULE_CHANNEL=other-channel \ |
| 97 | +// RUN: %target-swift-frontend -typecheck %t/ChannelClient.swift \ |
| 98 | +// RUN: -swift-version 5 -I %t/build -parse-stdlib -module-cache-path %t/cache \ |
| 99 | +// RUN: -verify -verify-ignore-unknown -verify-additional-prefix reject- |
0 commit comments