|
| 1 | +/// Test the -module-alias flag with an escaped identifier and the explicit module loader. |
| 2 | +// UNSUPPORTED: OS=windows-msvc |
| 3 | +// RUN: %empty-directory(%t) |
| 4 | +// RUN: mkdir -p %t/inputs |
| 5 | +// RUN: mkdir -p %t/outputs |
| 6 | + |
| 7 | +/// Create a module Bar |
| 8 | +// RUN: echo 'public func bar() {}' > %t/inputs/FileBar.swift |
| 9 | +// RUN: %target-swift-frontend -module-name Bar %t/inputs/FileBar.swift -emit-module -emit-module-path %t/inputs/Bar.swiftmodule |
| 10 | +// RUN: %target-swift-emit-pcm -module-name SwiftShims %swift-lib-dir/swift/shims/module.modulemap -o %t/inputs/SwiftShims.pcm |
| 11 | +// RUN: %target-swift-emit-pcm -module-name _SwiftConcurrencyShims %swift-lib-dir/swift/shims/module.modulemap -o %t/inputs/_SwiftConcurrencyShims.pcm |
| 12 | + |
| 13 | +/// Check Bar.swiftmodule is created |
| 14 | +// RUN: test -f %t/inputs/Bar.swiftmodule |
| 15 | + |
| 16 | +/// Next create an explicit module dependency map to build module Foo |
| 17 | +// RUN: echo 'import `//my/project:cat`' > %t/inputs/FileFoo.swift |
| 18 | + |
| 19 | +// RUN: echo "[{" > %/t/inputs/map.json |
| 20 | +// RUN: echo "\"moduleName\": \"Bar\"," >> %/t/inputs/map.json |
| 21 | +// RUN: echo "\"modulePath\": \"%/t/inputs/Bar.swiftmodule\"," >> %/t/inputs/map.json |
| 22 | +// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json |
| 23 | +// RUN: echo "}," >> %/t/inputs/map.json |
| 24 | +// RUN: echo "{" >> %/t/inputs/map.json |
| 25 | +// RUN: echo "\"moduleName\": \"Swift\"," >> %/t/inputs/map.json |
| 26 | +// RUN: echo "\"modulePath\": \"%/stdlib_module\"," >> %/t/inputs/map.json |
| 27 | +// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json |
| 28 | +// RUN: echo "}," >> %/t/inputs/map.json |
| 29 | +// RUN: echo "{" >> %/t/inputs/map.json |
| 30 | +// RUN: echo "\"moduleName\": \"SwiftOnoneSupport\"," >> %/t/inputs/map.json |
| 31 | +// RUN: echo "\"modulePath\": \"%/ononesupport_module\"," >> %/t/inputs/map.json |
| 32 | +// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json |
| 33 | +// RUN: echo "}," >> %/t/inputs/map.json |
| 34 | +// RUN: echo "{" >> %/t/inputs/map.json |
| 35 | +// RUN: echo "\"moduleName\": \"_Concurrency\"," >> %/t/inputs/map.json |
| 36 | +// RUN: echo "\"modulePath\": \"%/concurrency_module\"," >> %/t/inputs/map.json |
| 37 | +// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json |
| 38 | +// RUN: echo "}," >> %/t/inputs/map.json |
| 39 | +// RUN: echo "{" >> %/t/inputs/map.json |
| 40 | +// RUN: echo "\"moduleName\": \"SwiftShims\"," >> %/t/inputs/map.json |
| 41 | +// RUN: echo "\"isFramework\": false," >> %/t/inputs/map.json |
| 42 | +// RUN: echo "\"clangModuleMapPath\": \"%swift-lib-dir/swift/shims/module.modulemap\"," >> %/t/inputs/map.json |
| 43 | +// RUN: echo "\"clangModulePath\": \"%t/inputs/SwiftShims.pcm\"" >> %/t/inputs/map.json |
| 44 | +// RUN: echo "}," >> %/t/inputs/map.json |
| 45 | +// RUN: echo "{" >> %/t/inputs/map.json |
| 46 | +// RUN: echo "\"moduleName\": \"_SwiftConcurrencyShims\"," >> %/t/inputs/map.json |
| 47 | +// RUN: echo "\"isFramework\": false," >> %/t/inputs/map.json |
| 48 | +// RUN: echo "\"clangModuleMapPath\": \"%swift-lib-dir/swift/shims/module.modulemap\"," >> %/t/inputs/map.json |
| 49 | +// RUN: echo "\"clangModulePath\": \"%t/inputs/_SwiftConcurrencyShims.pcm\"" >> %/t/inputs/map.json |
| 50 | +// RUN: echo "}," >> %/t/inputs/map.json |
| 51 | +// RUN: echo "{" >> %/t/inputs/map.json |
| 52 | +// RUN: echo "\"moduleName\": \"_StringProcessing\"," >> %/t/inputs/map.json |
| 53 | +// RUN: echo "\"modulePath\": \"%/string_processing_module\"," >> %/t/inputs/map.json |
| 54 | +// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json |
| 55 | +// RUN: echo "}]" >> %/t/inputs/map.json |
| 56 | + |
| 57 | +/// Create a module Foo that imports `//my/project:cat` with -module-alias "//my/project:cat=Bar" with an explicit module loader |
| 58 | +// RUN: %target-swift-frontend -module-name Foo %t/inputs/FileFoo.swift -module-alias "//my/project:cat=Bar" -I %t/inputs -emit-module -emit-module-path %t/outputs/Foo.swiftmodule -disable-implicit-swift-modules -explicit-swift-module-map-file %t/inputs/map.json -Rmodule-loading 2> %t/outputs/load-result.output |
| 59 | + |
| 60 | +// RUN: test -f %t/outputs/Foo.swiftmodule |
| 61 | +// RUN: test -f %t/inputs/Bar.swiftmodule |
| 62 | +// RUN: not test -f %t/inputs/*cat.swiftmodule |
| 63 | + |
| 64 | +// RUN: %FileCheck %s -input-file %t/outputs/load-result.output -check-prefix CHECK |
| 65 | +// CHECK: remark: loaded module {{.*}}Bar.swiftmodule |
0 commit comments