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
|
|
|
|
2023-07-12 12:51:06 +02:00
|
|
|
#include "ctesttool.h"
|
2021-09-06 13:41:25 +02:00
|
|
|
|
2023-07-11 12:40:08 +02:00
|
|
|
#include "ctesttreeitem.h"
|
2021-09-06 13:41:25 +02:00
|
|
|
#include "../autotestconstants.h"
|
2022-07-13 18:31:56 +02:00
|
|
|
#include "../autotesttr.h"
|
2021-09-06 13:41:25 +02:00
|
|
|
|
2023-07-11 12:40:08 +02:00
|
|
|
#include <coreplugin/dialogs/ioptionspage.h>
|
|
|
|
|
|
|
|
|
|
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/buildsystem.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 {
|
|
|
|
|
|
2023-07-11 12:40:08 +02:00
|
|
|
CTestTool &theCTestTool()
|
|
|
|
|
{
|
|
|
|
|
static CTestTool tool;
|
|
|
|
|
return tool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CTestTool::CTestTool()
|
2021-09-06 13:41:25 +02:00
|
|
|
{
|
2023-07-13 14:08:10 +02:00
|
|
|
setActive(false);
|
2021-09-06 13:41:25 +02:00
|
|
|
setSettingsGroups("Autotest", "CTest");
|
2023-07-12 13:35:15 +02:00
|
|
|
setAutoApply(false);
|
2023-07-28 18:11:19 +02:00
|
|
|
setId("AutoTest.Framework.CTest");
|
2023-07-13 14:08:10 +02:00
|
|
|
setDisplayName(Tr::tr("CTest"));
|
2023-05-09 17:46:02 +02:00
|
|
|
|
2024-05-14 14:54:45 +02:00
|
|
|
// clang-format off
|
2023-05-30 17:04:14 +02:00
|
|
|
setLayouter([this] {
|
|
|
|
|
return Row { Form {
|
2023-05-09 17:46:02 +02:00
|
|
|
outputOnFail, br,
|
|
|
|
|
scheduleRandom, br,
|
|
|
|
|
stopOnFailure, br,
|
|
|
|
|
outputMode, br,
|
|
|
|
|
Group {
|
2024-05-14 14:54:45 +02:00
|
|
|
title(Tr::tr("Repeat Tests")),
|
2024-05-14 10:33:01 +02:00
|
|
|
groupChecker(repeat.groupChecker()),
|
2023-05-09 17:46:02 +02:00
|
|
|
Row { repetitionMode, repetitionCount},
|
|
|
|
|
}, br,
|
|
|
|
|
Group {
|
2024-05-14 14:54:45 +02:00
|
|
|
title(Tr::tr("Run in Parallel")),
|
2024-05-14 10:33:01 +02:00
|
|
|
groupChecker(parallel.groupChecker()),
|
2023-05-09 17:46:02 +02:00
|
|
|
Column {
|
|
|
|
|
Row { jobs }, br,
|
2024-05-14 10:33:01 +02:00
|
|
|
Row { testLoad, threshold }
|
2023-05-09 17:46:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-05-30 17:04:14 +02:00
|
|
|
}, st };
|
2023-05-09 17:46:02 +02:00
|
|
|
});
|
2024-05-14 14:54:45 +02:00
|
|
|
// clang-format on
|
2023-05-09 17:46:02 +02:00
|
|
|
|
2021-09-06 13:41:25 +02:00
|
|
|
outputOnFail.setSettingsKey("OutputOnFail");
|
2022-07-13 18:31:56 +02:00
|
|
|
outputOnFail.setLabelText(Tr::tr("Output on failure"));
|
2023-07-28 17:12:21 +02:00
|
|
|
outputOnFail.setLabelPlacement(BoolAspect::LabelPlacement::Compact);
|
2021-09-06 13:41:25 +02:00
|
|
|
outputOnFail.setDefaultValue(true);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
repeat.setSettingsKey("Repeat");
|
|
|
|
|
|
|
|
|
|
scheduleRandom.setSettingsKey("ScheduleRandom");
|
2022-07-13 18:31:56 +02:00
|
|
|
scheduleRandom.setLabelText(Tr::tr("Schedule random"));
|
2023-07-28 17:12:21 +02:00
|
|
|
scheduleRandom.setLabelPlacement(BoolAspect::LabelPlacement::Compact);
|
2021-09-06 13:41:25 +02:00
|
|
|
|
|
|
|
|
stopOnFailure.setSettingsKey("StopOnFail");
|
2022-07-13 18:31:56 +02:00
|
|
|
stopOnFailure.setLabelText(Tr::tr("Stop on failure"));
|
2023-07-28 17:12:21 +02:00
|
|
|
stopOnFailure.setLabelPlacement(BoolAspect::LabelPlacement::Compact);
|
2021-09-06 13:41:25 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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 "
|
2023-05-12 06:55:36 +02:00
|
|
|
"threshold."));
|
2021-09-06 13:41:25 +02:00
|
|
|
|
|
|
|
|
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);
|
2023-11-03 15:44:38 +01:00
|
|
|
|
|
|
|
|
readSettings();
|
|
|
|
|
|
2021-09-06 13:41:25 +02:00
|
|
|
threshold.setEnabler(&testLoad);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-11 12:40:08 +02:00
|
|
|
QStringList CTestTool::activeSettingsAsOptions() const
|
2021-09-06 13:41:25 +02:00
|
|
|
{
|
|
|
|
|
QStringList options;
|
2023-07-13 15:25:40 +02:00
|
|
|
if (outputOnFail())
|
2021-09-06 13:41:25 +02:00
|
|
|
options << "--output-on-failure";
|
2023-07-13 15:25:40 +02:00
|
|
|
switch (outputMode()) {
|
2021-09-06 13:41:25 +02:00
|
|
|
case 1: options << "-V"; break;
|
|
|
|
|
case 2: options << "-VV"; break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
2023-07-13 15:25:40 +02:00
|
|
|
if (repeat()) {
|
2021-09-06 13:41:25 +02:00
|
|
|
QString repeatOption;
|
2023-07-13 15:25:40 +02:00
|
|
|
switch (repetitionMode()) {
|
2021-09-06 13:41:25 +02:00
|
|
|
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(':');
|
2023-07-13 15:25:40 +02:00
|
|
|
repeatOption.append(QString::number(repetitionCount()));
|
2021-09-06 13:41:25 +02:00
|
|
|
options << "--repeat" << repeatOption;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-13 15:25:40 +02:00
|
|
|
if (scheduleRandom())
|
2021-09-06 13:41:25 +02:00
|
|
|
options << "--schedule-random";
|
2023-07-13 15:25:40 +02:00
|
|
|
if (stopOnFailure())
|
2021-09-06 13:41:25 +02:00
|
|
|
options << "--stop-on-failure";
|
2023-07-13 15:25:40 +02:00
|
|
|
if (parallel()) {
|
|
|
|
|
options << "-j" << QString::number(jobs());
|
|
|
|
|
if (testLoad())
|
|
|
|
|
options << "--test-load" << QString::number(threshold());
|
2021-09-06 13:41:25 +02:00
|
|
|
}
|
|
|
|
|
return options;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-11 12:40:08 +02:00
|
|
|
Id CTestTool::buildSystemId() const
|
|
|
|
|
{
|
|
|
|
|
return Id(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ITestTreeItem *CTestTool::createItemFromTestCaseInfo(const ProjectExplorer::TestCaseInfo &tci)
|
|
|
|
|
{
|
|
|
|
|
CTestTreeItem *item = new CTestTreeItem(this, tci.name, tci.path, TestTreeItem::TestCase);
|
|
|
|
|
item->setLine(tci.line);
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ITestTreeItem *CTestTool::createRootNode()
|
|
|
|
|
{
|
|
|
|
|
return new CTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CTestToolSettingsPage
|
|
|
|
|
|
|
|
|
|
class CTestToolSettingsPage final : public Core::IOptionsPage
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CTestToolSettingsPage()
|
|
|
|
|
{
|
2023-07-28 18:11:19 +02:00
|
|
|
setId(Id(Constants::SETTINGSPAGE_PREFIX).withSuffix("255.CTest"));
|
2023-07-11 12:40:08 +02:00
|
|
|
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
|
|
|
|
setDisplayName(Tr::tr("CTest"));
|
|
|
|
|
setSettingsProvider([] { return &theCTestTool(); });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const CTestToolSettingsPage settingsPage;
|
|
|
|
|
|
2023-05-09 17:46:02 +02:00
|
|
|
} // Autotest::Internal
|