Skip to content

Commit b41e98e

Browse files
committed
[swift-ide-test] Emit a diagnostic if we can't find the module to print.
Fixes rdar://problem/41048812.
1 parent 5132fc7 commit b41e98e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

test/IDE/print_module_missing.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Make sure we emit some kind of error message when we cannot find the module
2+
// to print.
3+
4+
// RUN: not %target-swift-ide-test -print-module -print-interface -no-empty-line-between-members -module-to-print=NoSuchModule -source-filename=%s 2> %t.err
5+
// RUN: %FileCheck %s -check-prefix=CHECK-MISSING < %t.err
6+
7+
// RUN: not %target-swift-ide-test -print-module -print-interface -no-empty-line-between-members -module-to-print=Swift.NoSuchSubModule -source-filename=%s 2> %t.suberr
8+
// RUN: %FileCheck %s -check-prefix=CHECK-MISSING-SUBMODULE < %t.suberr
9+
10+
// CHECK-MISSING: 'NoSuchModule'
11+
// CHECK-MISSING-SUBMODULE: 'Swift.NoSuchSubModule'

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,8 @@ static int doPrintModules(const CompilerInvocation &InitInvok,
18541854
// Get the (sub)module to print.
18551855
auto *M = getModuleByFullName(Context, ModuleToPrint);
18561856
if (!M) {
1857+
llvm::errs() << "error: could not find module '" << ModuleToPrint
1858+
<< "'\n";
18571859
ExitCode = 1;
18581860
continue;
18591861
}
@@ -1873,6 +1875,8 @@ static int doPrintModules(const CompilerInvocation &InitInvok,
18731875
if (ModuleName.size() > 1) {
18741876
M = getModuleByFullName(Context, ModuleName[0]);
18751877
if (!M) {
1878+
llvm::errs() << "error: could not find module '" << ModuleName[0]
1879+
<< "'\n";
18761880
ExitCode = 1;
18771881
continue;
18781882
}

0 commit comments

Comments
 (0)