summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer/commandlineinstall
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2024-01-23 11:43:45 +0200
committerKatja Marttila <katja.marttila@qt.io>2024-03-05 10:12:17 +0000
commit49c7011844a85bc50004e64ee5e56705202f10a5 (patch)
tree59e92d12a1f4b481f8cb9ee1faa0335370848624 /tests/auto/installer/commandlineinstall
parent3f5a21fe502a513f1cc3bdee1863688a85481fef (diff)
CLI: Perform commands primarily from default repositories
Especially in installers which contains huge amount of repositories, it takes a long time to perform commands from CLI. If the repositories are filtered using categories, it saves a lot of time if the components to install/update etc. are tried to install/update from the defaultly selected repository categories. Assuming that the component is found from the defaultly selected repositories. If the component is not found from defaultly selected repository categories, then all categories are searched for the component. Implemented also a filter logic, where the components to install are searched earlier, if the component is not found then we can exit early. Task-number: QTIFW-3251 Change-Id: I1274b5f56dbff293554cb21839a8cea63a7d2dcc Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'tests/auto/installer/commandlineinstall')
-rw-r--r--tests/auto/installer/commandlineinstall/tst_commandlineinstall.cpp57
1 files changed, 53 insertions, 4 deletions
diff --git a/tests/auto/installer/commandlineinstall/tst_commandlineinstall.cpp b/tests/auto/installer/commandlineinstall/tst_commandlineinstall.cpp
index 948768f8d..4dfadbad6 100644
--- a/tests/auto/installer/commandlineinstall/tst_commandlineinstall.cpp
+++ b/tests/auto/installer/commandlineinstall/tst_commandlineinstall.cpp
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2023 The Qt Company Ltd.
+** Copyright (C) 2024 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -34,6 +34,7 @@
#include <QLoggingCategory>
#include <QTest>
#include <QRegularExpression>
+#include <QSignalSpy>
using namespace QInstaller;
@@ -54,7 +55,6 @@ public:
void ignoreInstallPackageFailsMessages(const QRegularExpression &regExp)
{
QTest::ignoreMessage(QtDebugMsg, "Fetching latest update information...");
- QTest::ignoreMessage(QtDebugMsg, "Loading component scripts...");
QTest::ignoreMessage(QtDebugMsg, regExp);
}
@@ -159,8 +159,6 @@ private slots:
QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList()
<< QLatin1String("B.subcomponent")));
- ignoreInstallPackageFailsMessages(QRegularExpression("Cannot install MissingComponent. "
- "Component not found.\n"));
QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList()
<< QLatin1String("MissingComponent")));
QCOMPARE(PackageManagerCore::Canceled, core->status());
@@ -224,6 +222,57 @@ private slots:
QVERIFY(dir.removeRecursively());
}
+ void testCategoryInstall_data()
+ {
+ QTest::addColumn<QString>("repository");
+ QTest::addColumn<QStringList>("installComponents");
+ QTest::addColumn<PackageManagerCore::Status>("status");
+
+
+ QTest::newRow("Category installation")
+ << ":///data/installPackagesRepository"
+ << (QStringList() << "componentE")
+ << PackageManagerCore::Success;
+ }
+
+ void testCategoryInstall()
+ {
+ QFETCH(QString, repository);
+ QFETCH(QStringList, installComponents);
+ QFETCH(PackageManagerCore::Status, status);
+
+
+ QString loggingRules = (QLatin1String("ifw.* = true\n"));
+ QLoggingCategory::setFilterRules(loggingRules);
+ QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit
+ (m_installDir));
+
+ RepositoryCategory category;
+ category.setEnabled(false);
+ category.setDisplayName(QLatin1String("category"));
+
+ Repository repo = Repository::fromUserInput(repository);
+ category.addRepository(repo);
+
+ QSet<RepositoryCategory> categories;
+ categories.insert(category);
+
+ core->settings().addRepositoryCategories(categories);
+
+ QSignalSpy spy(core.data(), &PackageManagerCore::statusChanged);
+ QCOMPARE(core->installSelectedComponentsSilently(QStringList() << installComponents), status);
+
+ QList<int> statusArguments;
+
+ for (qsizetype i = 0; i < spy.size(); ++i) {
+ QList<QVariant> tempList = spy.at(i);
+ statusArguments << tempList.at(0).toInt();
+ }
+
+ QVERIFY(statusArguments.contains(PackageManagerCore::NoPackagesFound));
+ QVERIFY(statusArguments.contains(PackageManagerCore::Success));
+ }
+
void testInstall_data()
{
QTest::addColumn<QString>("repository");