2015-01-16 13:44:24 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-01-16 13:44:24 +01:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** This file is part of Qt Creator.
|
2015-01-16 13:44:24 +01:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
2015-01-16 13:44:24 +01:00
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-22 10:37:55 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2015-01-16 13:44:24 +01:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2015-01-16 13:44:24 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2015-12-09 09:46:33 +01:00
|
|
|
#include "testoutputreader.h"
|
2015-01-16 13:44:24 +01:00
|
|
|
#include "testresult.h"
|
2017-05-05 13:01:06 +02:00
|
|
|
#include "testresultspane.h"
|
2015-01-16 13:44:24 +01:00
|
|
|
|
2015-10-09 14:19:53 +02:00
|
|
|
#include <QDebug>
|
2015-01-16 13:44:24 +01:00
|
|
|
#include <QProcess>
|
|
|
|
|
|
|
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2016-02-25 13:02:31 +01:00
|
|
|
TestOutputReader::TestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
2016-01-26 17:24:11 +01:00
|
|
|
QProcess *testApplication, const QString &buildDirectory)
|
2016-01-20 08:26:10 +01:00
|
|
|
: m_futureInterface(futureInterface)
|
|
|
|
|
, m_testApplication(testApplication)
|
2016-01-26 17:24:11 +01:00
|
|
|
, m_buildDir(buildDirectory)
|
2015-01-16 13:44:24 +01:00
|
|
|
{
|
2016-07-21 16:02:42 +02:00
|
|
|
if (m_testApplication) {
|
|
|
|
|
connect(m_testApplication, &QProcess::readyRead,
|
|
|
|
|
this, [this] () {
|
2017-05-05 13:01:06 +02:00
|
|
|
while (m_testApplication->canReadLine()) {
|
|
|
|
|
QByteArray output = m_testApplication->readLine();
|
|
|
|
|
output.chop(1); // remove the newline from the output
|
|
|
|
|
if (output.endsWith('\r'))
|
|
|
|
|
output.chop(1);
|
|
|
|
|
|
|
|
|
|
emit newOutputAvailable(output);
|
|
|
|
|
processOutput(output);
|
|
|
|
|
}
|
2016-07-21 16:02:42 +02:00
|
|
|
});
|
|
|
|
|
connect(m_testApplication, &QProcess::readyReadStandardError,
|
|
|
|
|
this, [this] () {
|
2017-05-05 13:01:06 +02:00
|
|
|
const QByteArray output = m_testApplication->readAllStandardError();
|
|
|
|
|
emit newOutputAvailable(output);
|
|
|
|
|
processStdError(output);
|
2016-07-21 16:02:42 +02:00
|
|
|
});
|
|
|
|
|
}
|
2016-04-18 10:24:54 +02:00
|
|
|
}
|
|
|
|
|
|
2016-07-21 10:08:11 +02:00
|
|
|
void TestOutputReader::processStdError(const QByteArray &output)
|
2016-04-18 10:24:54 +02:00
|
|
|
{
|
2016-07-21 10:08:11 +02:00
|
|
|
qWarning() << "AutoTest.Run: Ignored plain output:" << output;
|
2015-01-16 13:44:24 +01:00
|
|
|
}
|
|
|
|
|
|
2017-09-20 11:20:25 +02:00
|
|
|
void TestOutputReader::reportResult(const TestResultPtr &result)
|
|
|
|
|
{
|
|
|
|
|
m_futureInterface.reportResult(result);
|
|
|
|
|
m_hadValidOutput = true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-16 13:44:24 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|