AutoTest: Fix outputparser

This patch amends 3056105c66. This patch fixes
handling of output while debugging and appending
to the "real" output if the user interacts with
the output while the test is running.

Change-Id: I1db54382f1df3e2b9a5a860002aac8fb208ee5b9
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2018-11-06 16:00:48 +01:00
parent 790a86d508
commit 1cfaa828a8
9 changed files with 33 additions and 16 deletions

View File

@@ -471,25 +471,35 @@ void TestRunner::runTests()
static void processOutput(TestOutputReader *outputreader, const QString &msg,
Utils::OutputFormat format)
{
QByteArray message = msg.toUtf8();
switch (format) {
case Utils::OutputFormat::StdOutFormatSameLine:
case Utils::OutputFormat::DebugFormat: {
static const QString gdbSpecialOut = "Qt: gdb: -nograb added to command-line options.\n"
"\t Use the -dograb option to enforce grabbing.";
int start = msg.startsWith(gdbSpecialOut) ? gdbSpecialOut.length() + 1 : 0;
static const QByteArray gdbSpecialOut = "Qt: gdb: -nograb added to command-line options.\n"
"\t Use the -dograb option to enforce grabbing.";
int start = message.startsWith(gdbSpecialOut) ? gdbSpecialOut.length() + 1 : 0;
if (start) {
int maxIndex = msg.length() - 1;
int maxIndex = message.length() - 1;
while (start < maxIndex && msg.at(start + 1) == '\n')
++start;
if (start >= msg.length()) // we cut out the whole message
if (start >= message.length()) // we cut out the whole message
break;
}
for (const QString &line : msg.mid(start).split('\n'))
outputreader->processOutput(line.toUtf8());
int index = message.indexOf('\n', start);
while (index != -1) {
const QByteArray line = message.mid(start, index - start + 1);
outputreader->processOutput(line);
start = index + 1;
index = message.indexOf('\n', start);
}
if (!QTC_GUARD(start == message.length())) // paranoia
outputreader->processOutput(message.mid(start).append('\n'));
break;
}
case Utils::OutputFormat::StdErrFormatSameLine:
outputreader->processStdError(msg.toUtf8());
outputreader->processStdError(message);
break;
default:
break; // channels we're not caring about