Skip to content

Commit f93c33a

Browse files
committed
[swift-ide-test] Print first 20 actual output lines when test in batch completion fails
I found this really useful to understand what’s going wrong
1 parent 3cf948b commit f93c33a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@
6767
#include "llvm/Support/ManagedStatic.h"
6868
#include <system_error>
6969

70+
#include <algorithm>
71+
#include <chrono>
7072
#include <random>
7173
#include <string>
72-
#include <chrono>
7374

7475
using namespace swift;
7576
using namespace ide;
@@ -1623,6 +1624,17 @@ static int doBatchCodeCompletion(const CompilerInvocation &InitInvok,
16231624
for (auto arg : FileCheckArgs)
16241625
llvm::errs() << " " << arg;
16251626
llvm::errs() << "\n";
1627+
llvm::errs() << "Code completion results:\n";
1628+
SmallVector<StringRef, 20> ResultLines;
1629+
llvm::SplitString(ResultStr, ResultLines, "\n");
1630+
for (size_t LineNo = 0;
1631+
LineNo < std::min(ResultLines.size(), static_cast<size_t>(20));
1632+
LineNo++) {
1633+
llvm::errs() << ResultLines[LineNo] << '\n';
1634+
}
1635+
if (ResultLines.size() > 20) {
1636+
llvm::errs() << " + " << (ResultLines.size() - 20) << " more lines\n";
1637+
}
16261638
}
16271639
}
16281640

0 commit comments

Comments
 (0)