diff options
author | Katja Marttila <katja.marttila@qt.io> | 2020-02-13 12:42:28 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2020-02-20 07:37:26 +0000 |
commit | 6ce8f28ba643d65ccd628ebf2e90b9d2540668f0 (patch) | |
tree | bda09664a7c4d834d09555204ed5a46296a5eeef | |
parent | 6163fc05768b6a7d05530ef5c33d8f024ebd6b6d (diff) |
Add unit tests for CLI option installPackages
Also remove extra space and quotation marks from print output
Change-Id: I18eb3532ac79f407023e15ef7ebab78ca0a7f59e
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
11 files changed, 75 insertions, 6 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index de3ff4e6b..94bb4cd78 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -2172,22 +2172,22 @@ void PackageManagerCore::installSelectedComponentsSilently(const QStringList& co if (idx.isValid()) { if (model->data(idx, Qt::CheckStateRole) == QVariant::Invalid) { // User cannot select the component, check why if (component && component->autoDependencies().count() > 0) - qCDebug(QInstaller::lcInstallerInstallLog) << "Cannot install component "<< name - << "Component is installed only as automatic dependency to "<< component->autoDependencies().join(QLatin1Char(',')); + qCDebug(QInstaller::lcInstallerInstallLog).noquote().nospace() << "Cannot install component "<< name + << ". Component is installed only as automatic dependency to "<< component->autoDependencies().join(QLatin1Char(',')) << "."; if (component && !component->isCheckable()) - qCDebug(QInstaller::lcInstallerInstallLog) << "Cannot install component "<< name + qCDebug(QInstaller::lcInstallerInstallLog).noquote().nospace() << "Cannot install component "<< name <<". Component is not checkable meaning you have to select one of the subcomponents."; } else if (component->isInstalled()) { - qCDebug(QInstaller::lcInstallerInstallLog) << "Component " << name <<" already installed"; + qCDebug(QInstaller::lcInstallerInstallLog).noquote().nospace() << "Component " << name <<" already installed"; } else { model->setData(idx, Qt::Checked, Qt::CheckStateRole); installComponentsFound = true; } } else { // idx is invalid and component valid when we have invisible virtual component if (component && component->isVirtual()) - qCDebug(QInstaller::lcInstallerInstallLog) << "Cannot install " << name <<". Component is virtual."; + qCDebug(QInstaller::lcInstallerInstallLog).noquote().nospace() << "Cannot install " << name <<". Component is virtual."; else - qCDebug(QInstaller::lcInstallerInstallLog) << "Cannot install " << name <<". Component not found."; + qCDebug(QInstaller::lcInstallerInstallLog).noquote().nospace() << "Cannot install " << name <<". Component not found."; } } if (installComponentsFound) { diff --git a/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/A/2.0.0content.7z b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/A/2.0.0content.7z Binary files differnew file mode 100644 index 000000000..d7fbf4d8e --- /dev/null +++ b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/A/2.0.0content.7z diff --git a/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/A/2.0.0content.7z.sha1 b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/A/2.0.0content.7z.sha1 new file mode 100644 index 000000000..c5825de47 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/A/2.0.0content.7z.sha1 @@ -0,0 +1 @@ +f33d2028e1c61061f7f29e5189f7d66800361dc2
\ No newline at end of file diff --git a/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/A/2.0.0meta.7z b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/A/2.0.0meta.7z Binary files differnew file mode 100644 index 000000000..d783c7c1c --- /dev/null +++ b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/A/2.0.0meta.7z diff --git a/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/AB/1.0.2-1meta.7z b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/AB/1.0.2-1meta.7z Binary files differnew file mode 100644 index 000000000..20f2aca2d --- /dev/null +++ b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/AB/1.0.2-1meta.7z diff --git a/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/B/2.0.0content.7z b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/B/2.0.0content.7z Binary files differnew file mode 100644 index 000000000..bd0bc9352 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/B/2.0.0content.7z diff --git a/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/B/2.0.0content.7z.sha1 b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/B/2.0.0content.7z.sha1 new file mode 100644 index 000000000..e66535388 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/B/2.0.0content.7z.sha1 @@ -0,0 +1 @@ +bb256f1eda0f452c7ab33d1f364a4fad062f0a73
\ No newline at end of file diff --git a/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/B/2.0.0meta.7z b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/B/2.0.0meta.7z Binary files differnew file mode 100644 index 000000000..f92853734 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/B/2.0.0meta.7z diff --git a/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/Updates.xml b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/Updates.xml new file mode 100644 index 000000000..e0aedffdd --- /dev/null +++ b/tests/auto/installer/cliinterface/data/uninstallableComponentsRepository/Updates.xml @@ -0,0 +1,40 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>true</Checksum> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>Example component A</Description> + <Version>2.0.0</Version> + <ReleaseDate>2015-01-01</ReleaseDate> + <Default>true</Default> + <UpdateFile CompressedSize="224" OS="Any" UncompressedSize="74"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>c1f340c9a7ad1edbef4cb6288c83c646211e5ccd</SHA1> + <AutoDependOn>autoDep</AutoDependOn> + </PackageUpdate> + <PackageUpdate> + <Name>AB</Name> + <DisplayName>AB</DisplayName> + <Description>Example component AB</Description> + <Version>1.0.2-1</Version> + <ReleaseDate>2015-01-01</ReleaseDate> + <Default>true</Default> + <UpdateFile CompressedSize="0" OS="Any" UncompressedSize="0"/> + <SHA1>3c1470896a9db84092e00806b1303f3b5fa4f7ad</SHA1> + <Checkable>false</Checkable> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>2.0.0</Version> + <ReleaseDate>2015-01-01</ReleaseDate> + <Default>true</Default> + <UpdateFile CompressedSize="224" OS="Any" UncompressedSize="74"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>cfa136fa1d7a4196896c90af72d510727ba799ae</SHA1> + <Virtual>true</Virtual> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/cliinterface/settings.qrc b/tests/auto/installer/cliinterface/settings.qrc index 614c01e3e..c0b643041 100644 --- a/tests/auto/installer/cliinterface/settings.qrc +++ b/tests/auto/installer/cliinterface/settings.qrc @@ -2,6 +2,7 @@ <qresource prefix="/"> <file>data/config.xml</file> <file>data/repository/Updates.xml</file> + <file>data/uninstallableComponentsRepository/Updates.xml</file> </qresource> <qresource prefix="/metadata"> <file>installer-config/config.xml</file> diff --git a/tests/auto/installer/cliinterface/tst_cliinterface.cpp b/tests/auto/installer/cliinterface/tst_cliinterface.cpp index 7f7e45724..48410311d 100644 --- a/tests/auto/installer/cliinterface/tst_cliinterface.cpp +++ b/tests/auto/installer/cliinterface/tst_cliinterface.cpp @@ -93,6 +93,32 @@ private slots: QTest::ignoreMessage(QtDebugMsg, "Id: C"); core->listAvailablePackages(QLatin1String("^C")); } + + void testInstallPackages() + { + QString loggingRules = (QLatin1String("ifw.* = false\n" + "ifw.installer.installlog = true\n")); + PackageManagerCore *core = new PackageManagerCore(BinaryContent::MagicInstallerMarker, QList<OperationBlob> ()); + QLoggingCategory::setFilterRules(loggingRules); + QSet<Repository> repoList; + Repository repo = Repository::fromUserInput(":///data/uninstallableComponentsRepository"); + repoList.insert(repo); + + core->settings().setDefaultRepositories(repoList); + + QTest::ignoreMessage(QtDebugMsg, "Cannot install component A. Component is installed only as automatic dependency to autoDep."); + core->installSelectedComponentsSilently(QStringList() << QLatin1String("A")); + + QTest::ignoreMessage(QtDebugMsg, "Cannot install component AB. Component is not checkable meaning you have to select one of the subcomponents."); + core->installSelectedComponentsSilently(QStringList() << QLatin1String("AB")); + + QTest::ignoreMessage(QtDebugMsg, "Cannot install B. Component is virtual."); + core->installSelectedComponentsSilently(QStringList() << QLatin1String("B")); + + QTest::ignoreMessage(QtDebugMsg, "Cannot install MissingComponent. Component not found."); + core->installSelectedComponentsSilently(QStringList() << QLatin1String("MissingComponent")); + } + }; |