|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: mkdir -p %t/clang-module-cache |
| 3 | +// RUN: mkdir -p %t/inputs |
| 4 | +// RUN: mkdir -p %t/barinputs |
| 5 | +// RUN: echo "public func foo() {}" >> %t/foo.swift |
| 6 | +// RUN: %target-swift-frontend -emit-module -emit-module-path %t/inputs/Foo.swiftmodule -emit-module-doc-path %t/inputs/Foo.swiftdoc -emit-module-source-info -emit-module-source-info-path %t/inputs/Foo.swiftsourceinfo -module-cache-path %t.module-cache %t/foo.swift -module-name Foo -user-module-version 9001 |
| 7 | +// RUN: echo "public func bar() {}" >> %t/bar.swift |
| 8 | +// RUN: %target-swift-frontend -emit-module -emit-module-path %t/barinputs/Bar.swiftmodule -emit-module-doc-path %t/barinputs/Bar.swiftdoc -emit-module-source-info -emit-module-source-info-path %t/barinputs/Bar.swiftsourceinfo -module-cache-path %t.module-cache %t/bar.swift -module-name Bar |
| 9 | + |
| 10 | +// RUN: echo "---" >> %t/inputs/ForwardingFoo.swiftmodule |
| 11 | +// RUN: echo "path: '%/t/inputs/Foo.swiftmodule'" >> %t/inputs/ForwardingFoo.swiftmodule |
| 12 | +// RUN: echo "dependencies: []" >> %t/inputs/ForwardingFoo.swiftmodule |
| 13 | +// RUN: echo "version: 1 " >> %t/inputs/ForwardingFoo.swiftmodule |
| 14 | +// RUN: echo "..." >> %t/inputs/ForwardingFoo.swiftmodule |
| 15 | + |
| 16 | +// RUN: echo "[{" > %/t/inputs/map.json |
| 17 | +// RUN: echo "\"moduleName\": \"Foo\"," >> %/t/inputs/map.json |
| 18 | +// RUN: echo "\"modulePath\": \"%/t/inputs/ForwardingFoo.swiftmodule\"," >> %/t/inputs/map.json |
| 19 | +// RUN: echo "\"docPath\": \"%/t/inputs/Foo.swiftdoc\"," >> %/t/inputs/map.json |
| 20 | +// RUN: echo "\"sourceInfoPath\": \"%/t/inputs/Foo.swiftsourceinfo\"," >> %/t/inputs/map.json |
| 21 | +// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json |
| 22 | +// RUN: echo "}]" >> %/t/inputs/map.json |
| 23 | + |
| 24 | +// RUN: not %target-swift-frontend -typecheck %s -explicit-swift-module-map-file %t/inputs/map.json -disable-implicit-swift-modules |
| 25 | +// RUN: %target-swift-frontend -typecheck %s -explicit-swift-module-map-file %t/inputs/map.json -I %t/barinputs -Rmodule-loading 2>&1 | %FileCheck -check-prefix=POSITIVE-CHECK %s |
| 26 | + |
| 27 | +#if canImport(Foo, _version: 9000) |
| 28 | +import Bar |
| 29 | +#endif |
| 30 | + |
| 31 | +// 'Bar' can only be imported if the explicitly-loaded 'Foo' is known to be over 9000 |
| 32 | +// POSITIVE-CHECK: remark: loaded module 'Bar' |
| 33 | + |
| 34 | +// Re-build Foo with a lower version and ensure we do not import `Bar` |
| 35 | +// RUN: %target-swift-frontend -emit-module -emit-module-path %t/inputs/Foo.swiftmodule -emit-module-doc-path %t/inputs/Foo.swiftdoc -emit-module-source-info -emit-module-source-info-path %t/inputs/Foo.swiftsourceinfo -module-cache-path %t.module-cache %t/foo.swift -module-name Foo -user-module-version 7000 |
| 36 | +// RUN: %target-swift-frontend -typecheck %s -explicit-swift-module-map-file %t/inputs/map.json -I %t/barinputs -Rmodule-loading 2>&1 | %FileCheck -check-prefix=NEGATIVE-CHECK %s |
| 37 | + |
| 38 | +// 'Bar' can only be imported if the explicitly-loaded 'Foo' is known to be over 9000 |
| 39 | +// NEGATIVE-CHECK-NOT: remark: loaded module 'Bar' |
0 commit comments