|
| 1 | +/// Test the -module-alias flag with an explicit module loader. |
| 2 | + |
| 3 | +// RUN: %empty-directory(%t) |
| 4 | + |
| 5 | +/// Create a module Bar |
| 6 | +// RUN: echo 'public func bar() {}' > %t/FileBar.swift |
| 7 | +// RUN: %target-swift-frontend -module-name Bar %t/FileBar.swift -emit-module -emit-module-path %t/Bar.swiftmodule |
| 8 | + |
| 9 | +/// Check Bar.swiftmodule is created |
| 10 | +// RUN: test -f %t/Bar.swiftmodule |
| 11 | + |
| 12 | +/// Next create an explicit module dependency map to build module Foo |
| 13 | +// RUN: mkdir -p %t/inputs |
| 14 | +// RUN: echo 'import Cat' > %t/FileFoo.swift |
| 15 | + |
| 16 | +// RUN: echo "[{" > %/t/inputs/map.json |
| 17 | +// RUN: echo "\"moduleName\": \"Foo\"," >> %/t/inputs/map.json |
| 18 | +// RUN: echo "\"modulePath\": \"%/t/inputs/Foo.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 | +// RUN: echo "{" >> %/t/inputs/map.json |
| 24 | +// RUN: echo "\"moduleName\": \"SwiftOnoneSupport\"," >> %/t/inputs/map.json |
| 25 | +// RUN: echo "\"modulePath\": \"%/ononesupport_module\"," >> %/t/inputs/map.json |
| 26 | +// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json |
| 27 | +// RUN: echo "}," >> %/t/inputs/map.json |
| 28 | +// RUN: echo "{" >> %/t/inputs/map.json |
| 29 | +// RUN: echo "\"moduleName\": \"_Concurrency\"," >> %/t/inputs/map.json |
| 30 | +// RUN: echo "\"modulePath\": \"%/concurrency_module\"," >> %/t/inputs/map.json |
| 31 | +// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json |
| 32 | +// RUN: echo "}," >> %/t/inputs/map.json |
| 33 | +// RUN: echo "{" >> %/t/inputs/map.json |
| 34 | +// RUN: echo "\"moduleName\": \"Swift\"," >> %/t/inputs/map.json |
| 35 | +// RUN: echo "\"modulePath\": \"%/stdlib_module\"," >> %/t/inputs/map.json |
| 36 | +// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json |
| 37 | +// RUN: echo "}," >> %/t/inputs/map.json |
| 38 | +// RUN: echo "{" >> %/t/inputs/map.json |
| 39 | +// RUN: echo "\"moduleName\": \"_Distributed\"," >> %/t/inputs/map.json |
| 40 | +// RUN: echo "\"modulePath\": \"%/distributed_module\"," >> %/t/inputs/map.json |
| 41 | +// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json |
| 42 | +// RUN: echo "}]" >> %/t/inputs/map.json |
| 43 | + |
| 44 | +/// Create a module Foo that imports Cat with -module-alias Cat=Bar with an explicit module loader |
| 45 | +// RUN: %target-swift-frontend -module-name Foo %t/FileFoo.swift -module-alias Cat=Bar -I %t -emit-module -emit-module-path %t/Foo.swiftmodule -disable-implicit-swift-modules -explicit-swift-module-map-file %t/inputs/map.json -Rmodule-loading 2> %t/load-result.output |
| 46 | + |
| 47 | +// RUN: test -f %t/Foo.swiftmodule |
| 48 | +// RUN: test -f %t/Bar.swiftmodule |
| 49 | +// RUN: not test -f %t/Cat.swiftmodule |
| 50 | + |
| 51 | +// RUN: %FileCheck %s -input-file %t/load-result.output -check-prefix CHECK |
| 52 | +// CHECK: remark: loaded module at {{.*}}Bar.swiftmodule |
| 53 | + |
0 commit comments