2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2021-09-06 13:41:25 +02:00
|
|
|
|
|
|
|
|
#include "ctestsettings.h"
|
|
|
|
|
|
|
|
|
|
#include "../autotestconstants.h"
|
2022-07-13 18:31:56 +02:00
|
|
|
#include "../autotesttr.h"
|
2021-09-06 13:41:25 +02:00
|
|
|
|
|
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
|
2023-05-09 17:46:02 +02:00
|
|
|
using namespace Layouting;
|
|
|
|
|
using namespace Utils;
|
2021-09-06 13:41:25 +02:00
|
|
|
|
2023-05-09 17:46:02 +02:00
|
|
|
namespace Autotest::Internal {
|
|
|
|
|
|
|
|
|
|
CTestSettings::CTestSettings(Id settingsId)
|
2021-09-06 13:41:25 +02:00
|
|
|
{
|
|
|
|
|
setSettingsGroups("Autotest", "CTest");
|
2023-05-09 17:46:02 +02:00
|
|
|
setId(settingsId);
|
|
|
|
|
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
|
|
|
|
setDisplayName(Tr::tr("CTest"));
|
|
|
|
|
|
|
|
|
|
setLayouter([this](QWidget *w) {
|
|
|
|
|
Column { Row { Form {
|
|
|
|
|
outputOnFail, br,
|
|
|
|
|
scheduleRandom, br,
|
|
|
|
|
stopOnFailure, br,
|
|
|
|
|
outputMode, br,
|
|
|
|
|
Group {
|
|
|
|
|
title(Tr::tr("Repeat tests")),
|
|
|
|
|
repeat.groupChecker(),
|
|
|
|
|
Row { repetitionMode, repetitionCount},
|
|
|
|
|
}, br,
|
|
|
|
|
Group {
|
|
|
|
|
title(Tr::tr("Run in parallel")),
|
|
|
|
|
parallel.groupChecker(),
|
|
|
|
|
Column {
|
|
|
|
|
Row { jobs }, br,
|
|
|
|
|
Row { testLoad, threshold}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, st }, st }.attachTo(w);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-06 13:41:25 +02:00
|
|
|
registerAspect(&outputOnFail);
|
|
|
|
|
outputOnFail.setSettingsKey("OutputOnFail");
|
2022-07-13 18:31:56 +02:00
|
|
|
outputOnFail.setLabelText(Tr::tr("Output on failure"));
|
2021-09-06 13:41:25 +02:00
|
|
|
outputOnFail.setDefaultValue(true);
|
|
|
|
|
|
|
|
|
|
registerAspect(&outputMode);
|
|
|
|
|
outputMode.setSettingsKey("OutputMode");
|
2022-07-13 18:31:56 +02:00
|
|
|
outputMode.setLabelText(Tr::tr("Output mode"));
|
2023-05-09 17:46:02 +02:00
|
|
|
outputMode.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
|
2022-07-13 18:31:56 +02:00
|
|
|
outputMode.addOption({Tr::tr("Default"), {}, 0});
|
|
|
|
|
outputMode.addOption({Tr::tr("Verbose"), {}, 1});
|
|
|
|
|
outputMode.addOption({Tr::tr("Very Verbose"), {}, 2});
|
2021-09-06 13:41:25 +02:00
|
|
|
|
|
|
|
|
registerAspect(&repetitionMode);
|
|
|
|
|
repetitionMode.setSettingsKey("RepetitionMode");
|
2022-07-13 18:31:56 +02:00
|
|
|
repetitionMode.setLabelText(Tr::tr("Repetition mode"));
|
2023-05-09 17:46:02 +02:00
|
|
|
repetitionMode.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
|
2022-07-13 18:31:56 +02:00
|
|
|
repetitionMode.addOption({Tr::tr("Until Fail"), {}, 0});
|
|
|
|
|
repetitionMode.addOption({Tr::tr("Until Pass"), {}, 1});
|
|
|
|
|
repetitionMode.addOption({Tr::tr("After Timeout"), {}, 2});
|
2021-09-06 13:41:25 +02:00
|
|
|
|
|
|
|
|
registerAspect(&repetitionCount);
|
|
|
|
|
repetitionCount.setSettingsKey("RepetitionCount");
|
|
|
|
|
repetitionCount.setDefaultValue(1);
|
2022-07-13 18:31:56 +02:00
|
|
|
repetitionCount.setLabelText(Tr::tr("Count"));
|
|
|
|
|
repetitionCount.setToolTip(Tr::tr("Number of re-runs for the test."));
|
2021-09-06 13:41:25 +02:00
|
|
|
repetitionCount.setRange(1, 10000);
|
|
|
|
|
|
|
|
|
|
registerAspect(&repeat);
|
|
|
|
|
repeat.setSettingsKey("Repeat");
|
|
|
|
|
|
|
|
|
|
registerAspect(&scheduleRandom);
|
|
|
|
|
scheduleRandom.setSettingsKey("ScheduleRandom");
|
2022-07-13 18:31:56 +02:00
|
|
|
scheduleRandom.setLabelText(Tr::tr("Schedule random"));
|
2021-09-06 13:41:25 +02:00
|
|
|
|
|
|
|
|
registerAspect(&stopOnFailure);
|
|
|
|
|
stopOnFailure.setSettingsKey("StopOnFail");
|
2022-07-13 18:31:56 +02:00
|
|
|
stopOnFailure.setLabelText(Tr::tr("Stop on failure"));
|
2021-09-06 13:41:25 +02:00
|
|
|
|
|
|
|
|
registerAspect(¶llel);
|
|
|
|
|
parallel.setSettingsKey("Parallel");
|
2022-07-13 18:31:56 +02:00
|
|
|
parallel.setToolTip(Tr::tr("Run tests in parallel mode using given number of jobs."));
|
2021-09-06 13:41:25 +02:00
|
|
|
|
|
|
|
|
registerAspect(&jobs);
|
|
|
|
|
jobs.setSettingsKey("Jobs");
|
2022-07-13 18:31:56 +02:00
|
|
|
jobs.setLabelText(Tr::tr("Jobs"));
|
2021-09-06 13:41:25 +02:00
|
|
|
jobs.setDefaultValue(1);
|
|
|
|
|
jobs.setRange(1, 128);
|
|
|
|
|
|
|
|
|
|
registerAspect(&testLoad);
|
|
|
|
|
testLoad.setSettingsKey("TestLoad");
|
2022-07-13 18:31:56 +02:00
|
|
|
testLoad.setLabelText(Tr::tr("Test load"));
|
|
|
|
|
testLoad.setToolTip(Tr::tr("Try not to start tests when they may cause CPU load to pass a "
|
2021-09-06 13:41:25 +02:00
|
|
|
"threshold."));
|
|
|
|
|
|
|
|
|
|
registerAspect(&threshold);
|
|
|
|
|
threshold.setSettingsKey("Threshold");
|
2022-07-13 18:31:56 +02:00
|
|
|
threshold.setLabelText(Tr::tr("Threshold"));
|
2021-09-06 13:41:25 +02:00
|
|
|
threshold.setDefaultValue(1);
|
|
|
|
|
threshold.setRange(1, 128);
|
|
|
|
|
threshold.setEnabler(&testLoad);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList CTestSettings::activeSettingsAsOptions() const
|
|
|
|
|
{
|
|
|
|
|
QStringList options;
|
|
|
|
|
if (outputOnFail.value())
|
|
|
|
|
options << "--output-on-failure";
|
|
|
|
|
switch (outputMode.value()) {
|
|
|
|
|
case 1: options << "-V"; break;
|
|
|
|
|
case 2: options << "-VV"; break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
if (repeat.value()) {
|
|
|
|
|
QString repeatOption;
|
|
|
|
|
switch (repetitionMode.value()) {
|
|
|
|
|
case 0: repeatOption = "until-fail"; break;
|
|
|
|
|
case 1: repeatOption = "until-pass"; break;
|
|
|
|
|
case 2: repeatOption = "after-timeout"; break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
if (!repeatOption.isEmpty()) {
|
|
|
|
|
repeatOption.append(':');
|
|
|
|
|
repeatOption.append(QString::number(repetitionCount.value()));
|
|
|
|
|
options << "--repeat" << repeatOption;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (scheduleRandom.value())
|
|
|
|
|
options << "--schedule-random";
|
|
|
|
|
if (stopOnFailure.value())
|
|
|
|
|
options << "--stop-on-failure";
|
|
|
|
|
if (parallel.value()) {
|
|
|
|
|
options << "-j" << QString::number(jobs.value());
|
|
|
|
|
if (testLoad.value())
|
|
|
|
|
options << "--test-load" << QString::number(threshold.value());
|
|
|
|
|
}
|
|
|
|
|
return options;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-09 17:46:02 +02:00
|
|
|
} // Autotest::Internal
|