forked from qt-creator/qt-creator
Limit result output by default
For huge amount of output the processing takes much too long and blocks QC. So, limiting it to a reasonable value seems appropriate. Additionally provide a setting to be still able to get the full output if you need to. Change-Id: I811d69be33c77830049f64fcf291681f05011966 Reviewed-by: Riitta-Leena Miettinen <riitta-leena.miettinen@theqtcompany.com> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -17,8 +17,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "autotestplugin.h"
|
||||
#include "testresultdelegate.h"
|
||||
#include "testresultmodel.h"
|
||||
#include "testsettings.h"
|
||||
|
||||
#include <QAbstractItemView>
|
||||
#include <QDebug>
|
||||
@@ -28,6 +30,8 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
const static int outputLimit = 100000;
|
||||
|
||||
TestResultDelegate::TestResultDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent)
|
||||
{
|
||||
@@ -124,6 +128,11 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
int leading = fm.leading();
|
||||
int fontHeight = fm.height();
|
||||
output.replace(QLatin1Char('\n'), QChar::LineSeparator);
|
||||
|
||||
if (AutotestPlugin::instance()->settings()->limitResultOutput
|
||||
&& output.length() > outputLimit)
|
||||
output = output.left(outputLimit).append(QLatin1String("..."));
|
||||
|
||||
QTextLayout tl(output);
|
||||
tl.setFont(painter->font());
|
||||
QTextOption txtOption;
|
||||
@@ -143,8 +152,9 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
tl.draw(painter, QPoint(positions.textAreaLeft(), positions.top()));
|
||||
} else {
|
||||
painter->setClipRect(positions.textArea());
|
||||
// cut output before generating elided text as this takes quite long for exhaustive output
|
||||
painter->drawText(positions.textAreaLeft(), positions.top() + fm.ascent(),
|
||||
fm.elidedText(output, Qt::ElideRight, positions.textAreaWidth()));
|
||||
fm.elidedText(output.left(2000), Qt::ElideRight, positions.textAreaWidth()));
|
||||
}
|
||||
|
||||
QString file = testResult.fileName();
|
||||
@@ -222,6 +232,11 @@ QSize TestResultDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo
|
||||
|
||||
int height = 0;
|
||||
int leading = fm.leading();
|
||||
|
||||
if (AutotestPlugin::instance()->settings()->limitResultOutput
|
||||
&& output.length() > outputLimit)
|
||||
output = output.left(outputLimit).append(QLatin1String("..."));
|
||||
|
||||
QTextLayout tl(output);
|
||||
tl.setFont(opt.font);
|
||||
QTextOption txtOption;
|
||||
|
@@ -29,10 +29,12 @@ static const char timeoutKey[] = "Timeout";
|
||||
static const char metricsKey[] = "Metrics";
|
||||
static const char omitInternalKey[] = "OmitInternal";
|
||||
static const char omitRunConfigWarnKey[] = "OmitRCWarnings";
|
||||
static const char limitResultOutputKey[] = "LimitResultOutput";
|
||||
static const int defaultTimeout = 60000;
|
||||
|
||||
TestSettings::TestSettings()
|
||||
: timeout(defaultTimeout), metrics(Walltime), omitInternalMssg(true), omitRunConfigWarn(false)
|
||||
: timeout(defaultTimeout), metrics(Walltime), omitInternalMssg(true), omitRunConfigWarn(false),
|
||||
limitResultOutput(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -43,6 +45,7 @@ void TestSettings::toSettings(QSettings *s) const
|
||||
s->setValue(QLatin1String(metricsKey), metrics);
|
||||
s->setValue(QLatin1String(omitInternalKey), omitInternalMssg);
|
||||
s->setValue(QLatin1String(omitRunConfigWarnKey), omitRunConfigWarn);
|
||||
s->setValue(QLatin1String(limitResultOutputKey), limitResultOutput);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
@@ -71,13 +74,15 @@ void TestSettings::fromSettings(const QSettings *s)
|
||||
metrics = intToMetrics(s->value(root + QLatin1String(metricsKey), Walltime).toInt());
|
||||
omitInternalMssg = s->value(root + QLatin1String(omitInternalKey), true).toBool();
|
||||
omitRunConfigWarn = s->value(root + QLatin1String(omitRunConfigWarnKey), false).toBool();
|
||||
limitResultOutput = s->value(root + QLatin1String(limitResultOutputKey), true).toBool();
|
||||
}
|
||||
|
||||
bool TestSettings::equals(const TestSettings &rhs) const
|
||||
{
|
||||
return timeout == rhs.timeout && metrics == rhs.metrics
|
||||
&& omitInternalMssg == rhs.omitInternalMssg
|
||||
&& omitRunConfigWarn == rhs.omitRunConfigWarn;
|
||||
&& omitRunConfigWarn == rhs.omitRunConfigWarn
|
||||
&& limitResultOutput == rhs.limitResultOutput;
|
||||
}
|
||||
|
||||
QString TestSettings::metricsTypeToOption(const MetricsType type)
|
||||
|
@@ -49,6 +49,7 @@ struct TestSettings
|
||||
MetricsType metrics;
|
||||
bool omitInternalMssg;
|
||||
bool omitRunConfigWarn;
|
||||
bool limitResultOutput;
|
||||
};
|
||||
|
||||
inline bool operator==(const TestSettings &s1, const TestSettings &s2) { return s1.equals(s2); }
|
||||
|
@@ -41,6 +41,7 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
|
||||
m_ui.timeoutSpin->setValue(settings.timeout / 1000); // we store milliseconds
|
||||
m_ui.omitInternalMsgCB->setChecked(settings.omitInternalMssg);
|
||||
m_ui.omitRunConfigWarnCB->setChecked(settings.omitRunConfigWarn);
|
||||
m_ui.limitResultOutputCB->setChecked(settings.limitResultOutput);
|
||||
|
||||
switch (settings.metrics) {
|
||||
case MetricsType::Walltime:
|
||||
@@ -69,6 +70,7 @@ TestSettings TestSettingsWidget::settings() const
|
||||
result.timeout = m_ui.timeoutSpin->value() * 1000; // we display seconds
|
||||
result.omitInternalMssg = m_ui.omitInternalMsgCB->isChecked();
|
||||
result.omitRunConfigWarn = m_ui.omitRunConfigWarnCB->isChecked();
|
||||
result.limitResultOutput = m_ui.limitResultOutputCB->isChecked();
|
||||
|
||||
if (m_ui.walltimeRB->isChecked())
|
||||
result.metrics = MetricsType::Walltime;
|
||||
|
@@ -13,7 +13,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
@@ -103,6 +103,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="limitResultOutputCB">
|
||||
<property name="toolTip">
|
||||
<string>Limit result output to 100000 characters.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Limit result output</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
Reference in New Issue
Block a user