summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2020-09-23 19:37:31 +0300
committerKatja Marttila <katja.marttila@qt.io>2020-09-25 10:32:30 +0300
commit02f8711dc250b4c4f07ea7b43cbb0904496b1cb3 (patch)
tree91357567cd4dfe0c0df14e2b21f5ef871fcce14e
parent557feae54796a861f6076d30df17958e14debb4c (diff)
CLI: Give more meaningfull return value for installs
Instead of returning just true or false when running installer or maintenancetool, utilize the PackagemanagerCore status message. Added also a new status enum, EssentialUpdated, which is returned when calling command 'update' and only essential components are updated. Also fixed a bug when components could be installed even when there were an essential update available. Task-number: QTIFW-1969 Change-Id: I43826301656573b34e1338b49566d199bdcd7468 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
-rw-r--r--doc/installerfw.qdoc4
-rw-r--r--src/libs/installer/packagemanagercore.cpp65
-rw-r--r--src/libs/installer/packagemanagercore.h19
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp5
-rw-r--r--src/sdk/commandlineinterface.cpp14
-rw-r--r--tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp3
-rw-r--r--tests/auto/installer/cliinterface/tst_cliinterface.cpp112
-rw-r--r--tests/auto/installer/commandlineupdate/data/installPackagesRepository/Updates.xml1
-rw-r--r--tests/auto/installer/commandlineupdate/data/installPackagesRepositoryUpdate/Updates.xml1
-rw-r--r--tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp74
-rw-r--r--tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp3
11 files changed, 199 insertions, 102 deletions
diff --git a/doc/installerfw.qdoc b/doc/installerfw.qdoc
index 42f410ec3..a77459b1f 100644
--- a/doc/installerfw.qdoc
+++ b/doc/installerfw.qdoc
@@ -159,6 +159,10 @@
separated by space. The \c <key=value> list is used to set internal key-value
pairs by the framework.
+ Installer will return an exit code after it is executed. Exit code can be used
+ to determine whether the installation was successful, if the installation has
+ an mandatory update etc. See \c PackagemanagerCore::Status.
+
\section1 Summary of Options
Options marked with \c CLI are only available when running in headless mode,
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 920ef0987..07f86647c 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -135,6 +135,9 @@ using namespace QInstaller;
\value Unfinished
Installation was not completed.
\value ForceUpdate
+ Installation has to be updated.
+ \value EssentialUpdated
+ Installation essential components were updated.
*/
/*!
@@ -2255,10 +2258,9 @@ void PackageManagerCore::listInstalledPackages()
/*!
Updates the selected components \a componentsToUpdate without GUI.
If essential components are found, then only those will be updated.
- Returns \c true if components are updated successfully or there are
- no updates to perform, otherwise returns \c false.
+ Returns PackageManagerCore installation status.
*/
-bool PackageManagerCore::updateComponentsSilently(const QStringList &componentsToUpdate)
+PackageManagerCore::Status PackageManagerCore::updateComponentsSilently(const QStringList &componentsToUpdate)
{
if (d->runningProcessesFound())
throw Error(tr("Running processes found."));
@@ -2303,7 +2305,7 @@ bool PackageManagerCore::updateComponentsSilently(const QStringList &componentsT
if (userSelectedComponents && componentsToBeUpdated.isEmpty()) {
qCDebug(QInstaller::lcInstallerInstallLog)
<< "No updates available for selected components.";
- return true;
+ return PackageManagerCore::Success;
}
foreach (Component *componentToUpdate, componentsToBeUpdated) {
const QModelIndex &idx = model->indexFromComponentName(componentToUpdate->name());
@@ -2312,7 +2314,7 @@ bool PackageManagerCore::updateComponentsSilently(const QStringList &componentsT
}
if (!d->calculateComponentsAndRun())
- return false;
+ return status();
if (essentialUpdatesFound) {
qCDebug(QInstaller::lcInstallerInstallLog) << "Essential components updated successfully."
@@ -2321,7 +2323,7 @@ bool PackageManagerCore::updateComponentsSilently(const QStringList &componentsT
qCDebug(QInstaller::lcInstallerInstallLog) << "Components updated successfully.";
}
}
- return true;
+ return status();
}
/*!
@@ -2336,10 +2338,9 @@ void PackageManagerCore::commitSessionOperations()
/*!
Uninstalls the selected components \a components without GUI.
- Returns \c true if components are uninstalled successfully or
- there are no components to uninstall, otherwise returns \c false.
+ Returns PackageManagerCore installation status.
*/
-bool PackageManagerCore::uninstallComponentsSilently(const QStringList& components)
+PackageManagerCore::Status PackageManagerCore::uninstallComponentsSilently(const QStringList& components)
{
if (d->runningProcessesFound())
throw Error(tr("Running processes found."));
@@ -2364,20 +2365,17 @@ bool PackageManagerCore::uninstallComponentsSilently(const QStringList& componen
}
if (uninstallComponentFound) {
- if (!d->calculateComponentsAndRun())
- return false;
-
- qCDebug(QInstaller::lcInstallerInstallLog) << "Components uninstalled successfully";
+ if (d->calculateComponentsAndRun())
+ qCDebug(QInstaller::lcInstallerInstallLog) << "Components uninstalled successfully";
}
- return true;
+ return status();
}
/*!
Uninstalls all installed components without GUI and removes
- the program directory. Returns \c true if components are
- uninstalled successfully, otherwise returns \c false.
+ the program directory. Returns PackageManagerCore installation status.
*/
-bool PackageManagerCore::removeInstallationSilently()
+PackageManagerCore::Status PackageManagerCore::removeInstallationSilently()
{
if (d->runningProcessesFound())
throw Error(tr("Running processes found."));
@@ -2385,20 +2383,22 @@ bool PackageManagerCore::removeInstallationSilently()
qCDebug(QInstaller::lcInstallerInstallLog) << "Complete uninstallation was chosen.";
if (!(d->m_autoConfirmCommand || d->askUserConfirmCommand())) {
qCDebug(QInstaller::lcInstallerInstallLog) << "Uninstallation aborted.";
- return false;
+ return status();
}
setCompleteUninstallation(true);
- return run();
+ if (run())
+ return PackageManagerCore::Success;
+ else
+ return PackageManagerCore::Failure;
}
/*!
Installs the selected components \a components without displaying a user
interface. Virtual components cannot be installed unless made visible with
--show-virtual-components. AutoDependOn nor non-checkable components cannot
- be installed directly. Returns \c true if components are installed or there
- is nothing to install, otherwise returns \c false.
+ be installed directly. Returns PackageManagerCore installation status.
*/
-bool PackageManagerCore::installSelectedComponentsSilently(const QStringList& components)
+PackageManagerCore::Status PackageManagerCore::installSelectedComponentsSilently(const QStringList& components)
{
if (!isInstaller()) {
// Check if there are processes running in the install if maintenancetool is used.
@@ -2413,12 +2413,13 @@ bool PackageManagerCore::installSelectedComponentsSilently(const QStringList& co
helperStrList.removeDuplicates();
if (helperStrList.count() == installedPackages.count()) {
qCDebug(QInstaller::lcInstallerInstallLog) << "Components already installed.";
- return true;
+ return PackageManagerCore::Success;
}
}
ComponentModel *model = defaultComponentModel();
- fetchRemotePackagesTree();
+ if (!fetchRemotePackagesTree())
+ return status();
bool installComponentsFound = false;
foreach (const QString &name, components){
@@ -2447,22 +2448,19 @@ bool PackageManagerCore::installSelectedComponentsSilently(const QStringList& co
}
}
if (installComponentsFound) {
- if (!d->calculateComponentsAndRun())
- return false;
-
- qCDebug(QInstaller::lcInstallerInstallLog) << "Components installed successfully";
+ if (d->calculateComponentsAndRun())
+ qCDebug(QInstaller::lcInstallerInstallLog) << "Components installed successfully";
}
- return true;
+ return status();
}
/*!
Installs components that are checked by default, i.e. those that are set
with <Default> or <ForcedInstallation> and their respective dependencies
without GUI.
- Returns \c true if default components are found and the maintenance tool
- needs to be written, otherwise returns \c false.
+ Returns PackageManagerCore installation status.
*/
-bool PackageManagerCore::installDefaultComponentsSilently()
+PackageManagerCore::Status PackageManagerCore::installDefaultComponentsSilently()
{
d->m_defaultInstall = true;
ComponentModel *model = defaultComponentModel();
@@ -2472,12 +2470,11 @@ bool PackageManagerCore::installDefaultComponentsSilently()
// There are components that are checked by default, we should install them
if (d->calculateComponentsAndRun()) {
qCDebug(QInstaller::lcInstallerInstallLog) << "Components installed successfully.";
- return true;
}
} else {
qCDebug(QInstaller::lcInstallerInstallLog) << "No components available for default installation.";
}
- return false;
+ return status();
}
/*!
diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h
index e02dbeb36..b0feb1a57 100644
--- a/src/libs/installer/packagemanagercore.h
+++ b/src/libs/installer/packagemanagercore.h
@@ -71,10 +71,11 @@ public:
enum Status {
Success = EXIT_SUCCESS,
Failure = EXIT_FAILURE,
- Running,
- Canceled,
- Unfinished,
- ForceUpdate
+ Running = 2,
+ Canceled = 3,
+ Unfinished = 4,
+ ForceUpdate = 5,
+ EssentialUpdated = 6
};
Status status() const;
QString error() const;
@@ -234,11 +235,11 @@ public:
ComponentModel *updaterComponentModel() const;
void listInstalledPackages();
void listAvailablePackages(const QString &regexp);
- bool updateComponentsSilently(const QStringList &componentsToUpdate);
- bool installSelectedComponentsSilently(const QStringList& components);
- bool installDefaultComponentsSilently();
- bool uninstallComponentsSilently(const QStringList& components);
- bool removeInstallationSilently();
+ PackageManagerCore::Status updateComponentsSilently(const QStringList &componentsToUpdate);
+ PackageManagerCore::Status installSelectedComponentsSilently(const QStringList& components);
+ PackageManagerCore::Status installDefaultComponentsSilently();
+ PackageManagerCore::Status uninstallComponentsSilently(const QStringList& components);
+ PackageManagerCore::Status removeInstallationSilently();
// convenience
Q_INVOKABLE void setInstaller();
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index da6ce66b9..52e732e49 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -1820,7 +1820,10 @@ bool PackageManagerCorePrivate::runPackageUpdater()
if (adminRightsGained)
m_core->dropAdminRights();
- setStatus(PackageManagerCore::Success);
+ if (m_foundEssentialUpdate)
+ setStatus(PackageManagerCore::EssentialUpdated);
+ else
+ setStatus(PackageManagerCore::Success);
emit installationFinished();
} catch (const Error &err) {
if (m_core->status() != PackageManagerCore::Canceled) {
diff --git a/src/sdk/commandlineinterface.cpp b/src/sdk/commandlineinterface.cpp
index 942faaf31..bfb4ea75a 100644
--- a/src/sdk/commandlineinterface.cpp
+++ b/src/sdk/commandlineinterface.cpp
@@ -159,8 +159,7 @@ int CommandLineInterface::updatePackages()
if (!checkLicense())
return EXIT_FAILURE;
try {
- return m_core->updateComponentsSilently(m_positionalArguments)
- ? EXIT_SUCCESS : EXIT_FAILURE;
+ return m_core->updateComponentsSilently(m_positionalArguments);
} catch (const QInstaller::Error &err) {
qCCritical(QInstaller::lcInstallerInstallLog) << err.message();
return EXIT_FAILURE;
@@ -179,12 +178,10 @@ int CommandLineInterface::installPackages()
return EXIT_FAILURE;
}
// No packages provided, install default components
- return m_core->installDefaultComponentsSilently()
- ? EXIT_SUCCESS : EXIT_FAILURE;
+ return m_core->installDefaultComponentsSilently();
}
// Normal installation
- return m_core->installSelectedComponentsSilently(m_positionalArguments)
- ? EXIT_SUCCESS : EXIT_FAILURE;
+ return m_core->installSelectedComponentsSilently(m_positionalArguments);
} catch (const QInstaller::Error &err) {
qCCritical(QInstaller::lcInstallerInstallLog) << err.message();
return EXIT_FAILURE;
@@ -201,8 +198,7 @@ int CommandLineInterface::uninstallPackages()
}
m_core->setPackageManager();
try {
- return m_core->uninstallComponentsSilently(m_positionalArguments)
- ? EXIT_SUCCESS : EXIT_FAILURE;
+ return m_core->uninstallComponentsSilently(m_positionalArguments);
} catch (const QInstaller::Error &err) {
qCCritical(QInstaller::lcInstallerInstallLog) << err.message();
return EXIT_FAILURE;
@@ -219,7 +215,7 @@ int CommandLineInterface::removeInstallation()
}
m_core->setUninstaller();
try {
- return m_core->removeInstallationSilently() ? EXIT_SUCCESS : EXIT_FAILURE;
+ return m_core->removeInstallationSilently();
} catch (const QInstaller::Error &err) {
qCCritical(QInstaller::lcInstallerInstallLog) << err.message();
return EXIT_FAILURE;
diff --git a/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp b/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp
index 27061fe4b..1b2d63fd7 100644
--- a/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp
+++ b/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp
@@ -127,7 +127,8 @@ private slots:
core->commitSessionOperations();
// We cannot check the file contents here as it will be deleted on
// undo Extract, but at least check that the uninstallation succeeds.
- QVERIFY(core->uninstallComponentsSilently(QStringList() << "A"));
+ QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently
+ (QStringList()<< "A"));
QDir dir(installDir);
QVERIFY(dir.removeRecursively());
diff --git a/tests/auto/installer/cliinterface/tst_cliinterface.cpp b/tests/auto/installer/cliinterface/tst_cliinterface.cpp
index bdf57541f..9932adb41 100644
--- a/tests/auto/installer/cliinterface/tst_cliinterface.cpp
+++ b/tests/auto/installer/cliinterface/tst_cliinterface.cpp
@@ -96,19 +96,24 @@ private slots:
QTest::ignoreMessage(QtDebugMsg, "\"Preparing meta information download...\"");
QTest::ignoreMessage(QtDebugMsg, "Cannot install component A. Component is installed only as automatic dependency to autoDep.");
- core->installSelectedComponentsSilently(QStringList() << QLatin1String("A"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("A")));
QTest::ignoreMessage(QtDebugMsg, "\"Preparing meta information download...\"");
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"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("AB")));
QTest::ignoreMessage(QtDebugMsg, "\"Preparing meta information download...\"");
QTest::ignoreMessage(QtDebugMsg, "Cannot install B. Component is virtual.");
- core->installSelectedComponentsSilently(QStringList() << QLatin1String("B"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("B")));
QTest::ignoreMessage(QtDebugMsg, "\"Preparing meta information download...\"");
QTest::ignoreMessage(QtDebugMsg, "Cannot install MissingComponent. Component not found.");
- core->installSelectedComponentsSilently(QStringList() << QLatin1String("MissingComponent"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("MissingComponent")));
+ QCOMPARE(PackageManagerCore::Success, core->status());
}
void testUninstallPackageFails()
@@ -126,16 +131,22 @@ private slots:
core.setValue(scTargetDir, m_installDir);
QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall ForcedInstallation component componentE");
- core.uninstallComponentsSilently(QStringList() << "componentE");
+ QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList()
+ << "componentE"));
QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall component componentD because it is added as auto dependency to componentA,componentB");
- core.uninstallComponentsSilently(QStringList() << "componentD");
+ QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList()
+ << "componentD"));
QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall component MissingComponent. Component not found in install tree.");
- core.uninstallComponentsSilently(QStringList() << "MissingComponent");
+ QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList()
+ << "MissingComponent"));
QTest::ignoreMessage(QtWarningMsg, "Cannot uninstall virtual component componentH");
- core.uninstallComponentsSilently(QStringList() << "componentH");
+ QCOMPARE(PackageManagerCore::Success, core.uninstallComponentsSilently(QStringList()
+ << "componentH"));
+
+ QCOMPARE(PackageManagerCore::Success, core.status());
}
void testListInstalledPackages()
@@ -164,7 +175,8 @@ private slots:
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
core->setNoDefaultInstallation(true);
- core->installDefaultComponentsSilently();
+ QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently());
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml"
<< "installcontentE.txt");
core->setNoDefaultInstallation(false);
@@ -174,7 +186,9 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << QLatin1String("componentE"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("componentE")));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall
VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Depends on componentA
@@ -186,7 +200,9 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << QLatin1String("componentA"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("componentA")));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall
VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Depends on componentA
@@ -198,13 +214,16 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << QLatin1String("componentA"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("componentA")));
VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentE.txt"
- << "installcontentA.txt" << "installcontent.txt" << "installcontentG.txt");
+ << "installcontentA.txt" << "installcontent.txt" << "installcontentG.txt");
core->commitSessionOperations();
core->setPackageManager();
- core->uninstallComponentsSilently(QStringList() << QLatin1String("componentA"));
+ QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList()
+ << QLatin1String("componentA")));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall
VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentA");
VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentG"); //Depends on componentA
@@ -215,13 +234,15 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << QLatin1String("componentA"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("componentA")));
VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentE.txt"
<< "installcontentA.txt" << "installcontent.txt" << "installcontentG.txt");
core->commitSessionOperations();
core->setUninstaller();
- QVERIFY(core->removeInstallationSilently());
+ QCOMPARE(PackageManagerCore::Success, core->removeInstallationSilently());
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentA");
VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentE");
VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentG");
@@ -239,7 +260,9 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << QLatin1String("componentC"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("componentC")));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentC
VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt"); //Dependency for componentC
VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall
@@ -254,14 +277,17 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << QLatin1String("componentC"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("componentC")));
VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentC.txt"
<< "installcontent.txt" << "installcontentA.txt" << "installcontentB.txt"
<< "installcontentD.txt"<< "installcontentE.txt" << "installcontentG.txt");
core->commitSessionOperations();
core->setPackageManager();
- core->uninstallComponentsSilently(QStringList() << QLatin1String("componentC"));
+ QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList()
+ << QLatin1String("componentC")));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentC
VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt"); //Dependency for componentC
VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall
@@ -277,7 +303,9 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << QLatin1String("componentF.subcomponent2.subsubcomponent2"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("componentF.subcomponent2.subsubcomponent2")));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResources(m_installDir, "componentF.subcomponent2.subsubcomponent2", "1.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentF.subcomponent2", "1.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentF", "1.0.0content.txt");
@@ -294,14 +322,18 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << QLatin1String("componentF.subcomponent2.subsubcomponent2"));
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << QLatin1String("componentF.subcomponent2.subsubcomponent2")));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentF.txt"
<< "installcontentF_2.txt" << "installcontentF_2_2.txt"
<< "installcontent.txt" << "installcontentA.txt"
<< "installcontentE.txt" << "installcontentG.txt");
core->commitSessionOperations();
core->setPackageManager();
- core->uninstallComponentsSilently(QStringList() << QLatin1String("componentF.subcomponent2"));
+ QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList()
+ << QLatin1String("componentF.subcomponent2")));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentG
VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall
VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Default install
@@ -317,7 +349,8 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installDefaultComponentsSilently();
+ QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently());
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentG
VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall
VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt"); //Default
@@ -329,13 +362,16 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installDefaultComponentsSilently();
+ QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently());
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt"
<< "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt");
core->commitSessionOperations();
core->setPackageManager();
- core->uninstallComponentsSilently(QStringList() << "componentG");
+ QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList()
+ << "componentG"));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentG
VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall
VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentG");
@@ -347,10 +383,13 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installDefaultComponentsSilently();
+ QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently());
+ QCOMPARE(PackageManagerCore::Success, core->status());
core->commitSessionOperations();
core->setPackageManager();
- core->uninstallComponentsSilently(QStringList() << "componentE");
+ QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList()
+ << "componentE"));
+ QCOMPARE(PackageManagerCore::Success, core->status());
//Nothing is uninstalled as componentE is forced install and cannot be uninstalled
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt"); //Dependency for componentG
VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt"); //ForcedInstall
@@ -363,10 +402,14 @@ private slots:
{
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << "componentA" << "componentB");
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << "componentA" << "componentB"));
+ QCOMPARE(PackageManagerCore::Success, core->status());
core->commitSessionOperations();
core->setPackageManager();
- core->uninstallComponentsSilently(QStringList() << "componentD");
+ QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList()
+ << "componentD"));
+ QCOMPARE(PackageManagerCore::Success, core->status());
//Nothing is uninstalled as componentD is installed as autodependency to componentA and componentB
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt");
@@ -383,12 +426,16 @@ private slots:
PackageManagerCore *core = PackageManager::getPackageManagerWithInit
(m_installDir, ":///data/installPackagesRepository");
core->setVirtualComponentsVisible(true);
- core->installSelectedComponentsSilently(QStringList() <<"componentH");
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ <<"componentH"));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResources(m_installDir, "componentH", "1.0.0content.txt");
core->commitSessionOperations();
core->setPackageManager();
- core->uninstallComponentsSilently(QStringList() << "componentH");
+ QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently(QStringList()
+ << "componentH"));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResourcesDeletion(m_installDir, "componentH");
}
@@ -408,7 +455,8 @@ private slots:
core->setFileDialogAutomaticAnswer("GetExistingDirectory", m_installDir);
core->setFileDialogAutomaticAnswer("GetExistingFile", testFile);
- core->installDefaultComponentsSilently();
+ QCOMPARE(PackageManagerCore::Success, core->installDefaultComponentsSilently());
+ QCOMPARE(PackageManagerCore::Success, core->status());
QVERIFY(core->containsFileDialogAutomaticAnswer("ValidFile"));
core->removeFileDialogAutomaticAnswer("ValidFile");
diff --git a/tests/auto/installer/commandlineupdate/data/installPackagesRepository/Updates.xml b/tests/auto/installer/commandlineupdate/data/installPackagesRepository/Updates.xml
index 824a6e21f..345b462d0 100644
--- a/tests/auto/installer/commandlineupdate/data/installPackagesRepository/Updates.xml
+++ b/tests/auto/installer/commandlineupdate/data/installPackagesRepository/Updates.xml
@@ -12,6 +12,7 @@
<UpdateFile OS="Any" CompressedSize="299" UncompressedSize="158"/>
<DownloadableArchives>content.7z</DownloadableArchives>
<SHA1>92b02a74d0886bc1569ff8b3a7edd1f9d828e56c</SHA1>
+ <Essential>true</Essential>
</PackageUpdate>
<PackageUpdate>
<Name>componentB</Name>
diff --git a/tests/auto/installer/commandlineupdate/data/installPackagesRepositoryUpdate/Updates.xml b/tests/auto/installer/commandlineupdate/data/installPackagesRepositoryUpdate/Updates.xml
index f87a105b4..125289261 100644
--- a/tests/auto/installer/commandlineupdate/data/installPackagesRepositoryUpdate/Updates.xml
+++ b/tests/auto/installer/commandlineupdate/data/installPackagesRepositoryUpdate/Updates.xml
@@ -12,6 +12,7 @@
<UpdateFile CompressedSize="297" UncompressedSize="99" OS="Any"/>
<DownloadableArchives>content.7z</DownloadableArchives>
<SHA1>43c8fcc544ea6d35fe5180a50d4764dcf9fd7473</SHA1>
+ <Essential>true</Essential>
</PackageUpdate>
<PackageUpdate>
<Name>componentB</Name>
diff --git a/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp b/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
index 8d223ae09..7a61e9608 100644
--- a/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
+++ b/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
@@ -60,50 +60,93 @@ private slots:
core = PackageManager::getPackageManagerWithInit(m_installDir);
}
- void testUpdatePackageSilently()
+ void testInstallWhenEssentialUpdate()
{
setRepository(":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << "componentA" << "componentB");
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << "componentA"));
+ QCOMPARE(PackageManagerCore::Success, core->status());
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt");
- VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt");
+ VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt"
+ << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt");
+ core->commitSessionOperations();
+ core->setPackageManager();
+ setRepository(":///data/installPackagesRepositoryUpdate");
+ QCOMPARE(PackageManagerCore::ForceUpdate, core->installSelectedComponentsSilently(QStringList()
+ << "componentB"));
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt");
VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt"
- << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt"
- << "installcontentB.txt" << "installcontentD.txt");
+ << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt");
+ }
+
+ void testUpdateEssentialPackageSilently()
+ {
+ QCOMPARE(PackageManagerCore::EssentialUpdated, core->updateComponentsSilently(QStringList()));
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "2.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "1.0.0content.txt");
+ //Because of bug QTIFW-1970 componentD got installed too
+ VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml"
+ << "installcontentA_update.txt" << "installcontentE.txt" << "installcontentG.txt"
+ << "installcontentD_update.txt");
+ VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentA", "1.0.0content.txt");
+ //As we are using the same core in tests, clean the essentalupdate value
+ core->setFoundEssentialUpdate(false);
+ }
+
+ void testUpdatePackageSilently()
+ {
+ setRepository(":///data/installPackagesRepository");
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << "componentB"));
+ QCOMPARE(PackageManagerCore::Success, core->status());
+ //Because of bug QTIFW-1970 componentD got uninstalled. It should be installed now
+ //as its dependencies are installed.
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "2.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt");
+ VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml"
+ << "installcontentA_update.txt" << "installcontentE.txt" << "installcontentG.txt"
+ << "installcontentB.txt");
core->commitSessionOperations();
setRepository(":///data/installPackagesRepositoryUpdate");
- core->updateComponentsSilently(QStringList() << "componentA");
+ QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList()
+ << "componentB"));
// componentD is autodependent and cannot be deselected
// componentE is a forced component and thus will be updated
VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "2.0.0content.txt");
- VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "2.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentD", "2.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentE", "2.0.0content.txt");
- VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentA", "1.0.0content.txt");
+
VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentD", "1.0.0content.txt");
VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentE", "1.0.0content.txt");
VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentA_update.txt"
<< "installcontentE_update.txt" << "installcontentG.txt"
- << "installcontentB.txt" << "installcontentD_update.txt");
+ << "installcontentB_update.txt" << "installcontentD_update.txt");
}
void testUpdateNoUpdatesForSelectedPackage()
{
setRepository(":///data/installPackagesRepositoryUpdate");
// Succeeds as no updates available for component so nothing to do
- QVERIFY(core->updateComponentsSilently(QStringList() << "componentInvalid"));
+ QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList()
+ << "componentInvalid"));
}
void testUpdateTwoPackageSilently()
{
setRepository(":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << "componentA" << "componentB" << "componentG");
- VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt");
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << "componentA" << "componentB" << "componentG"));
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "2.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt");
core->commitSessionOperations();
setRepository(":///data/installPackagesRepositoryUpdate");
- core->updateComponentsSilently(QStringList() << "componentB" << "componentG");
+ QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList()
+ << "componentB" << "componentG"));
VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "2.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "2.0.0content.txt");
VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentB", "1.0.0content.txt");
@@ -113,7 +156,8 @@ private slots:
void testUpdateAllPackagesSilently()
{
setRepository(":///data/installPackagesRepository");
- core->installSelectedComponentsSilently(QStringList() << "componentA" << "componentB" << "componentG" << "componentF");
+ QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ << "componentA" << "componentB" << "componentG" << "componentF"));
VerifyInstaller::verifyInstallerResources(m_installDir, "componentF", "1.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentF.subcomponent1", "1.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentF.subcomponent1.subsubcomponent1", "1.0.0content.txt");
@@ -121,7 +165,7 @@ private slots:
core->commitSessionOperations();
setRepository(":///data/installPackagesRepositoryUpdate");
- core->updateComponentsSilently(QStringList());
+ QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList()));
VerifyInstaller::verifyInstallerResources(m_installDir, "componentF", "2.0.0content.txt");
VerifyInstaller::verifyInstallerResources(m_installDir, "componentF.subcomponent2", "2.0.0content.txt");
VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentF", "1.0.0content.txt");
diff --git a/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp b/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp
index c8b970170..dafcd2676 100644
--- a/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp
+++ b/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp
@@ -302,7 +302,8 @@ private slots:
const QRegularExpression re(warningMessage);
QTest::ignoreMessage(QtWarningMsg, re);
QTest::ignoreMessage(QtDebugMsg, "No updates available.");
- core.updateComponentsSilently(QStringList());
+
+ QCOMPARE(PackageManagerCore::Failure, core.updateComponentsSilently(QStringList()));
QVERIFY(QDir().rmdir(testDirectory));
}