Skip to content

Commit 1cb4eda

Browse files
committed
test: add an IDE test for loading modules from explict module map
1 parent ec9cd91 commit 1cb4eda

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir -p %t/clang-module-cache
3+
// RUN: mkdir -p %t/inputs
4+
// RUN: echo "/// Some cool comments" > %t/foo.swift
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
7+
8+
// RUN: echo "{" > %t/inputs/map.json
9+
// RUN: echo "\"Foo\": {" >> %t/inputs/map.json
10+
// RUN: echo "\"SwiftModulePath\": \"%t/inputs/Foo.swiftmodule\"," >> %t/inputs/map.json
11+
// RUN: echo "\"SwiftDocPath\": \"%t/inputs/Foo.swiftdoc\"," >> %t/inputs/map.json
12+
// RUN: echo "\"SwiftSourceInfoPath\": \"%t/inputs/Foo.swiftsourceinfo\"" >> %t/inputs/map.json
13+
// RUN: echo "}" >> %t/inputs/map.json
14+
// RUN: echo "}" >> %t/inputs/map.json
15+
16+
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=Foo -enable-swiftsourceinfo -source-filename %s -explicit-swift-module-map-file %t/inputs/map.json | %FileCheck %s
17+
18+
// CHECK: foo.swift:2:13: Func/foo RawComment=[/// Some cool comments

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,10 @@ EnableSwiftSourceInfo("enable-swiftsourceinfo",
723723
llvm::cl::cat(Category),
724724
llvm::cl::init(false));
725725

726+
static llvm::cl::opt<std::string>
727+
ExplicitSwiftModuleMap("explicit-swift-module-map-file",
728+
llvm::cl::desc("JSON file to include explicit Swift modules"),
729+
llvm::cl::cat(Category));
726730
} // namespace options
727731

728732
static std::unique_ptr<llvm::MemoryBuffer>
@@ -3462,6 +3466,11 @@ int main(int argc, char *argv[]) {
34623466
for (auto ConfigName : options::BuildConfigs)
34633467
InitInvok.getLangOptions().addCustomConditionalCompilationFlag(ConfigName);
34643468

3469+
if (!options::ExplicitSwiftModuleMap.empty()) {
3470+
InitInvok.getSearchPathOptions().ExplicitSwiftModuleMap =
3471+
options::ExplicitSwiftModuleMap;
3472+
InitInvok.getFrontendOptions().DisableImplicitModules = true;
3473+
}
34653474
// Process the clang arguments last and allow them to override previously
34663475
// set options.
34673476
if (!CCArgs.empty()) {

0 commit comments

Comments
 (0)