forked from qt-creator/qt-creator
sdktool: Change tests to use QTest
* Moved all sdktool code into a static library, allowing us to link against the actual functionality in unittests * Convert all tests to proper unittests Change-Id: I5c93be0faecbd8b68e0923655483c870a2f408b5 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -33,12 +33,12 @@ set(UtilsSourcesDir "../../libs/utils")
|
|||||||
|
|
||||||
file(RELATIVE_PATH DATA_PATH "/${IDE_LIBEXEC_PATH}" "/${IDE_DATA_PATH}")
|
file(RELATIVE_PATH DATA_PATH "/${IDE_LIBEXEC_PATH}" "/${IDE_DATA_PATH}")
|
||||||
|
|
||||||
add_qtc_executable(sdktool
|
add_qtc_library(sdktoolLib
|
||||||
${DESTINATION}
|
STATIC
|
||||||
DEFINES DATA_PATH=\"${DATA_PATH}\"
|
DEFINES DATA_PATH=\"${DATA_PATH}\"
|
||||||
DEPENDS Qt5::Core
|
PUBLIC_DEPENDS Qt5::Core
|
||||||
|
PUBLIC_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} "${UtilsSourcesDir}/../"
|
||||||
INCLUDES
|
INCLUDES
|
||||||
"${UtilsSourcesDir}/../"
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
SOURCES
|
SOURCES
|
||||||
addabiflavor.cpp addabiflavor.h
|
addabiflavor.cpp addabiflavor.h
|
||||||
@@ -53,7 +53,6 @@ add_qtc_executable(sdktool
|
|||||||
findkeyoperation.cpp findkeyoperation.h
|
findkeyoperation.cpp findkeyoperation.h
|
||||||
findvalueoperation.cpp findvalueoperation.h
|
findvalueoperation.cpp findvalueoperation.h
|
||||||
getoperation.cpp getoperation.h
|
getoperation.cpp getoperation.h
|
||||||
main.cpp
|
|
||||||
operation.cpp operation.h
|
operation.cpp operation.h
|
||||||
rmcmakeoperation.cpp rmcmakeoperation.h
|
rmcmakeoperation.cpp rmcmakeoperation.h
|
||||||
rmdebuggeroperation.cpp rmdebuggeroperation.h
|
rmdebuggeroperation.cpp rmdebuggeroperation.h
|
||||||
@@ -65,15 +64,7 @@ add_qtc_executable(sdktool
|
|||||||
settings.cpp settings.h
|
settings.cpp settings.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if (MSVC AND TARGET sdktool)
|
extend_qtc_library(sdktoolLib
|
||||||
# find out if Qt is static and set /MT if so
|
|
||||||
get_target_property(_input_type Qt5::Core TYPE)
|
|
||||||
if (${_input_type} STREQUAL "STATIC_LIBRARY")
|
|
||||||
set_property(TARGET sdktool PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
extend_qtc_executable(sdktool
|
|
||||||
SOURCES_PREFIX "${UtilsSourcesDir}"
|
SOURCES_PREFIX "${UtilsSourcesDir}"
|
||||||
DEFINES QTCREATOR_UTILS_STATIC_LIB
|
DEFINES QTCREATOR_UTILS_STATIC_LIB
|
||||||
SOURCES
|
SOURCES
|
||||||
@@ -92,18 +83,37 @@ extend_qtc_executable(sdktool
|
|||||||
stringutils.cpp stringutils.h
|
stringutils.cpp stringutils.h
|
||||||
)
|
)
|
||||||
|
|
||||||
extend_qtc_executable(sdktool CONDITION APPLE
|
extend_qtc_library(sdktoolLib CONDITION APPLE
|
||||||
SOURCES_PREFIX "${UtilsSourcesDir}"
|
SOURCES_PREFIX "${UtilsSourcesDir}"
|
||||||
SOURCES
|
SOURCES
|
||||||
fileutils_mac.mm fileutils_mac.h
|
fileutils_mac.mm fileutils_mac.h
|
||||||
DEPENDS
|
PUBLIC_DEPENDS
|
||||||
${FWFoundation}
|
${FWFoundation}
|
||||||
)
|
)
|
||||||
|
|
||||||
extend_qtc_executable(sdktool CONDITION WIN32
|
extend_qtc_library(sdktoolLib CONDITION WIN32
|
||||||
DEPENDS
|
PUBLIC_DEPENDS
|
||||||
user32 iphlpapi ws2_32 shell32
|
user32 iphlpapi ws2_32 shell32
|
||||||
DEFINES
|
DEFINES
|
||||||
_UNICODE UNICODE
|
_UNICODE UNICODE
|
||||||
_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS
|
_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_qtc_executable(sdktool
|
||||||
|
${DESTINATION}
|
||||||
|
DEFINES DATA_PATH=\"${DATA_PATH}\"
|
||||||
|
DEPENDS sdktoolLib
|
||||||
|
INCLUDES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
SOURCES
|
||||||
|
main.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
if (MSVC AND TARGET sdktool)
|
||||||
|
# find out if Qt is static and set /MT if so
|
||||||
|
get_target_property(_input_type Qt5::Core TYPE)
|
||||||
|
if (${_input_type} STREQUAL "STATIC_LIBRARY")
|
||||||
|
set_property(TARGET sdktool PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
@@ -33,10 +33,14 @@
|
|||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(addAbiFlavorLog, "qtc.sdktool.operations.addabiflavor", QtWarningMsg)
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
const char VERSION[] = "Version";
|
const char VERSION[] = "Version";
|
||||||
@@ -66,7 +70,7 @@ bool AddAbiFlavor::setArguments(const QStringList &args)
|
|||||||
const QString next = ((i + 1) < args.count()) ? args.at(i + 1) : QString();
|
const QString next = ((i + 1) < args.count()) ? args.at(i + 1) : QString();
|
||||||
|
|
||||||
if (next.isNull() && current.startsWith("--")) {
|
if (next.isNull() && current.startsWith("--")) {
|
||||||
std::cerr << "No parameter for option '" << qPrintable(current) << "' given." << std::endl << std::endl;
|
qCCritical(addAbiFlavorLog) << "No parameter for option '" << qPrintable(current) << "' given.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,15 +86,15 @@ bool AddAbiFlavor::setArguments(const QStringList &args)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr << "Unknown parameter: " << qPrintable(current) << std::endl << std::endl;
|
qCCritical(addAbiFlavorLog) << "Unknown parameter: " << qPrintable(current);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_flavor.isEmpty())
|
if (m_flavor.isEmpty())
|
||||||
std::cerr << "Error no flavor was passed." << std::endl << std::endl;
|
qCCritical(addAbiFlavorLog) << "Error no flavor was passed.";
|
||||||
|
|
||||||
if (m_oses.isEmpty())
|
if (m_oses.isEmpty())
|
||||||
std::cerr << "Error no OSes name was passed." << std::endl << std::endl;
|
qCCritical(addAbiFlavorLog) << "Error no OSes name was passed.";
|
||||||
|
|
||||||
return !m_flavor.isEmpty() && !m_oses.isEmpty();
|
return !m_flavor.isEmpty() && !m_oses.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -110,38 +114,31 @@ int AddAbiFlavor::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool AddAbiFlavor::test() const
|
void AddAbiFlavor::unittest()
|
||||||
{
|
{
|
||||||
QVariantMap map = initializeAbiFlavors();
|
QVariantMap map = initializeAbiFlavors();
|
||||||
if (map.count() != 1)
|
QCOMPARE(map.count(), 1);
|
||||||
return false;
|
QVERIFY(map.contains(QLatin1String(VERSION)));
|
||||||
if (!map.contains(QLatin1String(VERSION)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
map = AddAbiFlavorData{{"linux", "windows"}, "foo"}.addAbiFlavor(map);
|
AddAbiFlavorData d;
|
||||||
|
d.m_oses = {"linux", "windows"};
|
||||||
|
d.m_flavor = "foo";
|
||||||
|
map = d.addAbiFlavor(map);
|
||||||
|
|
||||||
if (map.count() != 2)
|
QCOMPARE(map.count(), 2);
|
||||||
return false;
|
QVERIFY(map.contains(QLatin1String(VERSION)));
|
||||||
if (!map.contains(QLatin1String(VERSION)))
|
QVERIFY(map.contains(QLatin1String(FLAVORS)));
|
||||||
return false;
|
|
||||||
if (!map.contains(QLatin1String(FLAVORS)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
const QVariantMap flavorMap = map.value(QLatin1String(FLAVORS)).toMap();
|
const QVariantMap flavorMap = map.value(QLatin1String(FLAVORS)).toMap();
|
||||||
if (flavorMap.count() != 1)
|
QCOMPARE(flavorMap.count(), 1);
|
||||||
return false;
|
QCOMPARE(flavorMap.value("foo").toStringList(), QStringList({"linux", "windows"}));
|
||||||
if (flavorMap.value("foo").toStringList() != QStringList({"linux", "windows"}))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Ignore known flavors:
|
// Ignore known flavors:
|
||||||
QTest::ignoreMessage(QtWarningMsg,
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
QRegularExpression("Error: flavor .* already defined as extra ABI flavor."));
|
QRegularExpression("Error: flavor .* already defined as extra ABI flavor."));
|
||||||
const QVariantMap result = AddAbiFlavorData({{"linux"}, "foo"}).addAbiFlavor(map);
|
const QVariantMap result = AddAbiFlavorData({{"linux"}, "foo"}).addAbiFlavor(map);
|
||||||
|
|
||||||
if (map != result)
|
QCOMPARE(map, result);
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -149,7 +146,7 @@ QVariantMap AddAbiFlavorData::addAbiFlavor(const QVariantMap &map) const
|
|||||||
{
|
{
|
||||||
// Sanity check: Is flavor already set in abi file?
|
// Sanity check: Is flavor already set in abi file?
|
||||||
if (exists(map, m_flavor)) {
|
if (exists(map, m_flavor)) {
|
||||||
std::cerr << "Error: flavor " << qPrintable(m_flavor) << " already defined as extra ABI flavor." << std::endl;
|
qCCritical(addAbiFlavorLog) << "Error: flavor" << qPrintable(m_flavor) << "already defined as extra ABI flavor.";
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,6 +53,6 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@@ -33,7 +33,13 @@
|
|||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include <iostream>
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(addCMakeOperationLog, "qtc.sdktool.operations.addcmake", QtWarningMsg)
|
||||||
|
|
||||||
// CMakeTools file stuff:
|
// CMakeTools file stuff:
|
||||||
const char COUNT[] = "CMakeTools.Count";
|
const char COUNT[] = "CMakeTools.Count";
|
||||||
@@ -72,7 +78,7 @@ bool AddCMakeOperation::setArguments(const QStringList &args)
|
|||||||
const QString next = ((i + 1) < args.count()) ? args.at(i + 1) : QString();
|
const QString next = ((i + 1) < args.count()) ? args.at(i + 1) : QString();
|
||||||
|
|
||||||
if (next.isNull() && current.startsWith("--")) {
|
if (next.isNull() && current.startsWith("--")) {
|
||||||
std::cerr << "No parameter for option '" << qPrintable(current) << "' given." << std::endl << std::endl;
|
qCCritical(addCMakeOperationLog) << "No parameter for option '" << qPrintable(current) << "' given.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,24 +100,24 @@ bool AddCMakeOperation::setArguments(const QStringList &args)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (next.isNull()) {
|
if (next.isNull()) {
|
||||||
std::cerr << "No value given for key '" << qPrintable(current) << "'.";
|
qCCritical(addCMakeOperationLog) << "No value given for key '" << qPrintable(current) << "'.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++i; // skip next;
|
++i; // skip next;
|
||||||
KeyValuePair pair(current, next);
|
KeyValuePair pair(current, next);
|
||||||
if (!pair.value.isValid()) {
|
if (!pair.value.isValid()) {
|
||||||
std::cerr << "Value for key '" << qPrintable(current) << "' is not valid.";
|
qCCritical(addCMakeOperationLog) << "Value for key '" << qPrintable(current) << "' is not valid.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_extra << pair;
|
m_extra << pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_id.isEmpty())
|
if (m_id.isEmpty())
|
||||||
std::cerr << "No id given for cmake tool." << std::endl;
|
qCCritical(addCMakeOperationLog) << "No id given for cmake tool.";
|
||||||
if (m_displayName.isEmpty())
|
if (m_displayName.isEmpty())
|
||||||
std::cerr << "No name given for cmake tool." << std::endl;
|
qCCritical(addCMakeOperationLog) << "No name given for cmake tool.";
|
||||||
if (m_path.isEmpty())
|
if (m_path.isEmpty())
|
||||||
std::cerr << "No path given for cmake tool." << std::endl;
|
qCCritical(addCMakeOperationLog) << "No path given for cmake tool.";
|
||||||
|
|
||||||
return !m_id.isEmpty() && !m_displayName.isEmpty() && !m_path.isEmpty();
|
return !m_id.isEmpty() && !m_displayName.isEmpty() && !m_path.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -130,55 +136,69 @@ int AddCMakeOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool AddCMakeOperation::test() const
|
void AddCMakeOperation::unittest()
|
||||||
{
|
{
|
||||||
QVariantMap map = initializeCMake();
|
QVariantMap map = initializeCMake();
|
||||||
|
|
||||||
// Add toolchain:
|
// Add toolchain:
|
||||||
map = AddCMakeData{"testId", "name", "/tmp/test", {{"ExtraKey", QVariant("ExtraValue")}}}.addCMake(map);
|
AddCMakeData d;
|
||||||
if (map.value(COUNT).toInt() != 1
|
d.m_id = "testId";
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '0'))
|
d.m_displayName = "name";
|
||||||
return false;
|
d.m_path = "/tmp/test";
|
||||||
|
d.m_extra = {{"ExtraKey", QVariant("ExtraValue")}};
|
||||||
|
map = d.addCMake(map);
|
||||||
|
|
||||||
|
QCOMPARE(map.value(COUNT).toInt(), 1);
|
||||||
|
QVERIFY(map.contains(QString::fromLatin1(PREFIX) + '0'));
|
||||||
|
|
||||||
QVariantMap cmData = map.value(QString::fromLatin1(PREFIX) + '0').toMap();
|
QVariantMap cmData = map.value(QString::fromLatin1(PREFIX) + '0').toMap();
|
||||||
if (cmData.count() != 5
|
QCOMPARE(cmData.count(), 5);
|
||||||
|| cmData.value(ID_KEY).toString() != "testId"
|
QCOMPARE(cmData.value(ID_KEY).toString(), "testId");
|
||||||
|| cmData.value(DISPLAYNAME_KEY).toString() != "name"
|
QCOMPARE(cmData.value(DISPLAYNAME_KEY).toString(), "name");
|
||||||
|| cmData.value(AUTODETECTED_KEY).toBool() != true
|
QCOMPARE(cmData.value(AUTODETECTED_KEY).toBool(), true);
|
||||||
|| cmData.value(PATH_KEY).toString() != "/tmp/test"
|
QCOMPARE(cmData.value(PATH_KEY).toString(), "/tmp/test");
|
||||||
|| cmData.value("ExtraKey").toString() != "ExtraValue")
|
QCOMPARE(cmData.value("ExtraKey").toString(), "ExtraValue");
|
||||||
return false;
|
|
||||||
|
|
||||||
// Ignore same Id:
|
// Ignore same Id:
|
||||||
QVariantMap unchanged = AddCMakeData{"testId", "name2", "/tmp/test2", {{"ExtraKey", QVariant("ExtraValue2")}}}
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
.addCMake(map);
|
QRegularExpression("Error: Id .* already defined for tool chains."));
|
||||||
if (!unchanged.isEmpty())
|
|
||||||
return false;
|
AddCMakeData ud;
|
||||||
|
ud.m_id = "testId";
|
||||||
|
ud.m_displayName = "name2";
|
||||||
|
ud.m_path = "/tmp/test2";
|
||||||
|
ud.m_extra = {{"ExtraKey", QVariant("ExtraValue2")}};
|
||||||
|
|
||||||
|
QVariantMap unchanged = ud.addCMake(map);
|
||||||
|
QVERIFY(unchanged.isEmpty());
|
||||||
|
|
||||||
// add 2nd cmake
|
// add 2nd cmake
|
||||||
map = AddCMakeData{"{some-cm-id}", "name", "/tmp/test", {{"ExtraKey", QVariant("ExtraValue")}}}
|
AddCMakeData d2;
|
||||||
.addCMake(map);
|
d2.m_id = "{some-cm-id}",
|
||||||
if (map.value(COUNT).toInt() != 2
|
d2.m_displayName = "name";
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '0')
|
d2.m_path = "/tmp/test";
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '1'))
|
d2.m_extra = {{"ExtraKey", QVariant("ExtraValue")}};
|
||||||
return false;
|
map = d2.addCMake(map);
|
||||||
cmData = map.value(QString::fromLatin1(PREFIX) + '0').toMap();
|
|
||||||
if (cmData.count() != 5
|
|
||||||
|| cmData.value(ID_KEY).toString() != "testId"
|
|
||||||
|| cmData.value(DISPLAYNAME_KEY).toString() != "name"
|
|
||||||
|| cmData.value(AUTODETECTED_KEY).toBool() != true
|
|
||||||
|| cmData.value(PATH_KEY).toString() != "/tmp/test"
|
|
||||||
|| cmData.value("ExtraKey").toString() != "ExtraValue")
|
|
||||||
return false;
|
|
||||||
cmData = map.value(QString::fromLatin1(PREFIX) + '1').toMap();
|
|
||||||
if (cmData.count() != 5
|
|
||||||
|| cmData.value(ID_KEY).toString() != "{some-cm-id}"
|
|
||||||
|| cmData.value(DISPLAYNAME_KEY).toString() != "name"
|
|
||||||
|| cmData.value(AUTODETECTED_KEY).toBool() != true
|
|
||||||
|| cmData.value(PATH_KEY).toString() != "/tmp/test"
|
|
||||||
|| cmData.value("ExtraKey").toString() != "ExtraValue")
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
QCOMPARE(map.value(COUNT).toInt(), 2);
|
||||||
|
QVERIFY(map.contains(QString::fromLatin1(PREFIX) + '0'));
|
||||||
|
QVERIFY(map.contains(QString::fromLatin1(PREFIX) + '1'));
|
||||||
|
|
||||||
|
cmData = map.value(QString::fromLatin1(PREFIX) + '0').toMap();
|
||||||
|
QCOMPARE(cmData.count(), 5);
|
||||||
|
QCOMPARE(cmData.value(ID_KEY).toString(), "testId");
|
||||||
|
QCOMPARE(cmData.value(DISPLAYNAME_KEY).toString(), "name");
|
||||||
|
QVERIFY(cmData.value(AUTODETECTED_KEY).toBool());
|
||||||
|
QCOMPARE(cmData.value(PATH_KEY).toString(), "/tmp/test");
|
||||||
|
QCOMPARE(cmData.value("ExtraKey").toString(), "ExtraValue");
|
||||||
|
|
||||||
|
cmData = map.value(QString::fromLatin1(PREFIX) + '1').toMap();
|
||||||
|
QCOMPARE(cmData.count(), 5);
|
||||||
|
QCOMPARE(cmData.value(ID_KEY).toString(), "{some-cm-id}");
|
||||||
|
QCOMPARE(cmData.value(DISPLAYNAME_KEY).toString(), "name");
|
||||||
|
QVERIFY(cmData.value(AUTODETECTED_KEY).toBool());
|
||||||
|
QCOMPARE(cmData.value(PATH_KEY).toString(), "/tmp/test");
|
||||||
|
QCOMPARE(cmData.value("ExtraKey").toString(), "ExtraValue");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -186,7 +206,7 @@ QVariantMap AddCMakeData::addCMake(const QVariantMap &map) const
|
|||||||
{
|
{
|
||||||
// Sanity check: Does the Id already exist?
|
// Sanity check: Does the Id already exist?
|
||||||
if (exists(map, m_id)) {
|
if (exists(map, m_id)) {
|
||||||
std::cerr << "Error: Id " << qPrintable(m_id) << " already defined for tool chains." << std::endl;
|
qCCritical(addCMakeOperationLog) << "Error: Id" << qPrintable(m_id) << "already defined for tool chains.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +214,7 @@ QVariantMap AddCMakeData::addCMake(const QVariantMap &map) const
|
|||||||
bool ok;
|
bool ok;
|
||||||
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
||||||
if (!ok || count < 0) {
|
if (!ok || count < 0) {
|
||||||
std::cerr << "Error: Count found in toolchains file seems wrong." << std::endl;
|
qCCritical(addCMakeOperationLog) << "Error: Count found in toolchains file seems wrong.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,6 +55,6 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@@ -33,7 +33,13 @@
|
|||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include <iostream>
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(addDebuggerOperationLog, "qtc.sdktool.operations.adddebugger", QtWarningMsg)
|
||||||
|
|
||||||
const char VERSION[] = "Version";
|
const char VERSION[] = "Version";
|
||||||
const char COUNT[] = "DebuggerItem.Count";
|
const char COUNT[] = "DebuggerItem.Count";
|
||||||
@@ -96,7 +102,7 @@ bool AddDebuggerOperation::setArguments(const QStringList &args)
|
|||||||
bool ok;
|
bool ok;
|
||||||
m_engine = next.toInt(&ok);
|
m_engine = next.toInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
std::cerr << "Debugger type is not an integer!" << std::endl;
|
qCCritical(addDebuggerOperationLog) << "Debugger type is not an integer!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@@ -128,12 +134,10 @@ bool AddDebuggerOperation::setArguments(const QStringList &args)
|
|||||||
m_extra << pair;
|
m_extra << pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (m_id.isEmpty())
|
if (m_id.isEmpty())
|
||||||
std::cerr << "No id given for kit." << std::endl << std::endl;
|
qCCritical(addDebuggerOperationLog) << "No id given for kit.";
|
||||||
if (m_displayName.isEmpty())
|
if (m_displayName.isEmpty())
|
||||||
std::cerr << "No name given for kit." << std::endl << std::endl;
|
qCCritical(addDebuggerOperationLog) << "No name given for kit.";
|
||||||
|
|
||||||
return !m_id.isEmpty() && !m_displayName.isEmpty();
|
return !m_id.isEmpty() && !m_displayName.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -153,18 +157,50 @@ int AddDebuggerOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool AddDebuggerOperation::test() const
|
void AddDebuggerOperation::unittest()
|
||||||
{
|
{
|
||||||
QVariantMap map = initializeDebuggers();
|
QVariantMap map = initializeDebuggers();
|
||||||
|
|
||||||
if (map.count() != 2
|
QCOMPARE(map.count(), 2);
|
||||||
|| !map.contains(QLatin1String(VERSION))
|
|
||||||
|| map.value(QLatin1String(VERSION)).toInt() != 1
|
|
||||||
|| !map.contains(QLatin1String(COUNT))
|
|
||||||
|| map.value(QLatin1String(COUNT)).toInt() != 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
QVERIFY(map.contains(QLatin1String(VERSION)));
|
||||||
|
QCOMPARE(map.value(QLatin1String(VERSION)).toInt(), 1);
|
||||||
|
QVERIFY(map.contains(QLatin1String(COUNT)));
|
||||||
|
QCOMPARE(map.value(QLatin1String(COUNT)).toInt(), 0);
|
||||||
|
|
||||||
|
AddDebuggerData d;
|
||||||
|
d.m_id = "testId";
|
||||||
|
d.m_displayName = "name";
|
||||||
|
d.m_binary = "/tmp/bin/gdb";
|
||||||
|
d.m_abis = {"aarch64", "x86_64"};
|
||||||
|
d.m_extra = {{"ExtraKey", QVariant("ExtraValue")}};
|
||||||
|
map = d.addDebugger(map);
|
||||||
|
|
||||||
|
QCOMPARE(map.value(COUNT).toInt(), 1);
|
||||||
|
QVERIFY(map.contains(QString::fromLatin1(PREFIX) + '0'));
|
||||||
|
|
||||||
|
QVariantMap dbgData = map.value(QString::fromLatin1(PREFIX) + '0').toMap();
|
||||||
|
QCOMPARE(dbgData.count(), 7);
|
||||||
|
QCOMPARE(dbgData.value(ID).toString(), "testId");
|
||||||
|
QCOMPARE(dbgData.value(DISPLAYNAME).toString(), "name");
|
||||||
|
QCOMPARE(dbgData.value(AUTODETECTED).toBool(), true);
|
||||||
|
QCOMPARE(dbgData.value(ABIS).toStringList(), (QStringList{"aarch64", "x86_64"}));
|
||||||
|
QCOMPARE(dbgData.value(BINARY).toString(), "/tmp/bin/gdb");
|
||||||
|
QCOMPARE(dbgData.value(ENGINE_TYPE).toInt(), 0);
|
||||||
|
QCOMPARE(dbgData.value("ExtraKey").toString(), "ExtraValue");
|
||||||
|
|
||||||
|
// Ignore existing.
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
|
QRegularExpression("Error: Id .* already defined as debugger."));
|
||||||
|
|
||||||
|
AddDebuggerData d2;
|
||||||
|
d2.m_id = "testId";
|
||||||
|
d2.m_displayName = "name2";
|
||||||
|
d2.m_binary = "/tmp/bin/gdb";
|
||||||
|
d2.m_abis = {};
|
||||||
|
d2.m_extra = {{"ExtraKey", QVariant("ExtraValue2")}};
|
||||||
|
QVariantMap unchanged = d2.addDebugger(map);
|
||||||
|
QVERIFY(unchanged.isEmpty());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -180,7 +216,7 @@ QVariantMap AddDebuggerData::addDebugger(const QVariantMap &map) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasId) {
|
if (hasId) {
|
||||||
std::cerr << "Error: Id " << qPrintable(m_id) << " already defined as debugger." << std::endl;
|
qCCritical(addDebuggerOperationLog) << "Error: Id" << qPrintable(m_id) << "already defined as debugger.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +224,7 @@ QVariantMap AddDebuggerData::addDebugger(const QVariantMap &map) const
|
|||||||
bool ok;
|
bool ok;
|
||||||
int count = GetOperation::get(map, QLatin1String(COUNT)).toInt(&ok);
|
int count = GetOperation::get(map, QLatin1String(COUNT)).toInt(&ok);
|
||||||
if (!ok || count < 0) {
|
if (!ok || count < 0) {
|
||||||
std::cerr << "Error: Count found in debuggers file seems wrong." << std::endl;
|
qCCritical(addDebuggerOperationLog) << "Error: Count found in debuggers file seems wrong.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
const QString debugger = QString::fromLatin1(PREFIX) + QString::number(count);
|
const QString debugger = QString::fromLatin1(PREFIX) + QString::number(count);
|
||||||
|
@@ -54,6 +54,6 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@@ -33,7 +33,13 @@
|
|||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(addDeviceLog, "qtc.sdktool.operations.adddevice", QtWarningMsg)
|
||||||
|
|
||||||
const char DEVICEMANAGER_ID[] = "DeviceManager";
|
const char DEVICEMANAGER_ID[] = "DeviceManager";
|
||||||
const char DEFAULT_DEVICES_ID[] = "DefaultDevices";
|
const char DEFAULT_DEVICES_ID[] = "DefaultDevices";
|
||||||
@@ -261,9 +267,9 @@ bool AddDeviceOperation::setArguments(const QStringList &args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_id.isEmpty())
|
if (m_id.isEmpty())
|
||||||
std::cerr << "No id given for device." << std::endl << std::endl;
|
qCCritical(addDeviceLog) << "No id given for device.";
|
||||||
if (m_displayName.isEmpty())
|
if (m_displayName.isEmpty())
|
||||||
std::cerr << "No name given for device." << std::endl << std::endl;
|
qCCritical(addDeviceLog) << "No name given for device.";
|
||||||
|
|
||||||
return !m_id.isEmpty() && !m_displayName.isEmpty() && m_type >= 0;
|
return !m_id.isEmpty() && !m_displayName.isEmpty() && m_type >= 0;
|
||||||
}
|
}
|
||||||
@@ -283,7 +289,7 @@ int AddDeviceOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool AddDeviceOperation::test() const
|
void AddDeviceOperation::unittest()
|
||||||
{
|
{
|
||||||
QVariantMap map = initializeDevices();
|
QVariantMap map = initializeDevices();
|
||||||
|
|
||||||
@@ -305,57 +311,37 @@ bool AddDeviceOperation::test() const
|
|||||||
devData.m_timeout = 5;
|
devData.m_timeout = 5;
|
||||||
devData.m_uname = "uname";
|
devData.m_uname = "uname";
|
||||||
devData.m_version = 6;
|
devData.m_version = 6;
|
||||||
|
devData.m_dockerMappedPaths = QStringList{"/opt", "/data"};
|
||||||
devData.m_dockerRepo = "repo";
|
devData.m_dockerRepo = "repo";
|
||||||
devData.m_dockerTag = "tag";
|
devData.m_dockerTag = "tag";
|
||||||
devData.m_dockerMappedPaths = QStringList{"/opt", "/data"};
|
|
||||||
|
|
||||||
QVariantMap result = devData.addDevice(map);
|
QVariantMap result = devData.addDevice(map);
|
||||||
QVariantMap data = result.value(QLatin1String(DEVICEMANAGER_ID)).toMap();
|
QVariantMap data = result.value(QLatin1String(DEVICEMANAGER_ID)).toMap();
|
||||||
QVariantList devList = data.value(QLatin1String(DEVICE_LIST_ID)).toList();
|
QVariantList devList = data.value(QLatin1String(DEVICE_LIST_ID)).toList();
|
||||||
if (devList.count() != 1)
|
QCOMPARE(devList.count(), 1);
|
||||||
return false;
|
|
||||||
QVariantMap dev = devList.at(0).toMap();
|
QVariantMap dev = devList.at(0).toMap();
|
||||||
if (dev.count() != 20)
|
QCOMPARE(dev.count(), 20);
|
||||||
return false;
|
QCOMPARE(dev.value(QLatin1String("Authentication")).toInt(), 2);
|
||||||
if (dev.value(QLatin1String("Authentication")).toInt() != 2)
|
QCOMPARE(dev.value(QLatin1String("DebugServerKey")).toString(), QLatin1String("debugServer"));
|
||||||
return false;
|
QCOMPARE(dev.value(QLatin1String("FreePortsSpec")).toString(), QLatin1String("ports"));
|
||||||
if (dev.value(QLatin1String("DebugServerKey")).toString() != QLatin1String("debugServer"))
|
QCOMPARE(dev.value(QLatin1String("Host")).toString(), QLatin1String("host"));
|
||||||
return false;
|
QCOMPARE(dev.value(QLatin1String("InternalId")).toString(), QLatin1String("test id"));
|
||||||
if (dev.value(QLatin1String("FreePortsSpec")).toString() != QLatin1String("ports"))
|
QCOMPARE(dev.value(QLatin1String("KeyFile")).toString(), QLatin1String("keyfile"));
|
||||||
return false;
|
QCOMPARE(dev.value(QLatin1String("Name")).toString(), QLatin1String("test name"));
|
||||||
if (dev.value(QLatin1String("Host")).toString() != QLatin1String("host"))
|
QCOMPARE(dev.value(QLatin1String("Origin")).toInt(), 3);
|
||||||
return false;
|
QCOMPARE(dev.value(QLatin1String("OsType")).toString(), QLatin1String("ostype"));
|
||||||
if (dev.value(QLatin1String("InternalId")).toString() != QLatin1String("test id"))
|
QCOMPARE(dev.value(QLatin1String("Password")).toString(), QLatin1String("passwd"));
|
||||||
return false;
|
QCOMPARE(dev.value(QLatin1String("SshPort")).toInt(), 4);
|
||||||
if (dev.value(QLatin1String("KeyFile")).toString() != QLatin1String("keyfile"))
|
QCOMPARE(dev.value(QLatin1String("Timeout")).toInt(), 5);
|
||||||
return false;
|
QCOMPARE(dev.value(QLatin1String("Type")).toInt(), 1);
|
||||||
if (dev.value(QLatin1String("Name")).toString() != QLatin1String("test name"))
|
QCOMPARE(dev.value(QLatin1String("Uname")).toString(), QLatin1String("uname"));
|
||||||
return false;
|
QCOMPARE(dev.value(QLatin1String("Version")).toInt(), 6);
|
||||||
if (dev.value(QLatin1String("Origin")).toInt() != 3)
|
QCOMPARE(dev.value(QLatin1String("DockerDeviceDataRepo")).toString(), "repo");
|
||||||
return false;
|
QCOMPARE(dev.value(QLatin1String("DockerDeviceDataTag")).toString(), "tag");
|
||||||
if (dev.value(QLatin1String("OsType")).toString() != QLatin1String("ostype"))
|
|
||||||
return false;
|
|
||||||
if (dev.value(QLatin1String("Password")).toString() != QLatin1String("passwd"))
|
|
||||||
return false;
|
|
||||||
if (dev.value(QLatin1String("SshPort")).toInt() != 4)
|
|
||||||
return false;
|
|
||||||
if (dev.value(QLatin1String("Timeout")).toInt() != 5)
|
|
||||||
return false;
|
|
||||||
if (dev.value(QLatin1String("Type")).toInt() != 1)
|
|
||||||
return false;
|
|
||||||
if (dev.value(QLatin1String("Uname")).toString() != QLatin1String("uname"))
|
|
||||||
return false;
|
|
||||||
if (dev.value(QLatin1String("Version")).toInt() != 6)
|
|
||||||
return false;
|
|
||||||
if (dev.value(QLatin1String("DockerDeviceDataRepo")).toString() != "repo")
|
|
||||||
return false;
|
|
||||||
if (dev.value(QLatin1String("DockerDeviceDataTag")).toString() != "tag")
|
|
||||||
return false;
|
|
||||||
const QStringList paths = dev.value(QLatin1String("DockerDeviceMappedPaths")).toStringList();
|
|
||||||
if (paths != QStringList({"/opt", "/data"}))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
const QStringList paths = dev.value(QLatin1String("DockerDeviceMappedPaths")).toStringList();
|
||||||
|
QCOMPARE(paths, QStringList({"/opt", "/data"}));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -363,7 +349,7 @@ QVariantMap AddDeviceData::addDevice(const QVariantMap &map) const
|
|||||||
{
|
{
|
||||||
QVariantMap result = map;
|
QVariantMap result = map;
|
||||||
if (exists(map, m_id)) {
|
if (exists(map, m_id)) {
|
||||||
std::cerr << "Device " << qPrintable(m_id) << " already exists!" << std::endl;
|
qCCritical(addDeviceLog) << "Device " << qPrintable(m_id) << " already exists!";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -80,6 +80,6 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@@ -27,6 +27,14 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(addkeyslog, "qtc.sdktool.operations.addkeys", QtWarningMsg)
|
||||||
|
|
||||||
QString AddKeysOperation::name() const
|
QString AddKeysOperation::name() const
|
||||||
{
|
{
|
||||||
return QLatin1String("addKeys");
|
return QLatin1String("addKeys");
|
||||||
@@ -39,7 +47,8 @@ QString AddKeysOperation::helpText() const
|
|||||||
|
|
||||||
QString AddKeysOperation::argumentsHelpText() const
|
QString AddKeysOperation::argumentsHelpText() const
|
||||||
{
|
{
|
||||||
return QLatin1String("A file (relative to top-level settings directory and without .xml extension)\n"
|
return QLatin1String(
|
||||||
|
"A file (relative to top-level settings directory and without .xml extension)\n"
|
||||||
"followed by one or more Tuples <KEY> <TYPE>:<VALUE> are required.\n");
|
"followed by one or more Tuples <KEY> <TYPE>:<VALUE> are required.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +64,7 @@ bool AddKeysOperation::setArguments(const QStringList &args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (next.isNull()) {
|
if (next.isNull()) {
|
||||||
std::cerr << "Missing value for key '" << qPrintable(current) << "'." << std::endl << std::endl;
|
qCCritical(addkeyslog) << "Missing value for key '" << qPrintable(current) << "'.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +94,7 @@ int AddKeysOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool AddKeysOperation::test() const
|
void AddKeysOperation::unittest()
|
||||||
{
|
{
|
||||||
QVariantMap testMap;
|
QVariantMap testMap;
|
||||||
QVariantMap subKeys;
|
QVariantMap subKeys;
|
||||||
@@ -101,118 +110,116 @@ bool AddKeysOperation::test() const
|
|||||||
data.append(KeyValuePair(QLatin1String("bool-false"), QString::fromLatin1("bool:false")));
|
data.append(KeyValuePair(QLatin1String("bool-false"), QString::fromLatin1("bool:false")));
|
||||||
data.append(KeyValuePair(QLatin1String("int"), QString::fromLatin1("int:42")));
|
data.append(KeyValuePair(QLatin1String("int"), QString::fromLatin1("int:42")));
|
||||||
data.append(KeyValuePair(QLatin1String("qstring"), QString::fromLatin1("QString:test string.")));
|
data.append(KeyValuePair(QLatin1String("qstring"), QString::fromLatin1("QString:test string.")));
|
||||||
data.append(KeyValuePair(QLatin1String("qbytearray"), QString::fromLatin1("QByteArray:test array.")));
|
data.append(
|
||||||
|
KeyValuePair(QLatin1String("qbytearray"), QString::fromLatin1("QByteArray:test array.")));
|
||||||
|
|
||||||
data.append(KeyValuePair(QLatin1String("subkeys/qbytearray"), QString::fromLatin1("QByteArray:test array.")));
|
data.append(KeyValuePair(QLatin1String("subkeys/qbytearray"),
|
||||||
data.append(KeyValuePair(QLatin1String("subkeys/newsubkeys/qbytearray"), QString::fromLatin1("QByteArray:test array.")));
|
QString::fromLatin1("QByteArray:test array.")));
|
||||||
data.append(KeyValuePair(QLatin1String("newsub/1/2/3/qbytearray"), QString::fromLatin1("QByteArray:test array.")));
|
data.append(KeyValuePair(QLatin1String("subkeys/newsubkeys/qbytearray"),
|
||||||
data.append(KeyValuePair(QLatin1String("newsub/1/2.1/3/qbytearray"), QString::fromLatin1("QByteArray:test array.")));
|
QString::fromLatin1("QByteArray:test array.")));
|
||||||
|
data.append(KeyValuePair(QLatin1String("newsub/1/2/3/qbytearray"),
|
||||||
|
QString::fromLatin1("QByteArray:test array.")));
|
||||||
|
data.append(KeyValuePair(QLatin1String("newsub/1/2.1/3/qbytearray"),
|
||||||
|
QString::fromLatin1("QByteArray:test array.")));
|
||||||
|
|
||||||
QVariantMap result = AddKeysData{data}.addKeys(testMap);
|
QVariantMap result = AddKeysData{data}.addKeys(testMap);
|
||||||
if (result.count() != 9)
|
QCOMPARE(result.count(), 9);
|
||||||
return false;
|
|
||||||
|
|
||||||
// subkeys:
|
// subkeys:
|
||||||
QVariantMap cur = result.value(QLatin1String("subkeys")).toMap();
|
QVariantMap cur = result.value(QLatin1String("subkeys")).toMap();
|
||||||
if (cur.count() != 4
|
QCOMPARE(cur.count(), 4);
|
||||||
|| !cur.contains(QLatin1String("qbytearray"))
|
QVERIFY(cur.contains(QLatin1String("qbytearray")));
|
||||||
|| !cur.contains(QLatin1String("testbool"))
|
QVERIFY(cur.contains(QLatin1String("testbool")));
|
||||||
|| !cur.contains(QLatin1String("subsubkeys"))
|
QVERIFY(cur.contains(QLatin1String("subsubkeys")));
|
||||||
|| !cur.contains(QLatin1String("newsubkeys")))
|
QVERIFY(cur.contains(QLatin1String("newsubkeys")));
|
||||||
return false;
|
|
||||||
|
|
||||||
// subkeys/newsubkeys:
|
// subkeys/newsubkeys:
|
||||||
QVariantMap tmp = cur;
|
QVariantMap tmp = cur;
|
||||||
cur = cur.value(QLatin1String("newsubkeys")).toMap();
|
cur = cur.value(QLatin1String("newsubkeys")).toMap();
|
||||||
if (cur.count() != 1
|
QCOMPARE(cur.count(), 1);
|
||||||
|| !cur.contains(QLatin1String("qbytearray")))
|
QVERIFY(cur.contains(QLatin1String("qbytearray")));
|
||||||
return false;
|
|
||||||
|
|
||||||
// subkeys/subsubkeys:
|
// subkeys/subsubkeys:
|
||||||
cur = tmp.value(QLatin1String("subsubkeys")).toMap();
|
cur = tmp.value(QLatin1String("subsubkeys")).toMap();
|
||||||
if (cur.count() != 0)
|
QVERIFY(cur.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
// newsub:
|
// newsub:
|
||||||
cur = result.value(QLatin1String("newsub")).toMap();
|
cur = result.value(QLatin1String("newsub")).toMap();
|
||||||
if (cur.count() != 1
|
QCOMPARE(cur.count(), 1);
|
||||||
|| !cur.contains(QLatin1String("1")))
|
QVERIFY(cur.contains(QLatin1String("1")));
|
||||||
return false;
|
|
||||||
|
|
||||||
// newsub/1:
|
// newsub/1:
|
||||||
cur = cur.value(QLatin1String("1")).toMap();
|
cur = cur.value(QLatin1String("1")).toMap();
|
||||||
if (cur.count() != 2
|
QCOMPARE(cur.count(), 2);
|
||||||
|| !cur.contains(QLatin1String("2"))
|
QVERIFY(cur.contains(QLatin1String("2")));
|
||||||
|| !cur.contains(QLatin1String("2.1")))
|
QVERIFY(cur.contains(QLatin1String("2.1")));
|
||||||
return false;
|
|
||||||
|
|
||||||
// newsub/1/2:
|
// newsub/1/2:
|
||||||
tmp = cur;
|
tmp = cur;
|
||||||
cur = cur.value(QLatin1String("2")).toMap();
|
cur = cur.value(QLatin1String("2")).toMap();
|
||||||
if (cur.count() != 1
|
QCOMPARE(cur.count(), 1);
|
||||||
|| !cur.contains(QLatin1String("3")))
|
QVERIFY(cur.contains(QLatin1String("3")));
|
||||||
return false;
|
|
||||||
|
|
||||||
// newsub/1/2/3:
|
// newsub/1/2/3:
|
||||||
cur = cur.value(QLatin1String("3")).toMap();
|
cur = cur.value(QLatin1String("3")).toMap();
|
||||||
if (cur.count() != 1
|
QCOMPARE(cur.count(), 1);
|
||||||
|| !cur.contains(QLatin1String("qbytearray")))
|
QVERIFY(cur.contains(QLatin1String("qbytearray")));
|
||||||
return false;
|
|
||||||
|
|
||||||
// newsub/1/2.1:
|
// newsub/1/2.1:
|
||||||
cur = tmp.value(QLatin1String("2.1")).toMap();
|
cur = tmp.value(QLatin1String("2.1")).toMap();
|
||||||
if (cur.count() != 1
|
QCOMPARE(cur.count(), 1);
|
||||||
|| !cur.contains(QLatin1String("3")))
|
QVERIFY(cur.contains(QLatin1String("3")));
|
||||||
return false;
|
|
||||||
|
|
||||||
// newsub/1/2.1/3:
|
// newsub/1/2.1/3:
|
||||||
cur = cur.value(QLatin1String("3")).toMap();
|
cur = cur.value(QLatin1String("3")).toMap();
|
||||||
if (cur.count() != 1
|
QCOMPARE(cur.count(), 1);
|
||||||
|| !cur.contains(QLatin1String("qbytearray")))
|
QVERIFY(cur.contains(QLatin1String("qbytearray")));
|
||||||
return false;
|
|
||||||
|
|
||||||
// subkeys2:
|
// subkeys2:
|
||||||
cur = result.value(QLatin1String("subkeys2")).toMap();
|
cur = result.value(QLatin1String("subkeys2")).toMap();
|
||||||
if (cur.count() != 0)
|
QVERIFY(cur.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
// values:
|
// values:
|
||||||
if (!result.contains(QLatin1String("bool-true")) || !result.value(QLatin1String("bool-true")).toBool())
|
QVERIFY(result.contains(QLatin1String("bool-true")));
|
||||||
return false;
|
QVERIFY(result.value(QLatin1String("bool-true")).toBool());
|
||||||
if (!result.contains(QLatin1String("bool-false")) || result.value(QLatin1String("bool-false")).toBool())
|
|
||||||
return false;
|
QVERIFY(result.contains(QLatin1String("bool-false")));
|
||||||
if (!result.contains(QLatin1String("int")) || result.value(QLatin1String("int")).toInt() != 42)
|
QVERIFY(!result.value(QLatin1String("bool-false")).toBool());
|
||||||
return false;
|
|
||||||
if (!result.contains(QLatin1String("qstring"))
|
QVERIFY(result.contains(QLatin1String("int")));
|
||||||
|| result.value(QLatin1String("qstring")).toString() != QLatin1String("test string."))
|
QCOMPARE(result.value(QLatin1String("int")).toInt(), 42);
|
||||||
return false;
|
QVERIFY(result.contains(QLatin1String("qstring")));
|
||||||
if (!result.contains(QLatin1String("qbytearray"))
|
QCOMPARE(result.value(QLatin1String("qstring")).toString(), QLatin1String("test string."));
|
||||||
|| result.value(QLatin1String("qbytearray")).toByteArray() != "test array.")
|
QVERIFY(result.contains(QLatin1String("qbytearray")));
|
||||||
return false;
|
QCOMPARE(result.value(QLatin1String("qbytearray")).toByteArray(), "test array.");
|
||||||
|
|
||||||
// Make sure we do not overwrite data:
|
// Make sure we do not overwrite data:
|
||||||
// preexisting:
|
// preexisting:
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
|
QRegularExpression("Cannot add key .* which already exists."));
|
||||||
|
|
||||||
data.clear();
|
data.clear();
|
||||||
data.append(KeyValuePair(QLatin1String("testint"), QString::fromLatin1("int:4")));
|
data.append(KeyValuePair(QLatin1String("testint"), QString::fromLatin1("int:4")));
|
||||||
result = AddKeysData{data}.addKeys(testMap);
|
result = AddKeysData{data}.addKeys(testMap);
|
||||||
if (!result.isEmpty())
|
QVERIFY(result.isEmpty());
|
||||||
return false;
|
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
|
QRegularExpression("Cannot add key .* which already exists."));
|
||||||
|
|
||||||
data.clear();
|
data.clear();
|
||||||
data.append(KeyValuePair(QLatin1String("subkeys/testbool"), QString::fromLatin1("int:24")));
|
data.append(KeyValuePair(QLatin1String("subkeys/testbool"), QString::fromLatin1("int:24")));
|
||||||
result = AddKeysData{data}.addKeys(testMap);
|
result = AddKeysData{data}.addKeys(testMap);
|
||||||
if (!result.isEmpty())
|
QVERIFY(result.isEmpty());
|
||||||
return false;
|
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
|
QRegularExpression("Cannot add key .* which already exists."));
|
||||||
|
|
||||||
// data inserted before:
|
// data inserted before:
|
||||||
data.clear();
|
data.clear();
|
||||||
data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe")));
|
data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe")));
|
||||||
data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe")));
|
data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe")));
|
||||||
result = AddKeysData{data}.addKeys(testMap);
|
result = AddKeysData{data}.addKeys(testMap);
|
||||||
if (!result.isEmpty())
|
QVERIFY(result.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -236,14 +243,16 @@ QVariantMap AddKeysData::addKeys(const QVariantMap &map) const
|
|||||||
// insert
|
// insert
|
||||||
Q_ASSERT(stack.count() == p.key.count());
|
Q_ASSERT(stack.count() == p.key.count());
|
||||||
if (stack.last().contains(p.key.last())) {
|
if (stack.last().contains(p.key.last())) {
|
||||||
std::cerr << "DEBUG: Adding key " << qPrintable(p.key.join(QLatin1Char('/'))) << " which already exists." << std::endl;
|
qCCritical(addkeyslog) << "Cannot add key" << qPrintable(p.key.join(QLatin1Char('/')))
|
||||||
|
<< "which already exists.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
stack.last().insert(p.key.last(), p.value);
|
stack.last().insert(p.key.last(), p.value);
|
||||||
|
|
||||||
// Generate new resultset by folding maps back in:
|
// Generate new resultset by folding maps back in:
|
||||||
QVariantMap foldBack = stack.takeLast();
|
QVariantMap foldBack = stack.takeLast();
|
||||||
for (int i = p.key.count() - 2; i >= 0; --i) { // skip last key, that is already taken care of
|
for (int i = p.key.count() - 2; i >= 0;
|
||||||
|
--i) { // skip last key, that is already taken care of
|
||||||
const QString k = p.key.at(i);
|
const QString k = p.key.at(i);
|
||||||
QVariantMap current = stack.takeLast();
|
QVariantMap current = stack.takeLast();
|
||||||
current.insert(k, foldBack);
|
current.insert(k, foldBack);
|
||||||
|
@@ -47,7 +47,8 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -26,10 +26,10 @@
|
|||||||
#include "addkitoperation.h"
|
#include "addkitoperation.h"
|
||||||
|
|
||||||
#include "addcmakeoperation.h"
|
#include "addcmakeoperation.h"
|
||||||
#include "addkeysoperation.h"
|
|
||||||
#include "addtoolchainoperation.h"
|
|
||||||
#include "addqtoperation.h"
|
|
||||||
#include "adddeviceoperation.h"
|
#include "adddeviceoperation.h"
|
||||||
|
#include "addkeysoperation.h"
|
||||||
|
#include "addqtoperation.h"
|
||||||
|
#include "addtoolchainoperation.h"
|
||||||
#include "findkeyoperation.h"
|
#include "findkeyoperation.h"
|
||||||
#include "findvalueoperation.h"
|
#include "findvalueoperation.h"
|
||||||
#include "getoperation.h"
|
#include "getoperation.h"
|
||||||
@@ -37,9 +37,14 @@
|
|||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include <iostream>
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(addkitlog, "qtc.sdktool.operations.addkit", QtWarningMsg)
|
||||||
|
|
||||||
// Qt version file stuff:
|
// Qt version file stuff:
|
||||||
const char PREFIX[] = "Profile.";
|
const char PREFIX[] = "Profile.";
|
||||||
@@ -88,7 +93,8 @@ QString AddKitOperation::argumentsHelpText() const
|
|||||||
" --name <NAME> display name of the new kit (required).\n"
|
" --name <NAME> display name of the new kit (required).\n"
|
||||||
" --icon <PATH> icon of the new kit.\n"
|
" --icon <PATH> icon of the new kit.\n"
|
||||||
" --debuggerid <ID> the id of the debugger to use.\n"
|
" --debuggerid <ID> the id of the debugger to use.\n"
|
||||||
" (not compatible with --debugger and --debuggerengine)\n"
|
" (not compatible with --debugger and "
|
||||||
|
"--debuggerengine)\n"
|
||||||
" --debuggerengine <ENGINE> debuggerengine of the new kit.\n"
|
" --debuggerengine <ENGINE> debuggerengine of the new kit.\n"
|
||||||
" --debugger <PATH> debugger of the new kit.\n"
|
" --debugger <PATH> debugger of the new kit.\n"
|
||||||
" --devicetype <TYPE> (run-)device type of the new kit (required).\n"
|
" --devicetype <TYPE> (run-)device type of the new kit (required).\n"
|
||||||
@@ -103,7 +109,8 @@ QString AddKitOperation::argumentsHelpText() const
|
|||||||
" --cmake <ID> set a cmake tool.\n"
|
" --cmake <ID> set a cmake tool.\n"
|
||||||
" --cmake-generator <GEN>:<EXTRA>:<TOOLSET>:<PLATFORM>\n"
|
" --cmake-generator <GEN>:<EXTRA>:<TOOLSET>:<PLATFORM>\n"
|
||||||
" set a cmake generator.\n"
|
" set a cmake generator.\n"
|
||||||
" --cmake-config <KEY:TYPE=VALUE> set a cmake configuration value [may be repeated]\n"
|
" --cmake-config <KEY:TYPE=VALUE> set a cmake configuration value [may be "
|
||||||
|
"repeated]\n"
|
||||||
" <KEY> <TYPE:VALUE> extra key value pairs\n");
|
" <KEY> <TYPE:VALUE> extra key value pairs\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +151,7 @@ bool AddKitOperation::setArguments(const QStringList &args)
|
|||||||
bool ok;
|
bool ok;
|
||||||
m_debuggerEngine = next.toInt(&ok);
|
m_debuggerEngine = next.toInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
std::cerr << "Debugger type is not an integer!" << std::endl;
|
qCCritical(addkitlog) << "Debugger type is not an integer!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@@ -208,11 +215,11 @@ bool AddKitOperation::setArguments(const QStringList &args)
|
|||||||
const QString lang = tmp2.isEmpty() ? QString("Cxx") : tmp2;
|
const QString lang = tmp2.isEmpty() ? QString("Cxx") : tmp2;
|
||||||
|
|
||||||
if (next.isEmpty()) {
|
if (next.isEmpty()) {
|
||||||
std::cerr << "Empty langid for toolchain given." << std::endl << std::endl;
|
qCCritical(addkitlog) << "Empty langid for toolchain given.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (m_tcs.contains(lang)) {
|
if (m_tcs.contains(lang)) {
|
||||||
std::cerr << "No langid for toolchain given twice." << std::endl << std::endl;
|
qCCritical(addkitlog) << "No langid for toolchain given twice.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_tcs.insert(lang, next);
|
m_tcs.insert(lang, next);
|
||||||
@@ -284,13 +291,13 @@ bool AddKitOperation::setArguments(const QStringList &args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_id.isEmpty())
|
if (m_id.isEmpty())
|
||||||
std::cerr << "No id given for kit." << std::endl << std::endl;
|
qCCritical(addkitlog) << "No id given for kit.";
|
||||||
if (m_displayName.isEmpty())
|
if (m_displayName.isEmpty())
|
||||||
std::cerr << "No name given for kit." << std::endl << std::endl;
|
qCCritical(addkitlog) << "No name given for kit.";
|
||||||
if (m_deviceType.isEmpty())
|
if (m_deviceType.isEmpty())
|
||||||
std::cerr << "No devicetype given for kit." << std::endl << std::endl;
|
qCCritical(addkitlog) << "No devicetype given for kit.";
|
||||||
if (!m_debuggerId.isEmpty() && (!m_debugger.isEmpty() || m_debuggerEngine != 0)) {
|
if (!m_debuggerId.isEmpty() && (!m_debugger.isEmpty() || m_debuggerEngine != 0)) {
|
||||||
std::cerr << "Cannot set both debugger id and debugger/debuggerengine." << std::endl << std::endl;
|
qCCritical(addkitlog) << "Cannot set both debugger id and debugger/debuggerengine.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +318,7 @@ int AddKitOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool AddKitOperation::test() const
|
void AddKitOperation::unittest()
|
||||||
{
|
{
|
||||||
AddKitData baseData;
|
AddKitData baseData;
|
||||||
baseData.m_id = "testId";
|
baseData.m_id = "testId";
|
||||||
@@ -328,12 +335,28 @@ bool AddKitOperation::test() const
|
|||||||
QVariantMap map = initializeKits();
|
QVariantMap map = initializeKits();
|
||||||
|
|
||||||
QVariantMap tcMap = AddToolChainData::initializeToolChains();
|
QVariantMap tcMap = AddToolChainData::initializeToolChains();
|
||||||
tcMap = AddToolChainData{"{tc-id}", "langId", "TC", "/usr/bin/gcc",
|
AddToolChainData atcd;
|
||||||
"x86-linux-generic-elf-32bit", "x86-linux-generic-elf-32bit", {}}
|
atcd.m_id = "{tc-id}";
|
||||||
.addToolChain(tcMap);
|
atcd.m_languageId = "langId";
|
||||||
|
atcd.m_displayName = "TC";
|
||||||
|
atcd.m_path = "/usr/bin/gcc";
|
||||||
|
atcd.m_targetAbi = "x86-linux-generic-elf-32bit";
|
||||||
|
atcd.m_supportedAbis = "x86-linux-generic-elf-32bit";
|
||||||
|
atcd.m_extra = {};
|
||||||
|
|
||||||
|
tcMap = atcd.addToolChain(tcMap);
|
||||||
|
|
||||||
QVariantMap qtMap = AddQtData::initializeQtVersions();
|
QVariantMap qtMap = AddQtData::initializeQtVersions();
|
||||||
qtMap = AddQtData{"{qt-id}", "Qt", "desktop-qt", "/usr/bin/qmake", {}, {}}.addQt(qtMap);
|
AddQtData aqtd;
|
||||||
|
|
||||||
|
aqtd.m_id = "{qt-id}";
|
||||||
|
aqtd.m_displayName = "Qt";
|
||||||
|
aqtd.m_type = "desktop-qt";
|
||||||
|
aqtd.m_qmake = "/usr/bin/qmake";
|
||||||
|
aqtd.m_abis = {};
|
||||||
|
aqtd.m_extra = {};
|
||||||
|
|
||||||
|
qtMap = aqtd.addQt(qtMap);
|
||||||
|
|
||||||
QVariantMap devMap = AddDeviceOperation::initializeDevices();
|
QVariantMap devMap = AddDeviceOperation::initializeDevices();
|
||||||
AddDeviceData devData;
|
AddDeviceData devData;
|
||||||
@@ -358,159 +381,119 @@ bool AddKitOperation::test() const
|
|||||||
|
|
||||||
const QStringList env = {"TEST=1", "PATH"};
|
const QStringList env = {"TEST=1", "PATH"};
|
||||||
|
|
||||||
if (map.count() != 3)
|
QCOMPARE(map.count(), 3);
|
||||||
return false;
|
QVERIFY(map.contains(VERSION));
|
||||||
if (!map.contains(VERSION))
|
QCOMPARE(map.value(VERSION).toInt(), 1);
|
||||||
return false;
|
QVERIFY(map.contains(COUNT));
|
||||||
if (map.value(VERSION).toInt() != 1)
|
QCOMPARE(map.value(COUNT).toInt(), 0);
|
||||||
return false;
|
QVERIFY(map.contains(DEFAULT));
|
||||||
if (!map.contains(COUNT))
|
QVERIFY(map.value(DEFAULT).toString().isEmpty());
|
||||||
return false;
|
|
||||||
if (map.value(COUNT).toInt() != 0)
|
|
||||||
return false;
|
|
||||||
if (!map.contains(DEFAULT))
|
|
||||||
return false;
|
|
||||||
if (!map.value(DEFAULT).toString().isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QHash<QString, QString> tcs;
|
QHash<QString, QString> tcs;
|
||||||
tcs.insert("Cxx", "{tcXX-id}");
|
tcs.insert("Cxx", "{tcXX-id}");
|
||||||
|
|
||||||
// Fail if TC is not there:
|
// Fail if TC is not there:
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
|
QRegularExpression(
|
||||||
|
"Error: Toolchain .* for language Cxx does not exist."));
|
||||||
|
|
||||||
AddKitData kitData = baseData;
|
AddKitData kitData = baseData;
|
||||||
kitData.m_tcs = tcs;
|
kitData.m_tcs = tcs;
|
||||||
QVariantMap empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
QVariantMap empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
|
|
||||||
if (!empty.isEmpty())
|
QVERIFY(empty.isEmpty());
|
||||||
return false;
|
|
||||||
// Do not fail if TC is an ABI:
|
// Do not fail if TC is an ABI:
|
||||||
tcs.clear();
|
tcs.clear();
|
||||||
tcs.insert("C", "x86-linux-generic-elf-64bit");
|
tcs.insert("C", "x86-linux-generic-elf-64bit");
|
||||||
kitData = baseData;
|
kitData = baseData;
|
||||||
kitData.m_tcs = tcs;
|
kitData.m_tcs = tcs;
|
||||||
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (empty.isEmpty())
|
QVERIFY(!empty.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
// QTCREATORBUG-11983, mach_o was not covered by the first attempt to fix this.
|
// QTCREATORBUG-11983, mach_o was not covered by the first attempt to fix this.
|
||||||
tcs.insert("D", "x86-macos-generic-mach_o-64bit");
|
tcs.insert("D", "x86-macos-generic-mach_o-64bit");
|
||||||
kitData = baseData;
|
kitData = baseData;
|
||||||
kitData.m_tcs = tcs;
|
kitData.m_tcs = tcs;
|
||||||
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (empty.isEmpty())
|
QVERIFY(!empty.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
tcs.clear();
|
tcs.clear();
|
||||||
tcs.insert("Cxx", "{tc-id}");
|
tcs.insert("Cxx", "{tc-id}");
|
||||||
|
|
||||||
// Fail if Qt is not there:
|
// Fail if Qt is not there:
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg, QRegularExpression("Error: Qt .* does not exist."));
|
||||||
|
|
||||||
kitData = baseData;
|
kitData = baseData;
|
||||||
kitData.m_qt = "{qtXX-id}";
|
kitData.m_qt = "{qtXX-id}";
|
||||||
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (!empty.isEmpty())
|
QVERIFY(empty.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
// Fail if dev is not there:
|
// Fail if dev is not there:
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg, QRegularExpression("Error: Device .* does not exist."));
|
||||||
|
|
||||||
kitData = baseData;
|
kitData = baseData;
|
||||||
kitData.m_device = "{devXX-id}";
|
kitData.m_device = "{devXX-id}";
|
||||||
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
empty = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (!empty.isEmpty())
|
QVERIFY(empty.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
// Profile 0:
|
// Profile 0:
|
||||||
kitData = baseData;
|
kitData = baseData;
|
||||||
kitData.m_tcs = tcs;
|
kitData.m_tcs = tcs;
|
||||||
map = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
map = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
|
|
||||||
if (map.count() != 4)
|
QCOMPARE(map.count(), 4);
|
||||||
return false;
|
QVERIFY(map.contains(VERSION));
|
||||||
if (!map.contains(VERSION))
|
QCOMPARE(map.value(VERSION).toInt(), 1);
|
||||||
return false;
|
QVERIFY(map.contains(COUNT));
|
||||||
if (map.value(VERSION).toInt() != 1)
|
QCOMPARE(map.value(COUNT).toInt(), 1);
|
||||||
return false;
|
QVERIFY(map.contains(DEFAULT));
|
||||||
if (!map.contains(COUNT))
|
QCOMPARE(map.value(DEFAULT).toString(), "testId");
|
||||||
return false;
|
QVERIFY(map.contains("Profile.0"));
|
||||||
if (map.value(COUNT).toInt() != 1)
|
|
||||||
return false;
|
|
||||||
if (!map.contains(DEFAULT))
|
|
||||||
return false;
|
|
||||||
if (map.value(DEFAULT).toString() != "testId")
|
|
||||||
return false;
|
|
||||||
if (!map.contains("Profile.0"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QVariantMap profile0 = map.value("Profile.0").toMap();
|
QVariantMap profile0 = map.value("Profile.0").toMap();
|
||||||
if (profile0.count() != 6)
|
QCOMPARE(profile0.count(), 6);
|
||||||
return false;
|
QVERIFY(profile0.contains(ID));
|
||||||
|
QCOMPARE(profile0.value(ID).toString(), "testId");
|
||||||
if (!profile0.contains(ID))
|
QVERIFY(profile0.contains(DISPLAYNAME));
|
||||||
return false;
|
QCOMPARE(profile0.value(DISPLAYNAME).toString(), "Test Kit");
|
||||||
if (profile0.value(ID).toString() != "testId")
|
QVERIFY(profile0.contains(ICON));
|
||||||
return false;
|
QCOMPARE(profile0.value(ICON).toString(), "/tmp/icon.png");
|
||||||
if (!profile0.contains(DISPLAYNAME))
|
QVERIFY(profile0.contains(DATA));
|
||||||
return false;
|
QCOMPARE(profile0.value(DATA).type(), QVariant::Map);
|
||||||
if (profile0.value(DISPLAYNAME).toString() != "Test Kit")
|
QVERIFY(profile0.contains(AUTODETECTED));
|
||||||
return false;
|
QCOMPARE(profile0.value(AUTODETECTED).toBool(), true);
|
||||||
if (!profile0.contains(ICON))
|
QVERIFY(profile0.contains(SDK));
|
||||||
return false;
|
QCOMPARE(profile0.value(SDK).toBool(), true);
|
||||||
if (profile0.value(ICON).toString() != "/tmp/icon.png")
|
|
||||||
return false;
|
|
||||||
if (!profile0.contains(DATA))
|
|
||||||
return false;
|
|
||||||
if (profile0.value(DATA).type() != QVariant::Map)
|
|
||||||
return false;
|
|
||||||
if (!profile0.contains(AUTODETECTED))
|
|
||||||
return false;
|
|
||||||
if (profile0.value(AUTODETECTED).toBool() != true)
|
|
||||||
return false;
|
|
||||||
if (!profile0.contains(SDK))
|
|
||||||
return false;
|
|
||||||
if (profile0.value(SDK).toBool() != true)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QVariantMap data = profile0.value(DATA).toMap();
|
QVariantMap data = profile0.value(DATA).toMap();
|
||||||
if (data.count() != 7)
|
QCOMPARE(data.count(), 7);
|
||||||
return false;
|
QVERIFY(data.contains(DEBUGGER));
|
||||||
if (!data.contains(DEBUGGER))
|
QCOMPARE(data.value(DEBUGGER).type(), QVariant::Map);
|
||||||
return false;
|
QVERIFY(data.contains(DEVICE_TYPE));
|
||||||
if (data.value(DEBUGGER).type() != QVariant::Map)
|
QCOMPARE(data.value(DEVICE_TYPE).toString(), "Desktop");
|
||||||
return false;
|
QVERIFY(data.contains(TOOLCHAIN));
|
||||||
if (!data.contains(DEVICE_TYPE))
|
QVERIFY(data.contains(QT));
|
||||||
return false;
|
QCOMPARE(data.value(QT).toString(), "SDK.{qt-id}");
|
||||||
if (data.value(DEVICE_TYPE).toString() != "Desktop")
|
QVERIFY(data.contains(MKSPEC));
|
||||||
return false;
|
QCOMPARE(data.value(MKSPEC).toString(), "unsupported/mkspec");
|
||||||
if (!data.contains(TOOLCHAIN))
|
QVERIFY(data.contains("extraData"));
|
||||||
return false;
|
QCOMPARE(data.value("extraData").toString(), "extraValue");
|
||||||
if (!data.contains(QT))
|
|
||||||
return false;
|
|
||||||
if (data.value(QT).toString() != "SDK.{qt-id}")
|
|
||||||
return false;
|
|
||||||
if (!data.contains(MKSPEC))
|
|
||||||
return false;
|
|
||||||
if (data.value(MKSPEC).toString() != "unsupported/mkspec")
|
|
||||||
return false;
|
|
||||||
if (!data.contains("extraData"))
|
|
||||||
return false;
|
|
||||||
if (data.value("extraData").toString() != "extraValue")
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QVariantMap tcOutput = data.value(TOOLCHAIN).toMap();
|
QVariantMap tcOutput = data.value(TOOLCHAIN).toMap();
|
||||||
if (tcOutput.count() != 1)
|
QCOMPARE(tcOutput.count(), 1);
|
||||||
return false;
|
QVERIFY(tcOutput.contains("Cxx"));
|
||||||
if (!tcOutput.contains("Cxx"))
|
QCOMPARE(tcOutput.value("Cxx"), "{tc-id}");
|
||||||
return false;
|
|
||||||
if (tcOutput.value("Cxx") != "{tc-id}")
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Ignore exist ids:
|
// Ignore exist ids:
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg, QRegularExpression("Error: Id .* already defined as kit."));
|
||||||
|
|
||||||
kitData = baseData;
|
kitData = baseData;
|
||||||
kitData.m_displayName = "Test Qt Version X";
|
kitData.m_displayName = "Test Qt Version X";
|
||||||
kitData.m_icon = "/tmp/icon3.png";
|
kitData.m_icon = "/tmp/icon3.png";
|
||||||
kitData.m_debugger = "/usr/bin/gdb-test3";
|
kitData.m_debugger = "/usr/bin/gdb-test3";
|
||||||
kitData.m_tcs = tcs;
|
kitData.m_tcs = tcs;
|
||||||
QVariantMap result = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
QVariantMap result = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (!result.isEmpty())
|
QVERIFY(result.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
// Profile 1: Make sure name is unique:
|
// Profile 1: Make sure name is unique:
|
||||||
kitData = baseData;
|
kitData = baseData;
|
||||||
@@ -523,100 +506,56 @@ bool AddKitOperation::test() const
|
|||||||
kitData.m_tcs = tcs;
|
kitData.m_tcs = tcs;
|
||||||
map = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
map = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
|
|
||||||
if (map.count() != 5)
|
QCOMPARE(map.count(), 5);
|
||||||
return false;
|
QVERIFY(map.contains(VERSION));
|
||||||
if (!map.contains(VERSION) )
|
QCOMPARE(map.value(VERSION).toInt(), 1);
|
||||||
return false;
|
QVERIFY(map.contains(COUNT));
|
||||||
if (map.value(VERSION).toInt() != 1)
|
QCOMPARE(map.value(COUNT).toInt(), 2);
|
||||||
return false;
|
QVERIFY(map.contains(DEFAULT));
|
||||||
if (!map.contains(COUNT) )
|
QCOMPARE(map.value(DEFAULT).toInt(), 0);
|
||||||
return false;
|
QVERIFY(map.contains("Profile.0"));
|
||||||
if (map.value(COUNT).toInt() != 2)
|
QVERIFY(map.contains("Profile.1"));
|
||||||
return false;
|
QCOMPARE(map.value("Profile.0"), profile0);
|
||||||
if (!map.contains(DEFAULT) )
|
|
||||||
return false;
|
|
||||||
if (map.value(DEFAULT).toInt() != 0)
|
|
||||||
return false;
|
|
||||||
if (!map.contains("Profile.0"))
|
|
||||||
return false;
|
|
||||||
if (!map.contains("Profile.1"))
|
|
||||||
return false;
|
|
||||||
if (map.value("Profile.0") != profile0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QVariantMap profile1 = map.value("Profile.1").toMap();
|
QVariantMap profile1 = map.value("Profile.1").toMap();
|
||||||
if (profile1.count() != 6)
|
QCOMPARE(profile1.count(), 6);
|
||||||
return false;
|
QVERIFY(profile1.contains(ID));
|
||||||
if (!profile1.contains(ID) )
|
QCOMPARE(profile1.value(ID).toString(), "testId2");
|
||||||
return false;
|
QVERIFY(profile1.contains(DISPLAYNAME));
|
||||||
if (profile1.value(ID).toString() != "testId2")
|
QCOMPARE(profile1.value(DISPLAYNAME).toString(), "Test Kit2");
|
||||||
return false;
|
QVERIFY(profile1.contains(ICON));
|
||||||
if (!profile1.contains(DISPLAYNAME) )
|
QCOMPARE(profile1.value(ICON).toString(), "/tmp/icon2.png");
|
||||||
return false;
|
QVERIFY(profile1.contains(DATA));
|
||||||
if (profile1.value(DISPLAYNAME).toString() != "Test Kit2")
|
QCOMPARE(profile1.value(DATA).type(), QVariant::Map);
|
||||||
return false;
|
QVERIFY(profile1.contains(AUTODETECTED));
|
||||||
if (!profile1.contains(ICON) )
|
QCOMPARE(profile1.value(AUTODETECTED).toBool(), true);
|
||||||
return false;
|
QVERIFY(profile1.contains(SDK));
|
||||||
if (profile1.value(ICON).toString() != "/tmp/icon2.png")
|
QCOMPARE(profile1.value(SDK).toBool(), true);
|
||||||
return false;
|
|
||||||
if (!profile1.contains(DATA) )
|
|
||||||
return false;
|
|
||||||
if (profile1.value(DATA).type() != QVariant::Map)
|
|
||||||
return false;
|
|
||||||
if (!profile1.contains(AUTODETECTED) )
|
|
||||||
return false;
|
|
||||||
if (profile1.value(AUTODETECTED).toBool() != true)
|
|
||||||
return false;
|
|
||||||
if (!profile1.contains(SDK) )
|
|
||||||
return false;
|
|
||||||
if (profile1.value(SDK).toBool() != true)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
data = profile1.value(DATA).toMap();
|
data = profile1.value(DATA).toMap();
|
||||||
if (data.count() != 9)
|
QCOMPARE(data.count(), 9);
|
||||||
return false;
|
QVERIFY(data.contains(DEBUGGER));
|
||||||
if (!data.contains(DEBUGGER) )
|
QCOMPARE(data.value(DEBUGGER).type(), QVariant::Map);
|
||||||
return false;
|
QVERIFY(data.contains(DEVICE_TYPE));
|
||||||
if (data.value(DEBUGGER).type() != QVariant::Map)
|
QCOMPARE(data.value(DEVICE_TYPE).toString(), "Desktop");
|
||||||
return false;
|
QVERIFY(data.contains(DEVICE_ID));
|
||||||
if (!data.contains(DEVICE_TYPE) )
|
QCOMPARE(data.value(DEVICE_ID).toString(), "{dev-id}");
|
||||||
return false;
|
QVERIFY(data.contains(SYSROOT));
|
||||||
if (data.value(DEVICE_TYPE).toString() != "Desktop")
|
QCOMPARE(data.value(SYSROOT).toString(), "/sys/root//");
|
||||||
return false;
|
QVERIFY(data.contains(TOOLCHAIN));
|
||||||
if (!data.contains(DEVICE_ID) )
|
QVERIFY(data.contains(QT));
|
||||||
return false;
|
QCOMPARE(data.value(QT).toString(), "SDK.{qt-id}");
|
||||||
if (data.value(DEVICE_ID).toString() != "{dev-id}")
|
QVERIFY(data.contains(MKSPEC));
|
||||||
return false;
|
QCOMPARE(data.value(MKSPEC).toString(), "unsupported/mkspec");
|
||||||
if (!data.contains(SYSROOT) )
|
QVERIFY(data.contains(ENV));
|
||||||
return false;
|
QCOMPARE(data.value(ENV).toStringList(), env);
|
||||||
if (data.value(SYSROOT).toString() != "/sys/root//")
|
QVERIFY(data.contains("extraData"));
|
||||||
return false;
|
QCOMPARE(data.value("extraData").toString(), "extraValue");
|
||||||
if (!data.contains(TOOLCHAIN))
|
|
||||||
return false;
|
|
||||||
if (!data.contains(QT) )
|
|
||||||
return false;
|
|
||||||
if (data.value(QT).toString() != "SDK.{qt-id}")
|
|
||||||
return false;
|
|
||||||
if (!data.contains(MKSPEC) )
|
|
||||||
return false;
|
|
||||||
if (data.value(MKSPEC).toString() != "unsupported/mkspec")
|
|
||||||
return false;
|
|
||||||
if (!data.contains(ENV) )
|
|
||||||
return false;
|
|
||||||
if (data.value(ENV).toStringList() != env)
|
|
||||||
return false;
|
|
||||||
if (!data.contains("extraData") )
|
|
||||||
return false;
|
|
||||||
if (data.value("extraData").toString() != "extraValue")
|
|
||||||
return false;
|
|
||||||
|
|
||||||
tcOutput = data.value(TOOLCHAIN).toMap();
|
tcOutput = data.value(TOOLCHAIN).toMap();
|
||||||
if (tcOutput.count() != 1)
|
QCOMPARE(tcOutput.count(), 1);
|
||||||
return false;
|
QVERIFY(tcOutput.contains("Cxx"));
|
||||||
if (!tcOutput.contains("Cxx") )
|
QCOMPARE(tcOutput.value("Cxx"), "{tc-id}");
|
||||||
return false;
|
|
||||||
if (tcOutput.value("Cxx") != "{tc-id}")
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Profile 2: Test debugger id:
|
// Profile 2: Test debugger id:
|
||||||
kitData = baseData;
|
kitData = baseData;
|
||||||
@@ -627,68 +566,38 @@ bool AddKitOperation::test() const
|
|||||||
kitData.m_env = env;
|
kitData.m_env = env;
|
||||||
|
|
||||||
map = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
map = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
if (map.count() != 6)
|
QCOMPARE(map.count(), 6);
|
||||||
return false;
|
QVERIFY(map.contains(VERSION));
|
||||||
if (!map.contains(VERSION) )
|
QCOMPARE(map.value(VERSION).toInt(), 1);
|
||||||
return false;
|
QVERIFY(map.contains(COUNT));
|
||||||
if (map.value(VERSION).toInt() != 1)
|
QCOMPARE(map.value(COUNT).toInt(), 3);
|
||||||
return false;
|
QVERIFY(map.contains(DEFAULT));
|
||||||
if (!map.contains(COUNT) )
|
QCOMPARE(map.value(DEFAULT).toInt(), 0);
|
||||||
return false;
|
QVERIFY(map.contains("Profile.0"));
|
||||||
if (map.value(COUNT).toInt() != 3)
|
QVERIFY(map.contains("Profile.1"));
|
||||||
return false;
|
QVERIFY(map.contains("Profile.2"));
|
||||||
if (!map.contains(DEFAULT) )
|
QCOMPARE(map.value("Profile.0"), profile0);
|
||||||
return false;
|
QCOMPARE(map.value("Profile.1"), profile1);
|
||||||
if (map.value(DEFAULT).toInt() != 0)
|
|
||||||
return false;
|
|
||||||
if (!map.contains("Profile.0"))
|
|
||||||
return false;
|
|
||||||
if (!map.contains("Profile.1"))
|
|
||||||
return false;
|
|
||||||
if (!map.contains("Profile.2"))
|
|
||||||
return false;
|
|
||||||
if (map.value("Profile.0") != profile0)
|
|
||||||
return false;
|
|
||||||
if (map.value("Profile.1") != profile1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QVariantMap profile2 = map.value("Profile.2").toMap();
|
QVariantMap profile2 = map.value("Profile.2").toMap();
|
||||||
if (profile2.count() != 6)
|
QCOMPARE(profile2.count(), 6);
|
||||||
return false;
|
QVERIFY(profile2.contains(ID));
|
||||||
if (!profile2.contains(ID) )
|
QCOMPARE(profile2.value(ID).toString(), "test with debugger Id");
|
||||||
return false;
|
QVERIFY(profile2.contains(DISPLAYNAME));
|
||||||
if (profile2.value(ID).toString() != "test with debugger Id")
|
QCOMPARE(profile2.value(DISPLAYNAME).toString(), "Test debugger Id");
|
||||||
return false;
|
QVERIFY(profile2.contains(ICON));
|
||||||
if (!profile2.contains(DISPLAYNAME) )
|
QCOMPARE(profile2.value(ICON).toString(), "/tmp/icon2.png");
|
||||||
return false;
|
QVERIFY(profile2.contains(DATA));
|
||||||
if (profile2.value(DISPLAYNAME).toString() != "Test debugger Id")
|
QCOMPARE(profile2.value(DATA).type(), QVariant::Map);
|
||||||
return false;
|
QVERIFY(profile2.contains(AUTODETECTED));
|
||||||
if (!profile2.contains(ICON) )
|
QCOMPARE(profile2.value(AUTODETECTED).toBool(), true);
|
||||||
return false;
|
QVERIFY(profile2.contains(SDK));
|
||||||
if (profile2.value(ICON).toString() != "/tmp/icon2.png")
|
QCOMPARE(profile2.value(SDK).toBool(), true);
|
||||||
return false;
|
|
||||||
if (!profile2.contains(DATA) )
|
|
||||||
return false;
|
|
||||||
if (profile2.value(DATA).type() != QVariant::Map)
|
|
||||||
return false;
|
|
||||||
if (!profile2.contains(AUTODETECTED) )
|
|
||||||
return false;
|
|
||||||
if (profile2.value(AUTODETECTED).toBool() != true)
|
|
||||||
return false;
|
|
||||||
if (!profile2.contains(SDK) )
|
|
||||||
return false;
|
|
||||||
if (profile2.value(SDK).toBool() != true)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
data = profile2.value(DATA).toMap();
|
data = profile2.value(DATA).toMap();
|
||||||
if (data.count() != 7)
|
QCOMPARE(data.count(), 7);
|
||||||
return false;
|
QVERIFY(data.contains(DEBUGGER));
|
||||||
if (!data.contains(DEBUGGER))
|
QCOMPARE(data.value(DEBUGGER).toString(), "debugger Id");
|
||||||
return false;
|
|
||||||
if (data.value(DEBUGGER).toString() != "debugger Id")
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -702,8 +611,10 @@ QVariantMap AddKitData::addKit(const QVariantMap &map) const
|
|||||||
return AddKitData::addKit(map, tcMap, qtMap, devMap, cmakeMap);
|
return AddKitData::addKit(map, tcMap, qtMap, devMap, cmakeMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap AddKitData::addKit(const QVariantMap &map, const QVariantMap &tcMap,
|
QVariantMap AddKitData::addKit(const QVariantMap &map,
|
||||||
const QVariantMap &qtMap, const QVariantMap &devMap,
|
const QVariantMap &tcMap,
|
||||||
|
const QVariantMap &qtMap,
|
||||||
|
const QVariantMap &devMap,
|
||||||
const QVariantMap &cmakeMap) const
|
const QVariantMap &cmakeMap) const
|
||||||
{
|
{
|
||||||
// Sanity check: Make sure autodetection source is not in use already:
|
// Sanity check: Make sure autodetection source is not in use already:
|
||||||
@@ -716,16 +627,17 @@ QVariantMap AddKitData::addKit(const QVariantMap &map, const QVariantMap &tcMap,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasId) {
|
if (hasId) {
|
||||||
std::cerr << "Error: Id " << qPrintable(m_id) << " already defined as kit." << std::endl;
|
qCCritical(addkitlog) << "Error: Id" << qPrintable(m_id) << "already defined as kit.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto i = m_tcs.constBegin(); i != m_tcs.constEnd(); ++i) {
|
for (auto i = m_tcs.constBegin(); i != m_tcs.constEnd(); ++i) {
|
||||||
if (!i.value().isEmpty() && !AddToolChainOperation::exists(tcMap, i.value())) {
|
if (!i.value().isEmpty() && !AddToolChainOperation::exists(tcMap, i.value())) {
|
||||||
const QRegularExpression abiRegExp("^[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-(8|16|32|64|128)bit$");
|
const QRegularExpression abiRegExp(
|
||||||
|
"^[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-[a-z0-9_]+-(8|16|32|64|128)bit$");
|
||||||
if (!abiRegExp.match(i.value()).hasMatch()) {
|
if (!abiRegExp.match(i.value()).hasMatch()) {
|
||||||
std::cerr << "Error: Toolchain " << qPrintable(i.value())
|
qCCritical(addkitlog) << "Error: Toolchain" << qPrintable(i.value())
|
||||||
<< " for language " << qPrintable(i.key()) << " does not exist." << std::endl;
|
<< "for language" << qPrintable(i.key()) << "does not exist.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -735,15 +647,15 @@ QVariantMap AddKitData::addKit(const QVariantMap &map, const QVariantMap &tcMap,
|
|||||||
if (!qtId.isEmpty() && !qtId.startsWith("SDK."))
|
if (!qtId.isEmpty() && !qtId.startsWith("SDK."))
|
||||||
qtId = QString::fromLatin1("SDK.") + m_qt;
|
qtId = QString::fromLatin1("SDK.") + m_qt;
|
||||||
if (!qtId.isEmpty() && !AddQtData::exists(qtMap, qtId)) {
|
if (!qtId.isEmpty() && !AddQtData::exists(qtMap, qtId)) {
|
||||||
std::cerr << "Error: Qt " << qPrintable(qtId) << " does not exist." << std::endl;
|
qCCritical(addkitlog) << "Error: Qt" << qPrintable(qtId) << "does not exist.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
if (!m_device.isEmpty() && !AddDeviceOperation::exists(devMap, m_device)) {
|
if (!m_device.isEmpty() && !AddDeviceOperation::exists(devMap, m_device)) {
|
||||||
std::cerr << "Error: Device " << qPrintable(m_device) << " does not exist." << std::endl;
|
qCCritical(addkitlog) << "Error: Device" << qPrintable(m_device) << "does not exist.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
if (!m_buildDevice.isEmpty() && !AddDeviceOperation::exists(devMap, m_buildDevice)) {
|
if (!m_buildDevice.isEmpty() && !AddDeviceOperation::exists(devMap, m_buildDevice)) {
|
||||||
std::cerr << "Error: Device " << qPrintable(m_buildDevice) << " does not exist." << std::endl;
|
qCCritical(addkitlog) << "Error: Device" << qPrintable(m_buildDevice) << "does not exist.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,7 +664,7 @@ QVariantMap AddKitData::addKit(const QVariantMap &map, const QVariantMap &tcMap,
|
|||||||
qtId = "-1";
|
qtId = "-1";
|
||||||
|
|
||||||
if (!m_cmakeId.isEmpty() && !AddCMakeData::exists(cmakeMap, m_cmakeId)) {
|
if (!m_cmakeId.isEmpty() && !AddCMakeData::exists(cmakeMap, m_cmakeId)) {
|
||||||
std::cerr << "Error: CMake tool " << qPrintable(m_cmakeId) << " does not exist." << std::endl;
|
qCCritical(addkitlog) << "Error: CMake tool" << qPrintable(m_cmakeId) << "does not exist.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,7 +672,7 @@ QVariantMap AddKitData::addKit(const QVariantMap &map, const QVariantMap &tcMap,
|
|||||||
bool ok;
|
bool ok;
|
||||||
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
||||||
if (!ok || count < 0) {
|
if (!ok || count < 0) {
|
||||||
std::cerr << "Error: Count found in kits file seems wrong." << std::endl;
|
qCCritical(addkitlog) << "Error: Count found in kits file seems wrong.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
const QString kit = QString::fromLatin1(PREFIX) + QString::number(count);
|
const QString kit = QString::fromLatin1(PREFIX) + QString::number(count);
|
||||||
@@ -795,7 +707,8 @@ QVariantMap AddKitData::addKit(const QVariantMap &map, const QVariantMap &tcMap,
|
|||||||
if (!m_buildDevice.isNull())
|
if (!m_buildDevice.isNull())
|
||||||
data << KeyValuePair({kit, DATA, BUILDDEVICE_ID}, QVariant(m_buildDevice));
|
data << KeyValuePair({kit, DATA, BUILDDEVICE_ID}, QVariant(m_buildDevice));
|
||||||
if (!m_sysRoot.isNull())
|
if (!m_sysRoot.isNull())
|
||||||
data << KeyValuePair({kit, DATA, SYSROOT}, Utils::FilePath::fromUserInput(m_sysRoot).toVariant());
|
data << KeyValuePair({kit, DATA, SYSROOT},
|
||||||
|
Utils::FilePath::fromUserInput(m_sysRoot).toVariant());
|
||||||
for (auto i = m_tcs.constBegin(); i != m_tcs.constEnd(); ++i)
|
for (auto i = m_tcs.constBegin(); i != m_tcs.constEnd(); ++i)
|
||||||
data << KeyValuePair({kit, DATA, TOOLCHAIN, i.key()}, QVariant(i.value()));
|
data << KeyValuePair({kit, DATA, TOOLCHAIN, i.key()}, QVariant(i.value()));
|
||||||
if (!qtId.isNull())
|
if (!qtId.isNull())
|
||||||
|
@@ -73,6 +73,7 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@@ -35,7 +35,13 @@
|
|||||||
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
#include <iostream>
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(log, "qtc.sdktool.operations.addqt", QtWarningMsg)
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -87,7 +93,7 @@ bool AddQtOperation::setArguments(const QStringList &args)
|
|||||||
|
|
||||||
if (current == QLatin1String("--id")) {
|
if (current == QLatin1String("--id")) {
|
||||||
if (next.isNull()) {
|
if (next.isNull()) {
|
||||||
std::cerr << "Error parsing after --id." << std::endl << std::endl;
|
qCCritical(log) << "Error parsing after --id.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++i; // skip next;
|
++i; // skip next;
|
||||||
@@ -97,7 +103,7 @@ bool AddQtOperation::setArguments(const QStringList &args)
|
|||||||
|
|
||||||
if (current == QLatin1String("--name")) {
|
if (current == QLatin1String("--name")) {
|
||||||
if (next.isNull()) {
|
if (next.isNull()) {
|
||||||
std::cerr << "Error parsing after --name." << std::endl << std::endl;
|
qCCritical(log) << "Error parsing after --name.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++i; // skip next;
|
++i; // skip next;
|
||||||
@@ -107,7 +113,7 @@ bool AddQtOperation::setArguments(const QStringList &args)
|
|||||||
|
|
||||||
if (current == QLatin1String("--qmake")) {
|
if (current == QLatin1String("--qmake")) {
|
||||||
if (next.isNull()) {
|
if (next.isNull()) {
|
||||||
std::cerr << "Error parsing after --qmake." << std::endl << std::endl;
|
qCCritical(log) << "Error parsing after --qmake.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++i; // skip next;
|
++i; // skip next;
|
||||||
@@ -117,7 +123,7 @@ bool AddQtOperation::setArguments(const QStringList &args)
|
|||||||
|
|
||||||
if (current == QLatin1String("--type")) {
|
if (current == QLatin1String("--type")) {
|
||||||
if (next.isNull()) {
|
if (next.isNull()) {
|
||||||
std::cerr << "Error parsing after --type." << std::endl << std::endl;
|
qCCritical(log) << "Error parsing after --type.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++i; // skip next;
|
++i; // skip next;
|
||||||
@@ -127,7 +133,7 @@ bool AddQtOperation::setArguments(const QStringList &args)
|
|||||||
|
|
||||||
if (current == "--abis") {
|
if (current == "--abis") {
|
||||||
if (next.isNull()) {
|
if (next.isNull()) {
|
||||||
std::cerr << "Error parsing after --abis." << std::endl << std::endl;
|
qCCritical(log) << "Error parsing after --abis.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++i; // skip next;
|
++i; // skip next;
|
||||||
@@ -136,29 +142,29 @@ bool AddQtOperation::setArguments(const QStringList &args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (next.isNull()) {
|
if (next.isNull()) {
|
||||||
std::cerr << "Unknown parameter: " << qPrintable(current) << std::endl << std::endl;
|
qCCritical(log) << "Unknown parameter: " << qPrintable(current);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++i; // skip next;
|
++i; // skip next;
|
||||||
KeyValuePair pair(current, next);
|
KeyValuePair pair(current, next);
|
||||||
if (!pair.value.isValid()) {
|
if (!pair.value.isValid()) {
|
||||||
std::cerr << "Error parsing: " << qPrintable(current) << " " << qPrintable(next) << std::endl << std::endl;
|
qCCritical(log) << "Error parsing: " << qPrintable(current) << " " << qPrintable(next);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_extra << pair;
|
m_extra << pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_id.isEmpty())
|
if (m_id.isEmpty())
|
||||||
std::cerr << "Error no id was passed." << std::endl << std::endl;
|
qCCritical(log) << "Error no id was passed.";
|
||||||
|
|
||||||
if (m_displayName.isEmpty())
|
if (m_displayName.isEmpty())
|
||||||
std::cerr << "Error no display name was passed." << std::endl << std::endl;
|
qCCritical(log) << "Error no display name was passed.";
|
||||||
|
|
||||||
if (m_qmake.isEmpty())
|
if (m_qmake.isEmpty())
|
||||||
std::cerr << "Error no qmake was passed." << std::endl << std::endl;
|
qCCritical(log) << "Error no qmake was passed.";
|
||||||
|
|
||||||
if (m_type.isEmpty())
|
if (m_type.isEmpty())
|
||||||
std::cerr << "Error no type was passed." << std::endl << std::endl;
|
qCCritical(log) << "Error no type was passed.";
|
||||||
|
|
||||||
return !m_id.isEmpty() && !m_displayName.isEmpty() && !m_qmake.isEmpty() && !m_type.isEmpty();
|
return !m_id.isEmpty() && !m_displayName.isEmpty() && !m_qmake.isEmpty() && !m_type.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -178,93 +184,98 @@ int AddQtOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool AddQtOperation::test() const
|
void AddQtOperation::unittest()
|
||||||
{
|
{
|
||||||
AddQtData qtData;
|
|
||||||
QVariantMap map = initializeQtVersions();
|
QVariantMap map = initializeQtVersions();
|
||||||
|
|
||||||
if (map.count() != 1
|
QCOMPARE(map.count(), 1);
|
||||||
|| !map.contains(QLatin1String(VERSION))
|
QVERIFY(map.contains(QLatin1String(VERSION)));
|
||||||
|| map.value(QLatin1String(VERSION)).toInt() != 1)
|
QCOMPARE(map.value(QLatin1String(VERSION)).toInt(), 1);
|
||||||
return false;
|
|
||||||
|
AddQtData qtData;
|
||||||
|
qtData.m_id = "{some-qt-id}";
|
||||||
|
qtData.m_displayName = "Test Qt Version";
|
||||||
|
qtData.m_type = "testType";
|
||||||
|
qtData.m_qmake = "/tmp//../tmp/test/qmake";
|
||||||
|
qtData.m_abis = {};
|
||||||
|
qtData.m_extra = {{QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))}};
|
||||||
|
|
||||||
#if defined Q_OS_WIN
|
|
||||||
qtData = {"{some-qt-id}", "Test Qt Version", "testType", "/tmp//../tmp/test\\qmake", {},
|
|
||||||
{{QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))}}};
|
|
||||||
#else
|
|
||||||
qtData = {"{some-qt-id}", "Test Qt Version", "testType", "/tmp//../tmp/test/qmake", {},
|
|
||||||
{{QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))}}};
|
|
||||||
#endif
|
|
||||||
map = qtData.addQt(map);
|
map = qtData.addQt(map);
|
||||||
|
|
||||||
if (map.count() != 2
|
QCOMPARE(map.count(), 2);
|
||||||
|| !map.contains(QLatin1String(VERSION))
|
QVERIFY(map.contains(QLatin1String(VERSION)));
|
||||||
|| map.value(QLatin1String(VERSION)).toInt() != 1
|
QVERIFY(map.contains(QLatin1String("QtVersion.0")));
|
||||||
|| !map.contains(QLatin1String("QtVersion.0")))
|
QCOMPARE(map.value(QLatin1String(VERSION)).toInt(),1);
|
||||||
return false;
|
|
||||||
|
|
||||||
QVariantMap version0 = map.value(QLatin1String("QtVersion.0")).toMap();
|
QVariantMap version0 = map.value(QLatin1String("QtVersion.0")).toMap();
|
||||||
if (version0.count() != 8
|
QCOMPARE(version0.count(), 8);
|
||||||
|| !version0.contains(QLatin1String(ID))
|
QVERIFY(version0.contains(QLatin1String(ID)));
|
||||||
|| version0.value(QLatin1String(ID)).toInt() != -1
|
QCOMPARE(version0.value(QLatin1String(ID)).toInt(), -1);
|
||||||
|| !version0.contains(QLatin1String(DISPLAYNAME))
|
QVERIFY(version0.contains(QLatin1String(DISPLAYNAME)));
|
||||||
|| version0.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Qt Version")
|
QCOMPARE(version0.value(QLatin1String(DISPLAYNAME)).toString(), QLatin1String("Test Qt Version"));
|
||||||
|| !version0.contains(QLatin1String(AUTODETECTED))
|
QVERIFY(version0.contains(QLatin1String(AUTODETECTED)));
|
||||||
|| version0.value(QLatin1String(AUTODETECTED)).toBool() != true
|
QCOMPARE(version0.value(QLatin1String(AUTODETECTED)).toBool(), true);
|
||||||
|| !version0.contains(QLatin1String(AUTODETECTION_SOURCE))
|
QVERIFY(version0.contains(QLatin1String(AUTODETECTION_SOURCE)));
|
||||||
|| version0.value(QLatin1String(AUTODETECTION_SOURCE)).toString() != QLatin1String("SDK.{some-qt-id}")
|
QCOMPARE(version0.value(QLatin1String(AUTODETECTION_SOURCE)).toString(), QLatin1String("SDK.{some-qt-id}"));
|
||||||
|| !version0.contains(QLatin1String(TYPE))
|
QVERIFY(version0.contains(QLatin1String(TYPE)));
|
||||||
|| version0.value(QLatin1String(TYPE)).toString() != QLatin1String("testType")
|
QCOMPARE(version0.value(QLatin1String(TYPE)).toString(), QLatin1String("testType"));
|
||||||
|| !version0.contains(QLatin1String(ABIS))
|
QVERIFY(version0.contains(QLatin1String(ABIS)));
|
||||||
|| version0.value(QLatin1String(ABIS)).toStringList() != QStringList()
|
QCOMPARE(version0.value(QLatin1String(ABIS)).toStringList(), QStringList());
|
||||||
|| !version0.contains(QLatin1String(QMAKE))
|
QVERIFY(version0.contains(QLatin1String(QMAKE)));
|
||||||
|| version0.value(QLatin1String(QMAKE)).toString() != QLatin1String("/tmp/test/qmake")
|
QCOMPARE(version0.value(QLatin1String(QMAKE)).toString(), QLatin1String("/tmp/test/qmake"));
|
||||||
|| !version0.contains(QLatin1String("extraData"))
|
QVERIFY(version0.contains(QLatin1String("extraData")));
|
||||||
|| version0.value(QLatin1String("extraData")).toString() != QLatin1String("extraValue"))
|
QCOMPARE(version0.value(QLatin1String("extraData")).toString(), QLatin1String("extraValue"));
|
||||||
return false;
|
|
||||||
|
|
||||||
// Ignore existing ids:
|
// Ignore existing ids:
|
||||||
qtData = {"{some-qt-id}", "Test Qt Version2", "testType2", "/tmp/test/qmake2", {},
|
qtData.m_id = "{some-qt-id}";
|
||||||
{{QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))}}};
|
qtData.m_displayName = "Test Qt Version2";
|
||||||
|
qtData.m_type = "testType2";
|
||||||
|
qtData.m_qmake = "/tmp/test/qmake2";
|
||||||
|
qtData.m_abis = {};
|
||||||
|
qtData.m_extra = {{QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))}};
|
||||||
|
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
|
QRegularExpression("Error: Id .* already defined as Qt versions."));
|
||||||
|
|
||||||
QVariantMap result = qtData.addQt(map);
|
QVariantMap result = qtData.addQt(map);
|
||||||
if (!result.isEmpty())
|
QVERIFY(result.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
// add 2nd Qt version:
|
// add 2nd Qt version:
|
||||||
qtData = {"testId2", "Test Qt Version", "testType3", "/tmp/test/qmake2", {},
|
qtData.m_id = "testId2";
|
||||||
{{QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))}}};
|
qtData.m_displayName = "Test Qt Version";
|
||||||
map = qtData.addQt(map);
|
qtData.m_type = "testType3";
|
||||||
if (map.count() != 3
|
qtData.m_qmake = "/tmp/test/qmake2";
|
||||||
|| !map.contains(QLatin1String(VERSION))
|
qtData.m_abis = {};
|
||||||
|| map.value(QLatin1String(VERSION)).toInt() != 1
|
qtData.m_extra = {{QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))}};
|
||||||
|| !map.contains(QLatin1String("QtVersion.0"))
|
|
||||||
|| !map.contains(QLatin1String("QtVersion.1")))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (map.value(QLatin1String("QtVersion.0")) != version0)
|
map = qtData.addQt(map);
|
||||||
return false;
|
|
||||||
|
QCOMPARE(map.count(), 3);
|
||||||
|
QVERIFY(map.contains(QLatin1String(VERSION)));
|
||||||
|
QCOMPARE(map.value(QLatin1String(VERSION)).toInt(), 1);
|
||||||
|
QVERIFY(map.contains(QLatin1String("QtVersion.0")));
|
||||||
|
QVERIFY(map.contains(QLatin1String("QtVersion.1")));
|
||||||
|
|
||||||
|
QCOMPARE(map.value(QLatin1String("QtVersion.0")), version0);
|
||||||
|
|
||||||
QVariantMap version1 = map.value(QLatin1String("QtVersion.1")).toMap();
|
QVariantMap version1 = map.value(QLatin1String("QtVersion.1")).toMap();
|
||||||
if (version1.count() != 8
|
QCOMPARE(version1.count(), 8);
|
||||||
|| !version1.contains(QLatin1String(ID))
|
QVERIFY(version1.contains(QLatin1String(ID)));
|
||||||
|| version1.value(QLatin1String(ID)).toInt() != -1
|
QCOMPARE(version1.value(QLatin1String(ID)).toInt(), -1);
|
||||||
|| !version1.contains(QLatin1String(DISPLAYNAME))
|
QVERIFY(version1.contains(QLatin1String(DISPLAYNAME)));
|
||||||
|| version1.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Qt Version")
|
QCOMPARE(version1.value(QLatin1String(DISPLAYNAME)).toString(), QLatin1String("Test Qt Version"));
|
||||||
|| !version1.contains(QLatin1String(AUTODETECTED))
|
QVERIFY(version1.contains(QLatin1String(AUTODETECTED)));
|
||||||
|| version1.value(QLatin1String(AUTODETECTED)).toBool() != true
|
QCOMPARE(version1.value(QLatin1String(AUTODETECTED)).toBool(), true);
|
||||||
|| !version1.contains(QLatin1String(AUTODETECTION_SOURCE))
|
QVERIFY(version1.contains(QLatin1String(AUTODETECTION_SOURCE)));
|
||||||
|| version1.value(QLatin1String(AUTODETECTION_SOURCE)).toString() != QLatin1String("SDK.testId2")
|
QCOMPARE(version1.value(QLatin1String(AUTODETECTION_SOURCE)).toString(), QLatin1String("SDK.testId2"));
|
||||||
|| !version1.contains(QLatin1String(TYPE))
|
QVERIFY(version1.contains(QLatin1String(TYPE)));
|
||||||
|| version1.value(QLatin1String(TYPE)).toString() != QLatin1String("testType3")
|
QCOMPARE(version1.value(QLatin1String(TYPE)).toString(), QLatin1String("testType3"));
|
||||||
|| !version1.contains(QLatin1String(ABIS))
|
QVERIFY(version1.contains(QLatin1String(ABIS)));
|
||||||
|| version1.value(QLatin1String(ABIS)).toStringList() != QStringList()
|
QCOMPARE(version1.value(QLatin1String(ABIS)).toStringList(), QStringList());
|
||||||
|| !version1.contains(QLatin1String(QMAKE))
|
QVERIFY(version1.contains(QLatin1String(QMAKE)));
|
||||||
|| version1.value(QLatin1String(QMAKE)).toString() != QLatin1String("/tmp/test/qmake2")
|
QCOMPARE(version1.value(QLatin1String(QMAKE)).toString(), QLatin1String("/tmp/test/qmake2"));
|
||||||
|| !version1.contains(QLatin1String("extraData"))
|
QVERIFY(version1.contains(QLatin1String("extraData")));
|
||||||
|| version1.value(QLatin1String("extraData")).toString() != QLatin1String("extraValue"))
|
QCOMPARE(version1.value(QLatin1String("extraData")).toString(), QLatin1String("extraValue"));
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -274,7 +285,7 @@ QVariantMap AddQtData::addQt(const QVariantMap &map) const
|
|||||||
|
|
||||||
// Sanity check: Make sure autodetection source is not in use already:
|
// Sanity check: Make sure autodetection source is not in use already:
|
||||||
if (exists(map, sdkId)) {
|
if (exists(map, sdkId)) {
|
||||||
std::cerr << "Error: Id " << qPrintable(m_id) << " already defined as Qt versions." << std::endl;
|
qCCritical(log) << "Error: Id" << qPrintable(m_id) << "already defined as Qt versions.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,6 +55,8 @@ private:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
public:
|
||||||
|
static void unittest();
|
||||||
|
// TODO: Remove
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@@ -35,6 +35,14 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(addtoolchainlog, "qtc.sdktool.operations.addtoolchain", QtWarningMsg)
|
||||||
|
|
||||||
// ToolChain file stuff:
|
// ToolChain file stuff:
|
||||||
const char COUNT[] = "ToolChain.Count";
|
const char COUNT[] = "ToolChain.Count";
|
||||||
const char PREFIX[] = "ToolChain.";
|
const char PREFIX[] = "ToolChain.";
|
||||||
@@ -80,7 +88,9 @@ bool AddToolChainOperation::setArguments(const QStringList &args)
|
|||||||
const QString next = ((i + 1) < args.count()) ? args.at(i + 1) : QString();
|
const QString next = ((i + 1) < args.count()) ? args.at(i + 1) : QString();
|
||||||
|
|
||||||
if (next.isNull() && current.startsWith("--")) {
|
if (next.isNull() && current.startsWith("--")) {
|
||||||
std::cerr << "No parameter for option '" << qPrintable(current) << "' given." << std::endl << std::endl;
|
std::cerr << "No parameter for option '" << qPrintable(current) << "' given."
|
||||||
|
<< std::endl
|
||||||
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +159,8 @@ bool AddToolChainOperation::setArguments(const QStringList &args)
|
|||||||
if (m_targetAbi.isEmpty())
|
if (m_targetAbi.isEmpty())
|
||||||
std::cerr << "No target abi given for tool chain." << std::endl;
|
std::cerr << "No target abi given for tool chain." << std::endl;
|
||||||
|
|
||||||
return !m_id.isEmpty() && !m_displayName.isEmpty() && !m_path.isEmpty() && !m_targetAbi.isEmpty();
|
return !m_id.isEmpty() && !m_displayName.isEmpty() && !m_path.isEmpty()
|
||||||
|
&& !m_targetAbi.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
int AddToolChainOperation::execute() const
|
int AddToolChainOperation::execute() const
|
||||||
@@ -166,66 +177,87 @@ int AddToolChainOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool AddToolChainOperation::test() const
|
void AddToolChainOperation::unittest()
|
||||||
{
|
{
|
||||||
QVariantMap map = initializeToolChains();
|
QVariantMap map = initializeToolChains();
|
||||||
|
|
||||||
// Add toolchain:
|
// Add toolchain:
|
||||||
map = AddToolChainData{"testId", "langId", "name", "/tmp/test", "test-abi", "test-abi,test-abi2",
|
AddToolChainData d;
|
||||||
{{"ExtraKey", QVariant("ExtraValue")}}}.addToolChain(map);
|
d.m_id = "testId";
|
||||||
if (map.value(COUNT).toInt() != 1
|
d.m_languageId = "langId";
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '0'))
|
d.m_displayName = "name";
|
||||||
return false;
|
d.m_path = "/tmp/test";
|
||||||
|
d.m_targetAbi = "test-abi";
|
||||||
|
d.m_supportedAbis = "test-abi,test-abi2";
|
||||||
|
d.m_extra = {{"ExtraKey", QVariant("ExtraValue")}};
|
||||||
|
|
||||||
|
map = d.addToolChain(map);
|
||||||
|
QCOMPARE(map.value(COUNT).toInt(), 1);
|
||||||
|
QVERIFY(map.contains(QString::fromLatin1(PREFIX) + '0'));
|
||||||
|
|
||||||
QVariantMap tcData = map.value(QString::fromLatin1(PREFIX) + '0').toMap();
|
QVariantMap tcData = map.value(QString::fromLatin1(PREFIX) + '0').toMap();
|
||||||
if (tcData.count() != 8
|
QCOMPARE(tcData.count(), 8);
|
||||||
|| tcData.value(ID).toString() != "testId"
|
QCOMPARE(tcData.value(ID).toString(), "testId");
|
||||||
|| tcData.value(LANGUAGE_KEY_V2).toString() != "langId"
|
QCOMPARE(tcData.value(LANGUAGE_KEY_V2).toString(), "langId");
|
||||||
|| tcData.value(DISPLAYNAME).toString() != "name"
|
QCOMPARE(tcData.value(DISPLAYNAME).toString(), "name");
|
||||||
|| tcData.value(AUTODETECTED).toBool() != true
|
QCOMPARE(tcData.value(AUTODETECTED).toBool(), true);
|
||||||
|| tcData.value(PATH).toString() != "/tmp/test"
|
QCOMPARE(tcData.value(PATH).toString(), "/tmp/test");
|
||||||
|| tcData.value(TARGET_ABI).toString() != "test-abi"
|
QCOMPARE(tcData.value(TARGET_ABI).toString(), "test-abi");
|
||||||
|| tcData.value(SUPPORTED_ABIS).toList().count() != 2
|
QCOMPARE(tcData.value(SUPPORTED_ABIS).toList().count(), 2);
|
||||||
|| tcData.value("ExtraKey").toString() != "ExtraValue")
|
QCOMPARE(tcData.value("ExtraKey").toString(), "ExtraValue");
|
||||||
return false;
|
|
||||||
|
|
||||||
// Ignore same Id:
|
// Ignore same Id:
|
||||||
QVariantMap unchanged = AddToolChainData{"testId", "langId", "name2", "/tmp/test2", "test-abi2",
|
AddToolChainData ud;
|
||||||
"test-abi2,test-abi3",
|
ud.m_id = "testId";
|
||||||
{{"ExtraKey", QVariant("ExtraValue2")}}}.addToolChain(map);
|
ud.m_languageId = "langId";
|
||||||
if (!unchanged.isEmpty())
|
ud.m_displayName = "name2";
|
||||||
return false;
|
ud.m_path = "/tmp/test2";
|
||||||
|
ud.m_targetAbi = "test-abi2";
|
||||||
|
ud.m_supportedAbis = "test-abi2,test-abi3";
|
||||||
|
ud.m_extra = {{"ExtraKey", QVariant("ExtraValue")}};
|
||||||
|
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
|
QRegularExpression("Error: Id .* already defined for tool chains."));
|
||||||
|
|
||||||
|
QVariantMap unchanged = ud.addToolChain(map);
|
||||||
|
QVERIFY(unchanged.isEmpty());
|
||||||
|
|
||||||
// add 2nd tool chain:
|
// add 2nd tool chain:
|
||||||
map = AddToolChainData{"{some-tc-id}", "langId2", "name", "/tmp/test", "test-abi", "test-abi,test-abi2",
|
AddToolChainData d2;
|
||||||
{{"ExtraKey", QVariant("ExtraValue")}}}.addToolChain(map);
|
d2.m_id = "{some-tc-id}";
|
||||||
if (map.value(COUNT).toInt() != 2
|
d2.m_languageId = "langId2";
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '0')
|
d2.m_displayName = "name";
|
||||||
|| !map.contains(QString::fromLatin1(PREFIX) + '1'))
|
d2.m_path = "/tmp/test";
|
||||||
return false;
|
d2.m_targetAbi = "test-abi";
|
||||||
tcData = map.value(QString::fromLatin1(PREFIX) + '0').toMap();
|
d2.m_supportedAbis = "test-abi,test-abi2";
|
||||||
if (tcData.count() != 8
|
d2.m_extra = {{"ExtraKey", QVariant("ExtraValue")}};
|
||||||
|| tcData.value(ID).toString() != "testId"
|
|
||||||
|| tcData.value(LANGUAGE_KEY_V2).toString() != "langId"
|
|
||||||
|| tcData.value(DISPLAYNAME).toString() != "name"
|
|
||||||
|| tcData.value(AUTODETECTED).toBool() != true
|
|
||||||
|| tcData.value(PATH).toString() != "/tmp/test"
|
|
||||||
|| tcData.value(TARGET_ABI).toString() != "test-abi"
|
|
||||||
|| tcData.value(SUPPORTED_ABIS).toList().count() != 2
|
|
||||||
|| tcData.value("ExtraKey").toString() != "ExtraValue")
|
|
||||||
return false;
|
|
||||||
tcData = map.value(QString::fromLatin1(PREFIX) + '1').toMap();
|
|
||||||
if (tcData.count() != 8
|
|
||||||
|| tcData.value(ID).toString() != "{some-tc-id}"
|
|
||||||
|| tcData.value(LANGUAGE_KEY_V2).toString() != "langId2"
|
|
||||||
|| tcData.value(DISPLAYNAME).toString() != "name"
|
|
||||||
|| tcData.value(AUTODETECTED).toBool() != true
|
|
||||||
|| tcData.value(PATH).toString() != "/tmp/test"
|
|
||||||
|| tcData.value(TARGET_ABI).toString() != "test-abi"
|
|
||||||
|| tcData.value(SUPPORTED_ABIS).toList().count() != 2
|
|
||||||
|| tcData.value("ExtraKey").toString() != "ExtraValue")
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
map = d2.addToolChain(map);
|
||||||
|
QCOMPARE(map.value(COUNT).toInt(), 2);
|
||||||
|
QVERIFY(map.contains(QString::fromLatin1(PREFIX) + '0'));
|
||||||
|
QVERIFY(map.contains(QString::fromLatin1(PREFIX) + '1'));
|
||||||
|
|
||||||
|
tcData = map.value(QString::fromLatin1(PREFIX) + '0').toMap();
|
||||||
|
QCOMPARE(tcData.count(), 8);
|
||||||
|
QCOMPARE(tcData.value(ID).toString(), "testId");
|
||||||
|
QCOMPARE(tcData.value(LANGUAGE_KEY_V2).toString(), "langId");
|
||||||
|
QCOMPARE(tcData.value(DISPLAYNAME).toString(), "name");
|
||||||
|
QVERIFY(tcData.value(AUTODETECTED).toBool());
|
||||||
|
QCOMPARE(tcData.value(PATH).toString(), "/tmp/test");
|
||||||
|
QCOMPARE(tcData.value(TARGET_ABI).toString(), "test-abi");
|
||||||
|
QCOMPARE(tcData.value(SUPPORTED_ABIS).toList().count(), 2);
|
||||||
|
QCOMPARE(tcData.value("ExtraKey").toString(), "ExtraValue");
|
||||||
|
|
||||||
|
tcData = map.value(QString::fromLatin1(PREFIX) + '1').toMap();
|
||||||
|
QCOMPARE(tcData.count(), 8);
|
||||||
|
QCOMPARE(tcData.value(ID).toString(), "{some-tc-id}");
|
||||||
|
QCOMPARE(tcData.value(LANGUAGE_KEY_V2).toString(), "langId2");
|
||||||
|
QCOMPARE(tcData.value(DISPLAYNAME).toString(), "name");
|
||||||
|
QVERIFY(tcData.value(AUTODETECTED).toBool());
|
||||||
|
QCOMPARE(tcData.value(PATH).toString(), "/tmp/test");
|
||||||
|
QCOMPARE(tcData.value(TARGET_ABI).toString(), "test-abi");
|
||||||
|
QCOMPARE(tcData.value(SUPPORTED_ABIS).toList().count(), 2);
|
||||||
|
QCOMPARE(tcData.value("ExtraKey").toString(), "ExtraValue");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -233,7 +265,8 @@ QVariantMap AddToolChainData::addToolChain(const QVariantMap &map) const
|
|||||||
{
|
{
|
||||||
// Sanity check: Does the Id already exist?
|
// Sanity check: Does the Id already exist?
|
||||||
if (exists(map, m_id)) {
|
if (exists(map, m_id)) {
|
||||||
std::cerr << "Error: Id " << qPrintable(m_id) << " already defined for tool chains." << std::endl;
|
qCCritical(addtoolchainlog)
|
||||||
|
<< "Error: Id" << qPrintable(m_id) << "already defined for tool chains.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +274,7 @@ QVariantMap AddToolChainData::addToolChain(const QVariantMap &map) const
|
|||||||
bool ok;
|
bool ok;
|
||||||
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
||||||
if (!ok || count < 0) {
|
if (!ok || count < 0) {
|
||||||
std::cerr << "Error: Count found in toolchains file seems wrong." << std::endl;
|
qCCritical(addtoolchainlog) << "Error: Count found in toolchains file seems wrong.";
|
||||||
return QVariantMap();
|
return QVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,9 +294,9 @@ QVariantMap AddToolChainData::addToolChain(const QVariantMap &map) const
|
|||||||
} else if (m_languageId == "1" || m_languageId == "C") {
|
} else if (m_languageId == "1" || m_languageId == "C") {
|
||||||
newLang = "C";
|
newLang = "C";
|
||||||
} else if (ok) {
|
} else if (ok) {
|
||||||
std::cerr << "Error: Language ID must be 1 for C, 2 for Cxx "
|
qCCritical(addtoolchainlog) << "Error: Language ID must be 1 for C, 2 for Cxx "
|
||||||
<< "or a string like \"C\", \"Cxx\", \"Nim\" (was \""
|
<< "or a string like \"C\", \"Cxx\", \"Nim\" (was \""
|
||||||
<< qPrintable(m_languageId) << "\")" << std::endl;
|
<< qPrintable(m_languageId) << "\")";
|
||||||
return {};
|
return {};
|
||||||
} else if (!ok) {
|
} else if (!ok) {
|
||||||
newLang = m_languageId;
|
newLang = m_languageId;
|
||||||
|
@@ -58,6 +58,7 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@@ -33,6 +33,14 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(addvaluelog, "qtc.sdktool.operations.addvalue", QtWarningMsg)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr auto SUCCESS = 0;
|
constexpr auto SUCCESS = 0;
|
||||||
constexpr auto FAILURE = !SUCCESS;
|
constexpr auto FAILURE = !SUCCESS;
|
||||||
@@ -111,7 +119,7 @@ int AddValueOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool AddValueOperation::test() const
|
void AddValueOperation::unittest()
|
||||||
{
|
{
|
||||||
QVariantList testDataList;
|
QVariantList testDataList;
|
||||||
testDataList.append(QLatin1String("Some String"));
|
testDataList.append(QLatin1String("Some String"));
|
||||||
@@ -127,40 +135,44 @@ bool AddValueOperation::test() const
|
|||||||
QVariantMap testMap;
|
QVariantMap testMap;
|
||||||
|
|
||||||
// add to empty map
|
// add to empty map
|
||||||
bool result = AddValueData{"some key", valueList}.appendListToMap(testMap);
|
AddValueData d;
|
||||||
|
d.m_key = "some key";
|
||||||
|
d.m_values = valueList;
|
||||||
|
|
||||||
if (result)
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
return false;
|
QRegularExpression("Error: Could not retrieve value for key .*."));
|
||||||
|
|
||||||
|
QVERIFY(!d.appendListToMap(testMap));
|
||||||
|
|
||||||
testMap.insert(QLatin1String("someEmptyThing"), QVariantMap());
|
testMap.insert(QLatin1String("someEmptyThing"), QVariantMap());
|
||||||
testMap.insert(QLatin1String("aKey"), "withAString");
|
testMap.insert(QLatin1String("aKey"), "withAString");
|
||||||
|
|
||||||
// append to a value
|
// append to a value
|
||||||
result = AddValueData{"aKey", valueList}.appendListToMap(testMap);
|
d.m_key = "aKey";
|
||||||
|
|
||||||
if (result)
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
return false;
|
QRegularExpression("Error: Data stored in .* is not a QVariantList."));
|
||||||
|
|
||||||
|
QVERIFY(!d.appendListToMap(testMap));
|
||||||
|
|
||||||
testMap = AddKeysData{testKvpList}.addKeys(testMap);
|
testMap = AddKeysData{testKvpList}.addKeys(testMap);
|
||||||
|
|
||||||
// quick sanity check
|
// quick sanity check
|
||||||
if (testMap.count() != 3 && testDataList.count() != 2 && testKvpList.count() != 3)
|
QCOMPARE(testMap.count(), 3);
|
||||||
return false;
|
QCOMPARE(testDataList.count(), 2);
|
||||||
|
QCOMPARE(testKvpList.count(), 3);
|
||||||
|
|
||||||
// successful adding of values
|
// successful adding of values
|
||||||
result = AddValueData{"test/bar", valueList}.appendListToMap(testMap);
|
d.m_key = "test/bar";
|
||||||
if (!result)
|
QVERIFY(d.appendListToMap(testMap));
|
||||||
return false;
|
|
||||||
|
|
||||||
const auto newList = qvariant_cast<QVariantList>(GetOperation::get(testMap, "test/bar"));
|
const auto newList = qvariant_cast<QVariantList>(GetOperation::get(testMap, "test/bar"));
|
||||||
if (newList.count() != (testDataList.count() + valueList.count()))
|
QCOMPARE(newList.count(), (testDataList.count() + valueList.count()));
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!newList.contains(1860) || !newList.contains(QString("Some String"))
|
QVERIFY(newList.contains(1860));
|
||||||
|| !newList.contains("ELIL") || !newList.contains(-1))
|
QVERIFY(newList.contains(QString("Some String")));
|
||||||
return false;
|
QVERIFY(newList.contains("ELIL"));
|
||||||
|
QVERIFY(newList.contains(-1));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -169,14 +181,14 @@ bool AddValueData::appendListToMap(QVariantMap &map) const
|
|||||||
const QVariant data = GetOperation::get(map, m_key);
|
const QVariant data = GetOperation::get(map, m_key);
|
||||||
|
|
||||||
if (!data.isValid() || data.isNull()) {
|
if (!data.isValid() || data.isNull()) {
|
||||||
std::cerr << "Error: Could not retrieve value for key " << std::quoted(m_key.toStdString())
|
qCCritical(addvaluelog) << "Error: Could not retrieve value for key"
|
||||||
<< std::endl;
|
<< m_key;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.type() != QVariant::List) {
|
if (data.type() != QVariant::List) {
|
||||||
std::cerr << "Error: Data stored in " << std::quoted(m_key.toStdString())
|
qCCritical(addvaluelog) << "Error: Data stored in" << m_key
|
||||||
<< " is not a QVariantList." << std::endl;
|
<< "is not a QVariantList.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -27,6 +27,15 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(findkeylog, "qtc.sdktool.operations.findkey", QtWarningMsg)
|
||||||
|
|
||||||
|
|
||||||
QString FindKeyOperation::name() const
|
QString FindKeyOperation::name() const
|
||||||
{
|
{
|
||||||
return QLatin1String("findKey");
|
return QLatin1String("findKey");
|
||||||
@@ -57,9 +66,9 @@ bool FindKeyOperation::setArguments(const QStringList &args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_file.isEmpty())
|
if (m_file.isEmpty())
|
||||||
std::cerr << "No file given." << std::endl << std::endl;
|
qCCritical(findkeylog) << "No file given.";
|
||||||
if (m_keys.isEmpty())
|
if (m_keys.isEmpty())
|
||||||
std::cerr << "No keys given." << std::endl << std::endl;
|
qCCritical(findkeylog) << "No keys given.";
|
||||||
|
|
||||||
return (!m_file.isEmpty() && !m_keys.isEmpty());
|
return (!m_file.isEmpty() && !m_keys.isEmpty());
|
||||||
}
|
}
|
||||||
@@ -69,17 +78,18 @@ int FindKeyOperation::execute() const
|
|||||||
Q_ASSERT(!m_keys.isEmpty());
|
Q_ASSERT(!m_keys.isEmpty());
|
||||||
QVariantMap map = load(m_file);
|
QVariantMap map = load(m_file);
|
||||||
|
|
||||||
foreach (const QString &k, m_keys) {
|
for (const auto &k : m_keys) {
|
||||||
const QStringList result = findKey(map, k);
|
const QStringList result = findKey(map, k);
|
||||||
foreach (const QString &r, result)
|
for (const auto &r: result) {
|
||||||
std::cout << qPrintable(r) << std::endl;
|
std::cout << qPrintable(r) << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool FindKeyOperation::test() const
|
void FindKeyOperation::unittest()
|
||||||
{
|
{
|
||||||
QVariantMap testMap;
|
QVariantMap testMap;
|
||||||
QVariantMap subKeys;
|
QVariantMap subKeys;
|
||||||
@@ -108,26 +118,20 @@ bool FindKeyOperation::test() const
|
|||||||
|
|
||||||
QStringList result;
|
QStringList result;
|
||||||
result = findKey(testMap, QLatin1String("missing"));
|
result = findKey(testMap, QLatin1String("missing"));
|
||||||
if (!result.isEmpty())
|
QVERIFY(result.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
result = findKey(testMap, QLatin1String("testint"));
|
result = findKey(testMap, QLatin1String("testint"));
|
||||||
if (result.count() != 2
|
QCOMPARE(result.count(), 2);
|
||||||
|| !result.contains(QLatin1String("testint"))
|
QVERIFY(result.contains(QLatin1String("testint")));
|
||||||
|| !result.contains(QLatin1String("subkeys/subsubkeys/testint")))
|
QVERIFY(result.contains(QLatin1String("subkeys/subsubkeys/testint")));
|
||||||
return false;
|
|
||||||
|
|
||||||
result = findKey(testMap, QLatin1String("testbool"));
|
result = findKey(testMap, QLatin1String("testbool"));
|
||||||
if (result.count() != 2
|
QCOMPARE(result.count(), 2);
|
||||||
|| !result.contains(QLatin1String("testbool")))
|
QVERIFY(result.contains(QLatin1String("testbool")));
|
||||||
return false;
|
|
||||||
|
|
||||||
result = findKey(testMap, QLatin1String("findMe"));
|
result = findKey(testMap, QLatin1String("findMe"));
|
||||||
if (result.count() != 1
|
QCOMPARE(result.count(), 1);
|
||||||
|| !result.contains(QLatin1String("aList[2][1]/findMe")))
|
QVERIFY(result.contains(QLatin1String("aList[2][1]/findMe")));
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -39,11 +39,11 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QStringList findKey(const QVariant &in, const QString &key,
|
static QStringList findKey(const QVariant &in, const QString &key,
|
||||||
const QString &prefix = QString());
|
const QString &prefix = QString());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_file;
|
QString m_file;
|
||||||
QStringList m_keys;
|
QStringList m_keys;
|
||||||
|
@@ -27,6 +27,14 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(findvaluelog, "qtc.sdktool.operations.findvalue", QtWarningMsg)
|
||||||
|
|
||||||
QString FindValueOperation::name() const
|
QString FindValueOperation::name() const
|
||||||
{
|
{
|
||||||
return QLatin1String("find");
|
return QLatin1String("find");
|
||||||
@@ -55,16 +63,16 @@ bool FindValueOperation::setArguments(const QStringList &args)
|
|||||||
|
|
||||||
QVariant v = valueFromString(current);
|
QVariant v = valueFromString(current);
|
||||||
if (!v.isValid()) {
|
if (!v.isValid()) {
|
||||||
std::cerr << "Value for key '" << qPrintable(current) << "' is not valid." << std::endl << std::endl;
|
qCCritical(findvaluelog) << "Value for key '" << qPrintable(current) << "' is not valid.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_values << v;
|
m_values << v;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_file.isEmpty())
|
if (m_file.isEmpty())
|
||||||
std::cerr << "No file given." << std::endl << std::endl;
|
qCCritical(findvaluelog) << "No file given.";
|
||||||
if (m_values.isEmpty())
|
if (m_values.isEmpty())
|
||||||
std::cerr << "No values given." << std::endl << std::endl;
|
qCCritical(findvaluelog) << "No values given.";
|
||||||
|
|
||||||
return (!m_file.isEmpty() && !m_values.isEmpty());
|
return (!m_file.isEmpty() && !m_values.isEmpty());
|
||||||
}
|
}
|
||||||
@@ -84,7 +92,7 @@ int FindValueOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool FindValueOperation::test() const
|
void FindValueOperation::unittest()
|
||||||
{
|
{
|
||||||
QVariantMap testMap;
|
QVariantMap testMap;
|
||||||
QVariantMap subKeys;
|
QVariantMap subKeys;
|
||||||
@@ -114,26 +122,21 @@ bool FindValueOperation::test() const
|
|||||||
|
|
||||||
QStringList result;
|
QStringList result;
|
||||||
result = findValue(testMap, QVariant(23));
|
result = findValue(testMap, QVariant(23));
|
||||||
if (result.count() != 1
|
QCOMPARE(result.count(), 1);
|
||||||
|| !result.contains(QLatin1String("testint")))
|
QVERIFY(result.contains(QLatin1String("testint")));
|
||||||
return false;
|
|
||||||
|
|
||||||
result = findValue(testMap, QVariant(53));
|
result = findValue(testMap, QVariant(53));
|
||||||
if (result.count() != 2
|
QCOMPARE(result.count(), 2);
|
||||||
|| !result.contains(QLatin1String("subkeys/subsubkeys/testint2"))
|
|
||||||
|| !result.contains(QLatin1String("subkeys/otherint")))
|
QVERIFY(result.contains(QLatin1String("subkeys/subsubkeys/testint2")));
|
||||||
return false;
|
QVERIFY(result.contains(QLatin1String("subkeys/otherint")));
|
||||||
|
|
||||||
result = findValue(testMap, QVariant(23456));
|
result = findValue(testMap, QVariant(23456));
|
||||||
if (!result.isEmpty())
|
QVERIFY(result.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
result = findValue(testMap, QVariant(QString::fromLatin1("FindInList")));
|
result = findValue(testMap, QVariant(QString::fromLatin1("FindInList")));
|
||||||
if (result.count() != 1
|
QCOMPARE(result.count(), 1);
|
||||||
|| !result.contains(QLatin1String("aList[2][1]/findMe")))
|
QVERIFY(result.contains(QLatin1String("aList[2][1]/findMe")));
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QStringList findValue(const QVariant &in, const QVariant &value,
|
static QStringList findValue(const QVariant &in, const QVariant &value,
|
||||||
|
@@ -27,6 +27,14 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(getlog, "qtc.sdktool.operations.get", QtWarningMsg)
|
||||||
|
|
||||||
QString GetOperation::name() const
|
QString GetOperation::name() const
|
||||||
{
|
{
|
||||||
return QLatin1String("get");
|
return QLatin1String("get");
|
||||||
@@ -52,9 +60,9 @@ bool GetOperation::setArguments(const QStringList &args)
|
|||||||
m_file = m_keys.takeFirst();
|
m_file = m_keys.takeFirst();
|
||||||
|
|
||||||
if (m_file.isEmpty())
|
if (m_file.isEmpty())
|
||||||
std::cerr << "No file given." << std::endl << std::endl;
|
qCCritical(getlog) << "No file given.";
|
||||||
if (m_keys.isEmpty())
|
if (m_keys.isEmpty())
|
||||||
std::cerr << "No keys given." << std::endl << std::endl;
|
qCCritical(getlog) << "No keys given.";
|
||||||
|
|
||||||
return !m_file.isEmpty() && !m_keys.isEmpty();
|
return !m_file.isEmpty() && !m_keys.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -112,7 +120,7 @@ int GetOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool GetOperation::test() const
|
void GetOperation::unittest()
|
||||||
{
|
{
|
||||||
QVariantMap testMap;
|
QVariantMap testMap;
|
||||||
QVariantMap subKeys;
|
QVariantMap subKeys;
|
||||||
@@ -127,22 +135,16 @@ bool GetOperation::test() const
|
|||||||
|
|
||||||
QVariant result;
|
QVariant result;
|
||||||
result = get(testMap, QLatin1String("testint"));
|
result = get(testMap, QLatin1String("testint"));
|
||||||
if (result.toString() != QLatin1String("23"))
|
QCOMPARE(result.toString(), QLatin1String("23"));
|
||||||
return false;
|
|
||||||
|
|
||||||
result = get(testMap, QLatin1String("subkeys/testbool"));
|
result = get(testMap, QLatin1String("subkeys/testbool"));
|
||||||
if (result.toString() != QLatin1String("true"))
|
QCOMPARE(result.toString(), QLatin1String("true"));
|
||||||
return false;
|
|
||||||
|
|
||||||
result = get(testMap, QLatin1String("subkeys/subsubkeys"));
|
result = get(testMap, QLatin1String("subkeys/subsubkeys"));
|
||||||
if (result.type() != QVariant::Map)
|
QCOMPARE(result.type(), QVariant::Map);
|
||||||
return false;
|
|
||||||
|
|
||||||
result = get(testMap, QLatin1String("nonexistant"));
|
result = get(testMap, QLatin1String("nonexistant"));
|
||||||
if (result.isValid())
|
QVERIFY(!result.isValid());
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -39,11 +39,10 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QVariant get(const QVariantMap &map, const QString &key);
|
static QVariant get(const QVariantMap &map, const QString &key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList m_keys;
|
QStringList m_keys;
|
||||||
QString m_file;
|
QString m_file;
|
||||||
|
@@ -214,21 +214,6 @@ int main(int argc, char *argv[])
|
|||||||
operations.emplace_back(std::make_unique<FindKeyOperation>());
|
operations.emplace_back(std::make_unique<FindKeyOperation>());
|
||||||
operations.emplace_back(std::make_unique<FindValueOperation>());
|
operations.emplace_back(std::make_unique<FindValueOperation>());
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
if (argc == 2 && !strcmp(argv[1], "-test")) {
|
|
||||||
std::cerr << std::endl << std::endl << "Starting tests..." << std::endl;
|
|
||||||
int res = 0;
|
|
||||||
for (const std::unique_ptr<Operation> &o : operations) {
|
|
||||||
if (!o->test()) {
|
|
||||||
std::cerr << "!!!! Test failed for: " << qPrintable(o->name()) << " !!!!" << std::endl;
|
|
||||||
++res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::cerr << "Tests done." << std::endl << std::endl;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int result = parseArguments(a.arguments(), &settings, operations);
|
int result = parseArguments(a.arguments(), &settings, operations);
|
||||||
return settings.operation ? settings.operation->execute() : result;
|
return settings.operation ? settings.operation->execute() : result;
|
||||||
}
|
}
|
||||||
|
@@ -59,10 +59,6 @@ public:
|
|||||||
|
|
||||||
virtual int execute() const = 0;
|
virtual int execute() const = 0;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
|
||||||
virtual bool test() const = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QVariantMap load(const QString &file);
|
static QVariantMap load(const QString &file);
|
||||||
bool save(const QVariantMap &map, const QString &file) const;
|
bool save(const QVariantMap &map, const QString &file) const;
|
||||||
};
|
};
|
||||||
|
@@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
#include "rmcmakeoperation.h"
|
#include "rmcmakeoperation.h"
|
||||||
|
|
||||||
#include "addkeysoperation.h"
|
|
||||||
#include "addcmakeoperation.h"
|
#include "addcmakeoperation.h"
|
||||||
|
#include "addkeysoperation.h"
|
||||||
#include "findkeyoperation.h"
|
#include "findkeyoperation.h"
|
||||||
#include "findvalueoperation.h"
|
#include "findvalueoperation.h"
|
||||||
#include "getoperation.h"
|
#include "getoperation.h"
|
||||||
@@ -34,6 +34,14 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(rmcmakelog, "qtc.sdktool.operations.rmcmake", QtWarningMsg)
|
||||||
|
|
||||||
// CMake file stuff:
|
// CMake file stuff:
|
||||||
const char COUNT[] = "CMakeTools.Count";
|
const char COUNT[] = "CMakeTools.Count";
|
||||||
const char PREFIX[] = "CMakeTools.";
|
const char PREFIX[] = "CMakeTools.";
|
||||||
@@ -64,7 +72,7 @@ bool RmCMakeOperation::setArguments(const QStringList &args)
|
|||||||
|
|
||||||
if (current == "--id") {
|
if (current == "--id") {
|
||||||
if (next.isNull()) {
|
if (next.isNull()) {
|
||||||
std::cerr << "No parameter for --id given." << std::endl << std::endl;
|
qCCritical(rmcmakelog) << "No parameter for --id given.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++i; // skip next;
|
++i; // skip next;
|
||||||
@@ -73,8 +81,9 @@ bool RmCMakeOperation::setArguments(const QStringList &args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_id.isEmpty())
|
if (m_id.isEmpty()) {
|
||||||
std::cerr << "No id given." << std::endl << std::endl;
|
qCCritical(rmcmakelog) << "No id given.";
|
||||||
|
}
|
||||||
|
|
||||||
return !m_id.isEmpty();
|
return !m_id.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -93,45 +102,55 @@ int RmCMakeOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool RmCMakeOperation::test() const
|
void RmCMakeOperation::unittest()
|
||||||
{
|
{
|
||||||
// Add cmakes:
|
// Add cmakes:
|
||||||
QVariantMap map = AddCMakeOperation::initializeCMake();
|
QVariantMap map = AddCMakeOperation::initializeCMake();
|
||||||
const QVariantMap emptyMap = map;
|
const QVariantMap emptyMap = map;
|
||||||
map = AddCMakeData{"testId", "name", "/tmp/test",
|
AddCMakeData d;
|
||||||
{{"ExtraKey", QVariant("ExtraValue")}}}.addCMake(map);
|
d.m_id = "testId";
|
||||||
map = AddCMakeData{"testId2", "other name", "/tmp/test2", {}}.addCMake(map);
|
d.m_displayName = "name";
|
||||||
|
d.m_path = "/tmp/test";
|
||||||
|
d.m_extra = {{"ExtraKey", QVariant("ExtraValue")}};
|
||||||
|
map = d.addCMake(map);
|
||||||
|
|
||||||
QVariantMap result = RmCMakeData{"nonexistent"}.rmCMake(QVariantMap());
|
d.m_id = "testId2";
|
||||||
if (!result.isEmpty())
|
d.m_displayName = "other name";
|
||||||
return false;
|
d.m_path = "/tmp/test2";
|
||||||
|
d.m_extra = {};
|
||||||
|
map = d.addCMake(map);
|
||||||
|
|
||||||
result = RmCMakeData{"nonexistent"}.rmCMake(map);
|
RmCMakeData rmD;
|
||||||
if (result != map)
|
rmD.m_id = "nonexistent";
|
||||||
return false;
|
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg, "Error: Count found in cmake tools file seems wrong.");
|
||||||
|
|
||||||
|
QVERIFY(rmD.rmCMake(QVariantMap()).isEmpty());
|
||||||
|
QCOMPARE(rmD.rmCMake(map), map);
|
||||||
|
|
||||||
// Remove from map with both testId and testId2:
|
// Remove from map with both testId and testId2:
|
||||||
result = RmCMakeData{"testId2"}.rmCMake(map);
|
rmD.m_id = "testId2";
|
||||||
if (result == map
|
QVariantMap result = rmD.rmCMake(map);
|
||||||
|| result.value(COUNT, 0).toInt() != 1
|
QVERIFY(result != map);
|
||||||
|| !result.contains(QString::fromLatin1(PREFIX) + "0")
|
|
||||||
|| result.value(QString::fromLatin1(PREFIX) + "0") != map.value(QString::fromLatin1(PREFIX) + "0"))
|
QCOMPARE(result.value(COUNT, 0).toInt(), 1);
|
||||||
return false;
|
QVERIFY(result.contains(QString::fromLatin1(PREFIX) + "0"));
|
||||||
|
QCOMPARE(result.value(QString::fromLatin1(PREFIX) + "0"),
|
||||||
|
map.value(QString::fromLatin1(PREFIX) + "0"));
|
||||||
|
|
||||||
// Remove from map with both testId and testId2:
|
// Remove from map with both testId and testId2:
|
||||||
result = RmCMakeData{"testId"}.rmCMake(map);
|
rmD.m_id = "testId";
|
||||||
if (result == map
|
result = rmD.rmCMake(map);
|
||||||
|| result.value(COUNT, 0).toInt() != 1
|
QVERIFY(result != map);
|
||||||
|| !result.contains(QString::fromLatin1(PREFIX) + "0")
|
QCOMPARE(result.value(COUNT, 0).toInt(), 1);
|
||||||
|| result.value(QString::fromLatin1(PREFIX) + "0") != map.value(QString::fromLatin1(PREFIX) + "1"))
|
QVERIFY(result.contains(QString::fromLatin1(PREFIX) + "0"));
|
||||||
return false;
|
QCOMPARE(result.value(QString::fromLatin1(PREFIX) + "0"),
|
||||||
|
map.value(QString::fromLatin1(PREFIX) + "1"));
|
||||||
|
|
||||||
// Remove from map without testId!
|
// Remove from map without testId!
|
||||||
result = RmCMakeData{"testId2"}.rmCMake(result);
|
rmD.m_id = "testId2";
|
||||||
if (result != emptyMap)
|
result = rmD.rmCMake(result);
|
||||||
return false;
|
QCOMPARE(result, emptyMap);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -141,13 +160,14 @@ QVariantMap RmCMakeData::rmCMake(const QVariantMap &map) const
|
|||||||
bool ok;
|
bool ok;
|
||||||
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
||||||
if (!ok || count < 0) {
|
if (!ok || count < 0) {
|
||||||
std::cerr << "Error: Count found in cmake tools file seems wrong." << std::endl;
|
qCCritical(rmcmakelog) << "Error: Count found in cmake tools file seems wrong.";
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList cmList;
|
QVariantList cmList;
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
QVariantMap cmData = GetOperation::get(map, QString::fromLatin1(PREFIX) + QString::number(i)).toMap();
|
QVariantMap cmData
|
||||||
|
= GetOperation::get(map, QString::fromLatin1(PREFIX) + QString::number(i)).toMap();
|
||||||
if (cmData.value(ID).toString() != m_id)
|
if (cmData.value(ID).toString() != m_id)
|
||||||
cmList.append(cmData);
|
cmList.append(cmData);
|
||||||
}
|
}
|
||||||
@@ -159,4 +179,3 @@ QVariantMap RmCMakeData::rmCMake(const QVariantMap &map) const
|
|||||||
|
|
||||||
return newMap;
|
return newMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,6 +47,6 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@@ -36,6 +36,14 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(rmdebuggerlog, "qtc.sdktool.operations.rmdebugger", QtWarningMsg)
|
||||||
|
|
||||||
// Qt version file stuff:
|
// Qt version file stuff:
|
||||||
const char PREFIX[] = "DebuggerItem.";
|
const char PREFIX[] = "DebuggerItem.";
|
||||||
const char COUNT[] = "DebuggerItem.Count";
|
const char COUNT[] = "DebuggerItem.Count";
|
||||||
@@ -58,7 +66,8 @@ QString RmDebuggerOperation::helpText() const
|
|||||||
|
|
||||||
QString RmDebuggerOperation::argumentsHelpText() const
|
QString RmDebuggerOperation::argumentsHelpText() const
|
||||||
{
|
{
|
||||||
return QLatin1String(" --id <ID> id of the debugger to remove.\n");
|
return QLatin1String(
|
||||||
|
" --id <ID> id of the debugger to remove.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RmDebuggerOperation::setArguments(const QStringList &args)
|
bool RmDebuggerOperation::setArguments(const QStringList &args)
|
||||||
@@ -70,8 +79,9 @@ bool RmDebuggerOperation::setArguments(const QStringList &args)
|
|||||||
|
|
||||||
m_id = args.at(1);
|
m_id = args.at(1);
|
||||||
|
|
||||||
if (m_id.isEmpty())
|
if (m_id.isEmpty()) {
|
||||||
std::cerr << "No id given." << std::endl << std::endl;
|
qCCritical(rmdebuggerlog) << "No id given.";
|
||||||
|
}
|
||||||
|
|
||||||
return !m_id.isEmpty();
|
return !m_id.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -91,51 +101,50 @@ int RmDebuggerOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool RmDebuggerOperation::test() const
|
void RmDebuggerOperation::unittest()
|
||||||
{
|
{
|
||||||
|
AddDebuggerData d;
|
||||||
|
d.m_id = "id1";
|
||||||
|
d.m_displayName = "Name1";
|
||||||
|
d.m_engine = 2;
|
||||||
|
d.m_binary = "/tmp/debugger1";
|
||||||
|
d.m_abis = {"test11", "test12"};
|
||||||
|
|
||||||
QVariantMap map =
|
QVariantMap map = d.addDebugger(AddDebuggerOperation::initializeDebuggers());
|
||||||
AddDebuggerData{QLatin1String("id1"), QLatin1String("Name1"),
|
d.m_id = "id2";
|
||||||
2, QLatin1String("/tmp/debugger1"),
|
d.m_displayName = "Name2";
|
||||||
{"test11", "test12"}, {}}
|
d.m_binary = "/tmp/debugger2";
|
||||||
.addDebugger(AddDebuggerOperation::initializeDebuggers());
|
d.m_abis = {"test21", "test22"};
|
||||||
|
map = d.addDebugger(map);
|
||||||
map = AddDebuggerData{QLatin1String("id2"), QLatin1String("Name2"),
|
|
||||||
2, QLatin1String("/tmp/debugger2"),
|
|
||||||
{"test21", "test22"}, {}}
|
|
||||||
.addDebugger(map);
|
|
||||||
|
|
||||||
QVariantMap result = rmDebugger(map, QLatin1String("id2"));
|
QVariantMap result = rmDebugger(map, QLatin1String("id2"));
|
||||||
if (result.count() != 3
|
QCOMPARE(result.count(), 3);
|
||||||
|| !result.contains(QLatin1String("DebuggerItem.0"))
|
QVERIFY(result.contains(QLatin1String("DebuggerItem.0")));
|
||||||
|| !result.contains(QLatin1String(COUNT))
|
QVERIFY(result.contains(QLatin1String(COUNT)));
|
||||||
|| result.value(QLatin1String(COUNT)).toInt() != 1
|
QCOMPARE(result.value(QLatin1String(COUNT)).toInt(), 1);
|
||||||
|| !result.contains(QLatin1String(VERSION))
|
QVERIFY(result.contains(QLatin1String(VERSION)));
|
||||||
|| result.value(QLatin1String(VERSION)).toInt() != 1)
|
QCOMPARE(result.value(QLatin1String(VERSION)).toInt(), 1);
|
||||||
return false;
|
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg,
|
||||||
|
QRegularExpression("Error: Id was not found"));
|
||||||
|
|
||||||
result = rmDebugger(map, QLatin1String("unknown"));
|
result = rmDebugger(map, QLatin1String("unknown"));
|
||||||
if (result != map)
|
QVERIFY(result == map);
|
||||||
return false;
|
|
||||||
|
|
||||||
result = rmDebugger(map, QLatin1String("id2"));
|
result = rmDebugger(map, QLatin1String("id2"));
|
||||||
if (result.count() != 3
|
QCOMPARE(result.count(), 3);
|
||||||
|| !result.contains(QLatin1String("DebuggerItem.0"))
|
QVERIFY(result.contains(QLatin1String("DebuggerItem.0")));
|
||||||
|| !result.contains(QLatin1String(COUNT))
|
QVERIFY(result.contains(QLatin1String(COUNT)));
|
||||||
|| result.value(QLatin1String(COUNT)).toInt() != 1
|
QCOMPARE(result.value(QLatin1String(COUNT)).toInt(), 1);
|
||||||
|| !result.contains(QLatin1String(VERSION))
|
QVERIFY(result.contains(QLatin1String(VERSION)));
|
||||||
|| result.value(QLatin1String(VERSION)).toInt() != 1)
|
QCOMPARE(result.value(QLatin1String(VERSION)).toInt(), 1);
|
||||||
return false;
|
|
||||||
|
|
||||||
result = rmDebugger(result, QLatin1String("id1"));
|
result = rmDebugger(result, QLatin1String("id1"));
|
||||||
if (result.count() != 2
|
QCOMPARE(result.count(), 2);
|
||||||
|| !result.contains(QLatin1String(COUNT))
|
QVERIFY(result.contains(QLatin1String(COUNT)));
|
||||||
|| result.value(QLatin1String(COUNT)).toInt() != 0
|
QCOMPARE(result.value(QLatin1String(COUNT)).toInt(), 0);
|
||||||
|| !result.contains(QLatin1String(VERSION))
|
QVERIFY(result.contains(QLatin1String(VERSION)));
|
||||||
|| result.value(QLatin1String(VERSION)).toInt() != 1)
|
QCOMPARE(result.value(QLatin1String(VERSION)).toInt(), 1);
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -147,7 +156,7 @@ QVariantMap RmDebuggerOperation::rmDebugger(const QVariantMap &map, const QStrin
|
|||||||
bool ok;
|
bool ok;
|
||||||
int count = GetOperation::get(map, QLatin1String(COUNT)).toInt(&ok);
|
int count = GetOperation::get(map, QLatin1String(COUNT)).toInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
std::cerr << "Error: The count found in map is not an integer." << std::endl;
|
qCCritical(rmdebuggerlog) << "Error: The count found in map is not an integer.";
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +168,7 @@ QVariantMap RmDebuggerOperation::rmDebugger(const QVariantMap &map, const QStrin
|
|||||||
debuggerList << debugger;
|
debuggerList << debugger;
|
||||||
}
|
}
|
||||||
if (debuggerList.count() == map.count() - 2) {
|
if (debuggerList.count() == map.count() - 2) {
|
||||||
std::cerr << "Error: Id was not found." << std::endl;
|
qCCritical(rmdebuggerlog) << "Error: Id was not found.";
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,4 +188,3 @@ QVariantMap RmDebuggerOperation::rmDebugger(const QVariantMap &map, const QStrin
|
|||||||
|
|
||||||
return AddKeysData{data}.addKeys(result);
|
return AddKeysData{data}.addKeys(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,11 +41,10 @@ public:
|
|||||||
int execute() const;
|
int execute() const;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QVariantMap rmDebugger(const QVariantMap &map, const QString &id);
|
static QVariantMap rmDebugger(const QVariantMap &map, const QString &id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_id;
|
QString m_id;
|
||||||
};
|
};
|
||||||
|
@@ -32,6 +32,15 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(rmdevicelog, "qtc.sdktool.operations.rmdevice", QtWarningMsg)
|
||||||
|
|
||||||
|
|
||||||
QString RmDeviceOperation::name() const
|
QString RmDeviceOperation::name() const
|
||||||
{
|
{
|
||||||
return QLatin1String("rmDev");
|
return QLatin1String("rmDev");
|
||||||
@@ -57,7 +66,7 @@ bool RmDeviceOperation::setArguments(const QStringList &args)
|
|||||||
m_id = args.at(1);
|
m_id = args.at(1);
|
||||||
|
|
||||||
if (m_id.isEmpty())
|
if (m_id.isEmpty())
|
||||||
std::cerr << "No id given." << std::endl << std::endl;
|
qCCritical(rmdevicelog) << "No id given.";
|
||||||
|
|
||||||
return !m_id.isEmpty();
|
return !m_id.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -77,9 +86,9 @@ int RmDeviceOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool RmDeviceOperation::test() const
|
void RmDeviceOperation::unittest()
|
||||||
{
|
{
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -107,8 +116,10 @@ QVariantMap RmDeviceOperation::rmDevice(const QVariantMap &map, const QString &i
|
|||||||
dmMap.insert(QLatin1String(DEVICE_LIST_ID), devList);
|
dmMap.insert(QLatin1String(DEVICE_LIST_ID), devList);
|
||||||
result.insert(QLatin1String(DEVICEMANAGER_ID), dmMap);
|
result.insert(QLatin1String(DEVICEMANAGER_ID), dmMap);
|
||||||
|
|
||||||
if (!found)
|
if (!found){
|
||||||
std::cerr << "Device " << qPrintable(id) << " not found." << std::endl;
|
qCCritical(rmdevicelog) << "Device " << qPrintable(id) << " not found.";
|
||||||
|
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ public:
|
|||||||
int execute() const;
|
int execute() const;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QVariantMap rmDevice(const QVariantMap &map, const QString &id);
|
static QVariantMap rmDevice(const QVariantMap &map, const QString &id);
|
||||||
|
@@ -27,6 +27,14 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(rmkeyslog, "qtc.sdktool.operations.rmkeys", QtWarningMsg)
|
||||||
|
|
||||||
QString RmKeysOperation::name() const
|
QString RmKeysOperation::name() const
|
||||||
{
|
{
|
||||||
return QLatin1String("rmKeys");
|
return QLatin1String("rmKeys");
|
||||||
@@ -52,9 +60,9 @@ bool RmKeysOperation::setArguments(const QStringList &args)
|
|||||||
m_file = m_keys.takeFirst();
|
m_file = m_keys.takeFirst();
|
||||||
|
|
||||||
if (m_file.isEmpty())
|
if (m_file.isEmpty())
|
||||||
std::cerr << "No file given." << std::endl << std::endl;
|
qCCritical(rmkeyslog) << "No file given.";
|
||||||
if (m_keys.isEmpty())
|
if (m_keys.isEmpty())
|
||||||
std::cerr << "No keys given." << std::endl << std::endl;
|
qCCritical(rmkeyslog) << "No keys given.";
|
||||||
|
|
||||||
return !m_file.isEmpty() && !m_keys.isEmpty();
|
return !m_file.isEmpty() && !m_keys.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -73,7 +81,7 @@ int RmKeysOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool RmKeysOperation::test() const
|
void RmKeysOperation::unittest()
|
||||||
{
|
{
|
||||||
QVariantMap testMap;
|
QVariantMap testMap;
|
||||||
QVariantMap subKeys;
|
QVariantMap subKeys;
|
||||||
@@ -90,77 +98,72 @@ bool RmKeysOperation::test() const
|
|||||||
|
|
||||||
QVariantMap result = rmKeys(testMap, data);
|
QVariantMap result = rmKeys(testMap, data);
|
||||||
|
|
||||||
if (result != testMap)
|
QVERIFY(result == testMap);
|
||||||
return false;
|
|
||||||
|
|
||||||
data.append(QLatin1String("testint"));
|
data.append(QLatin1String("testint"));
|
||||||
result = rmKeys(testMap, data);
|
result = rmKeys(testMap, data);
|
||||||
|
|
||||||
if (result.count() != 2
|
QCOMPARE(result.count(), 2);
|
||||||
|| !result.contains(QLatin1String("subkeys"))
|
QVERIFY(result.contains(QLatin1String("subkeys")));
|
||||||
|| !result.contains(QLatin1String("subkeys2")))
|
QVERIFY(result.contains(QLatin1String("subkeys2")));
|
||||||
return false;
|
|
||||||
cur = result.value(QLatin1String("subkeys")).toMap();
|
cur = result.value(QLatin1String("subkeys")).toMap();
|
||||||
if (cur.count() != 2
|
QCOMPARE(cur.count(), 2);
|
||||||
|| !cur.contains(QLatin1String("subsubkeys"))
|
QVERIFY(cur.contains(QLatin1String("subsubkeys")));
|
||||||
|| !cur.contains(QLatin1String("testbool")))
|
QVERIFY(cur.contains(QLatin1String("testbool")));
|
||||||
return false;
|
|
||||||
|
|
||||||
cur = cur.value(QLatin1String("subsubkeys")).toMap();
|
cur = cur.value(QLatin1String("subsubkeys")).toMap();
|
||||||
if (cur.count() != 1
|
QCOMPARE(cur.count(), 1);
|
||||||
|| !cur.contains(QLatin1String("testint2")))
|
QVERIFY(cur.contains(QLatin1String("testint2")));
|
||||||
return false;
|
|
||||||
|
|
||||||
cur = result.value(QLatin1String("subkeys2")).toMap();
|
cur = result.value(QLatin1String("subkeys2")).toMap();
|
||||||
if (cur.count() != 0)
|
QVERIFY(cur.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
data.clear();
|
data.clear();
|
||||||
data.append(QLatin1String("subkeys/subsubkeys"));
|
data.append(QLatin1String("subkeys/subsubkeys"));
|
||||||
result = rmKeys(testMap, data);
|
result = rmKeys(testMap, data);
|
||||||
|
|
||||||
if (result.count() != 3
|
QCOMPARE(result.count(), 3);
|
||||||
|| !result.contains(QLatin1String("subkeys"))
|
QVERIFY(result.contains(QLatin1String("subkeys")));
|
||||||
|| !result.contains(QLatin1String("subkeys2"))
|
QVERIFY(result.contains(QLatin1String("subkeys2")));
|
||||||
|| !result.contains(QLatin1String("testint")))
|
QVERIFY(result.contains(QLatin1String("testint")));
|
||||||
return false;
|
|
||||||
cur = result.value(QLatin1String("subkeys")).toMap();
|
cur = result.value(QLatin1String("subkeys")).toMap();
|
||||||
if (cur.count() != 1
|
QCOMPARE(cur.count(), 1);
|
||||||
|| !cur.contains(QLatin1String("testbool")))
|
QVERIFY(cur.contains(QLatin1String("testbool")));
|
||||||
return false;
|
|
||||||
|
|
||||||
cur = result.value(QLatin1String("subkeys2")).toMap();
|
cur = result.value(QLatin1String("subkeys2")).toMap();
|
||||||
if (cur.count() != 0)
|
QVERIFY(cur.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
data.clear();
|
data.clear();
|
||||||
data.append(QLatin1String("subkeys/testbool"));
|
data.append(QLatin1String("subkeys/testbool"));
|
||||||
result = rmKeys(testMap, data);
|
result = rmKeys(testMap, data);
|
||||||
|
|
||||||
if (result.count() != 3
|
QCOMPARE(result.count(), 3);
|
||||||
|| !result.contains(QLatin1String("subkeys"))
|
QVERIFY(result.contains(QLatin1String("subkeys")));
|
||||||
|| !result.contains(QLatin1String("subkeys2"))
|
QVERIFY(result.contains(QLatin1String("subkeys2")));
|
||||||
|| !result.contains(QLatin1String("testint")))
|
QVERIFY(result.contains(QLatin1String("testint")));
|
||||||
return false;
|
|
||||||
cur = result.value(QLatin1String("subkeys")).toMap();
|
cur = result.value(QLatin1String("subkeys")).toMap();
|
||||||
if (cur.count() != 1
|
QCOMPARE(cur.count(), 1);
|
||||||
|| !cur.contains(QLatin1String("subsubkeys")))
|
QVERIFY(cur.contains(QLatin1String("subsubkeys")));
|
||||||
return false;
|
|
||||||
|
|
||||||
cur = cur.value(QLatin1String("subsubkeys")).toMap();
|
cur = cur.value(QLatin1String("subsubkeys")).toMap();
|
||||||
if (cur.count() != 1
|
QCOMPARE(cur.count(), 1);
|
||||||
|| !cur.contains(QLatin1String("testint2")))
|
QVERIFY(cur.contains(QLatin1String("testint2")));
|
||||||
return false;
|
|
||||||
|
|
||||||
cur = result.value(QLatin1String("subkeys2")).toMap();
|
cur = result.value(QLatin1String("subkeys2")).toMap();
|
||||||
if (cur.count() != 0)
|
QVERIFY(cur.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
cur = result.value(QLatin1String("subkeys2")).toMap();
|
cur = result.value(QLatin1String("subkeys2")).toMap();
|
||||||
if (cur.count() != 0)
|
QVERIFY(cur.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
// Test removing of non-existent key ...
|
||||||
|
testMap = rmKeys(testMap, data);
|
||||||
|
|
||||||
|
QTest::ignoreMessage(QtWarningMsg,
|
||||||
|
QRegularExpression("Key .* not found."));
|
||||||
|
testMap = rmKeys(testMap, data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -180,7 +183,7 @@ QVariantMap RmKeysOperation::rmKeys(const QVariantMap &map, const QStringList &r
|
|||||||
if (stack.last().contains(keys.at(i))) {
|
if (stack.last().contains(keys.at(i))) {
|
||||||
subMap = stack.last().value(keys.at(i)).toMap();
|
subMap = stack.last().value(keys.at(i)).toMap();
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Warning: Key " << qPrintable(r) << " not found." << std::endl;
|
qCWarning(rmkeyslog) << "Key" << qPrintable(r) << "not found.";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
stack.append(subMap);
|
stack.append(subMap);
|
||||||
@@ -189,7 +192,7 @@ QVariantMap RmKeysOperation::rmKeys(const QVariantMap &map, const QStringList &r
|
|||||||
// remove
|
// remove
|
||||||
Q_ASSERT(stack.count() == keys.count());
|
Q_ASSERT(stack.count() == keys.count());
|
||||||
if (!stack.last().contains(keys.last())) {
|
if (!stack.last().contains(keys.last())) {
|
||||||
std::cerr << "Warning: Key " << qPrintable(r) << " not found." << std::endl;
|
qCWarning(rmkeyslog) << "Key" << qPrintable(r) << "not found.";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
stack.last().remove(keys.last());
|
stack.last().remove(keys.last());
|
||||||
|
@@ -39,7 +39,7 @@ public:
|
|||||||
int execute() const;
|
int execute() const;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QVariantMap rmKeys(const QVariantMap &map, const QStringList &removals);
|
static QVariantMap rmKeys(const QVariantMap &map, const QStringList &removals);
|
||||||
|
@@ -25,11 +25,11 @@
|
|||||||
|
|
||||||
#include "rmkitoperation.h"
|
#include "rmkitoperation.h"
|
||||||
|
|
||||||
#include "addkeysoperation.h"
|
|
||||||
#include "addtoolchainoperation.h"
|
|
||||||
#include "adddeviceoperation.h"
|
#include "adddeviceoperation.h"
|
||||||
#include "addqtoperation.h"
|
#include "addkeysoperation.h"
|
||||||
#include "addkitoperation.h"
|
#include "addkitoperation.h"
|
||||||
|
#include "addqtoperation.h"
|
||||||
|
#include "addtoolchainoperation.h"
|
||||||
#include "findkeyoperation.h"
|
#include "findkeyoperation.h"
|
||||||
#include "findvalueoperation.h"
|
#include "findvalueoperation.h"
|
||||||
#include "getoperation.h"
|
#include "getoperation.h"
|
||||||
@@ -39,6 +39,14 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(rmkitlog, "qtc.sdktool.operations.rmkit", QtWarningMsg)
|
||||||
|
|
||||||
// Qt version file stuff:
|
// Qt version file stuff:
|
||||||
const char PREFIX[] = "Profile.";
|
const char PREFIX[] = "Profile.";
|
||||||
const char COUNT[] = "Profile.Count";
|
const char COUNT[] = "Profile.Count";
|
||||||
@@ -75,7 +83,7 @@ bool RmKitOperation::setArguments(const QStringList &args)
|
|||||||
m_id = args.at(1);
|
m_id = args.at(1);
|
||||||
|
|
||||||
if (m_id.isEmpty())
|
if (m_id.isEmpty())
|
||||||
std::cerr << "No id given." << std::endl << std::endl;
|
qCCritical(rmkitlog) << "No id given.";
|
||||||
|
|
||||||
return !m_id.isEmpty();
|
return !m_id.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -95,15 +103,28 @@ int RmKitOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool RmKitOperation::test() const
|
void RmKitOperation::unittest()
|
||||||
{
|
{
|
||||||
QVariantMap tcMap = AddToolChainOperation::initializeToolChains();
|
QVariantMap tcMap = AddToolChainOperation::initializeToolChains();
|
||||||
tcMap = AddToolChainData{"{tc-id}", "langId", "TC", "/usr/bin/gcc",
|
AddToolChainData d;
|
||||||
"x86-linux-generic-elf-32bit", "x86-linux-generic-elf-32bit", {}}
|
d.m_id = "{tc-id}";
|
||||||
.addToolChain(tcMap);
|
d.m_languageId = "langId";
|
||||||
|
d.m_displayName = "TC";
|
||||||
|
d.m_path = "/usr/bin/gcc";
|
||||||
|
d.m_targetAbi = "x86-linux-generic-elf-32bit";
|
||||||
|
d.m_supportedAbis = "x86-linux-generic-elf-32bit";
|
||||||
|
d.m_extra = {};
|
||||||
|
|
||||||
|
tcMap = d.addToolChain(tcMap);
|
||||||
|
|
||||||
QVariantMap qtMap = AddQtData::initializeQtVersions();
|
QVariantMap qtMap = AddQtData::initializeQtVersions();
|
||||||
qtMap = AddQtData{"{qt-id}", "Qt", "desktop-qt", "/usr/bin/qmake", {}, {}}.addQt(qtMap);
|
AddQtData qtd;
|
||||||
|
qtd.m_id = "{qt-id}";
|
||||||
|
qtd.m_displayName = "Qt";
|
||||||
|
qtd.m_type = "desktop-qt";
|
||||||
|
qtd.m_qmake = "/usr/bin/qmake";
|
||||||
|
|
||||||
|
qtMap = qtd.addQt(qtMap);
|
||||||
|
|
||||||
QVariantMap devMap = AddDeviceOperation::initializeDevices();
|
QVariantMap devMap = AddDeviceOperation::initializeDevices();
|
||||||
AddDeviceData devData;
|
AddDeviceData devData;
|
||||||
@@ -143,7 +164,6 @@ bool RmKitOperation::test() const
|
|||||||
|
|
||||||
QVariantMap map = kitData.addKit(AddKitData::initializeKits(), tcMap, qtMap, devMap, {});
|
QVariantMap map = kitData.addKit(AddKitData::initializeKits(), tcMap, qtMap, devMap, {});
|
||||||
|
|
||||||
|
|
||||||
kitData.m_id = "testId2";
|
kitData.m_id = "testId2";
|
||||||
kitData.m_icon = "/tmp/icon2.png";
|
kitData.m_icon = "/tmp/icon2.png";
|
||||||
kitData.m_icon = "/usr/bin/gdb-test2";
|
kitData.m_icon = "/usr/bin/gdb-test2";
|
||||||
@@ -152,34 +172,40 @@ bool RmKitOperation::test() const
|
|||||||
|
|
||||||
map = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
map = kitData.addKit(map, tcMap, qtMap, devMap, {});
|
||||||
|
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg, "Error: Could not find the default kit.");
|
||||||
QVariantMap result = rmKit(map, "testId");
|
QVariantMap result = rmKit(map, "testId");
|
||||||
if (result.count() != 4
|
QCOMPARE(result.count(), 4);
|
||||||
|| !result.contains("Profile.0")
|
QVERIFY(result.contains("Profile.0"));
|
||||||
|| !result.contains(COUNT) || result.value(COUNT).toInt() != 1
|
QVERIFY(result.contains(COUNT));
|
||||||
|| !result.contains(DEFAULT) || result.value(DEFAULT).toInt() != 0
|
QCOMPARE(result.value(COUNT).toInt(), 1);
|
||||||
|| !result.contains(VERSION) || result.value(VERSION).toInt() != 1)
|
QVERIFY(result.contains(DEFAULT));
|
||||||
return false;
|
QCOMPARE(result.value(DEFAULT).toInt(), 0);
|
||||||
|
QVERIFY(result.contains(VERSION));
|
||||||
|
QCOMPARE(result.value(VERSION).toInt(), 1);
|
||||||
|
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg, "Error: Id was not found.");
|
||||||
result = rmKit(map, "unknown");
|
result = rmKit(map, "unknown");
|
||||||
if (result != map)
|
QCOMPARE(result, map);
|
||||||
return false;
|
|
||||||
|
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg, "Error: Could not find the default kit.");
|
||||||
result = rmKit(map, "testId2");
|
result = rmKit(map, "testId2");
|
||||||
if (result.count() != 4
|
QCOMPARE(result.count(), 4);
|
||||||
|| !result.contains("Profile.0")
|
QVERIFY(result.contains("Profile.0"));
|
||||||
|| !result.contains(COUNT) || result.value(COUNT).toInt() != 1
|
QVERIFY(result.contains(COUNT));
|
||||||
|| !result.contains(DEFAULT) || result.value(DEFAULT).toInt() != 0
|
QCOMPARE(result.value(COUNT).toInt(), 1);
|
||||||
|| !result.contains(VERSION) || result.value(VERSION).toInt() != 1)
|
QVERIFY(result.contains(DEFAULT));
|
||||||
return false;
|
QCOMPARE(result.value(DEFAULT).toInt(), 0);
|
||||||
|
QVERIFY(result.contains(VERSION));
|
||||||
|
QCOMPARE(result.value(VERSION).toInt(), 1);
|
||||||
|
|
||||||
result = rmKit(result, QLatin1String("testId"));
|
result = rmKit(result, QLatin1String("testId"));
|
||||||
if (result.count() != 3
|
QCOMPARE(result.count(), 3);
|
||||||
|| !result.contains(COUNT) || result.value(COUNT).toInt() != 0
|
QVERIFY(result.contains(COUNT));
|
||||||
|| !result.contains(DEFAULT) || result.value(DEFAULT).toInt() != -1
|
QCOMPARE(result.value(COUNT).toInt(), 0);
|
||||||
|| !result.contains(VERSION) || result.value(VERSION).toInt() != 1)
|
QVERIFY(result.contains(DEFAULT));
|
||||||
return false;
|
QCOMPARE(result.value(DEFAULT).toInt(), -1);
|
||||||
|
QVERIFY(result.contains(VERSION));
|
||||||
return true;
|
QCOMPARE(result.value(VERSION).toInt(), 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -191,7 +217,7 @@ QVariantMap RmKitOperation::rmKit(const QVariantMap &map, const QString &id)
|
|||||||
bool ok;
|
bool ok;
|
||||||
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
std::cerr << "Error: The count found in map is not an integer." << std::endl;
|
qCCritical(rmkitlog) << "Error: The count found in map is not an integer.";
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,13 +232,13 @@ QVariantMap RmKitOperation::rmKit(const QVariantMap &map, const QString &id)
|
|||||||
profileList << profile;
|
profileList << profile;
|
||||||
}
|
}
|
||||||
if (profileList.count() == map.count() - 3) {
|
if (profileList.count() == map.count() - 3) {
|
||||||
std::cerr << "Error: Id was not found." << std::endl;
|
qCCritical(rmkitlog) << "Error: Id was not found.";
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
int defaultKit = GetOperation::get(map, DEFAULT).toInt(&ok);
|
int defaultKit = GetOperation::get(map, DEFAULT).toInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
std::cerr << "Error: Could not find the default kit." << std::endl;
|
qCCritical(rmkitlog) << "Error: Could not find the default kit.";
|
||||||
defaultKit = -1;
|
defaultKit = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,8 +254,7 @@ QVariantMap RmKitOperation::rmKit(const QVariantMap &map, const QString &id)
|
|||||||
data << KeyValuePair(COUNT, QVariant(count - 1));
|
data << KeyValuePair(COUNT, QVariant(count - 1));
|
||||||
|
|
||||||
for (int i = 0; i < profileList.count(); ++i)
|
for (int i = 0; i < profileList.count(); ++i)
|
||||||
data << KeyValuePair(QString::fromLatin1(PREFIX) + QString::number(i),
|
data << KeyValuePair(QString::fromLatin1(PREFIX) + QString::number(i), profileList.at(i));
|
||||||
profileList.at(i));
|
|
||||||
|
|
||||||
return AddKeysData{data}.addKeys(result);
|
return AddKeysData{data}.addKeys(result);
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ public:
|
|||||||
int execute() const;
|
int execute() const;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QVariantMap rmKit(const QVariantMap &map, const QString &id);
|
static QVariantMap rmKit(const QVariantMap &map, const QString &id);
|
||||||
|
@@ -34,6 +34,14 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(rmqtlog, "qtc.sdktool.operations.rmqt", QtWarningMsg)
|
||||||
|
|
||||||
// ToolChain file stuff:
|
// ToolChain file stuff:
|
||||||
const char PREFIX[] = "QtVersion.";
|
const char PREFIX[] = "QtVersion.";
|
||||||
|
|
||||||
@@ -63,7 +71,7 @@ bool RmQtOperation::setArguments(const QStringList &args)
|
|||||||
|
|
||||||
if (current == QLatin1String("--id")) {
|
if (current == QLatin1String("--id")) {
|
||||||
if (next.isNull()) {
|
if (next.isNull()) {
|
||||||
std::cerr << "No parameter for --id given." << std::endl << std::endl;
|
qCCritical(rmqtlog) << "No parameter for --id given.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++i; // skip next;
|
++i; // skip next;
|
||||||
@@ -73,7 +81,7 @@ bool RmQtOperation::setArguments(const QStringList &args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_id.isEmpty())
|
if (m_id.isEmpty())
|
||||||
std::cerr << "No id given." << std::endl << std::endl;
|
qCCritical(rmqtlog) << "No id given.";
|
||||||
|
|
||||||
return !m_id.isEmpty();
|
return !m_id.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -92,42 +100,46 @@ int RmQtOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool RmQtOperation::test() const
|
void RmQtOperation::unittest()
|
||||||
{
|
{
|
||||||
// Add toolchain:
|
// Add toolchain:
|
||||||
QVariantMap map = AddQtData::initializeQtVersions();
|
QVariantMap map = AddQtData::initializeQtVersions();
|
||||||
|
|
||||||
QVariantMap result = rmQt(QVariantMap(), QLatin1String("nonexistant"));
|
QVariantMap result = rmQt(QVariantMap(), QLatin1String("nonexistant"));
|
||||||
if (result != map)
|
QCOMPARE(result, map);
|
||||||
return false;
|
|
||||||
|
|
||||||
map = AddQtData{"testId", "name", "type", "/tmp/test", {},
|
AddQtData addData;
|
||||||
{{QLatin1String("ExtraKey"), QVariant(QLatin1String("ExtraValue"))}}}
|
addData.m_id = "testId";
|
||||||
.addQt(map);
|
addData.m_displayName = "name";
|
||||||
|
addData.m_type = "type";
|
||||||
|
addData.m_qmake = "/tmp/test";
|
||||||
|
addData.m_extra = {{QLatin1String("ExtraKey"), QVariant(QLatin1String("ExtraValue"))}};
|
||||||
|
|
||||||
map = AddQtData{"testId2", "other name", "type", "/tmp/test2", {}, {}}.addQt(map);
|
map = addData.addQt(map);
|
||||||
|
|
||||||
|
addData.m_id = "testId2";
|
||||||
|
addData.m_displayName = "other name";
|
||||||
|
addData.m_type = "type";
|
||||||
|
addData.m_qmake = "/tmp/test2";
|
||||||
|
addData.m_extra = {};
|
||||||
|
|
||||||
|
map = addData.addQt(map);
|
||||||
|
|
||||||
result = rmQt(map, QLatin1String("nonexistant"));
|
result = rmQt(map, QLatin1String("nonexistant"));
|
||||||
if (result != map)
|
QCOMPARE(result, map);
|
||||||
return false;
|
|
||||||
|
|
||||||
result = rmQt(map, QLatin1String("testId2"));
|
result = rmQt(map, QLatin1String("testId2"));
|
||||||
if (result == map
|
QVERIFY(result != map);
|
||||||
|| !result.contains(QLatin1String("QtVersion.0"))
|
QVERIFY(result.contains(QLatin1String("QtVersion.0")));
|
||||||
|| result.value(QLatin1String("QtVersion.0")) != map.value(QLatin1String("QtVersion.0")))
|
QCOMPARE(result.value(QLatin1String("QtVersion.0")), map.value(QLatin1String("QtVersion.0")));
|
||||||
return false;
|
|
||||||
|
|
||||||
result = rmQt(map, QLatin1String("testId"));
|
result = rmQt(map, QLatin1String("testId"));
|
||||||
if (result == map
|
QVERIFY(result != map);
|
||||||
|| !result.contains(QLatin1String("QtVersion.0"))
|
QVERIFY(result.contains(QLatin1String("QtVersion.0")));
|
||||||
|| result.value(QLatin1String("QtVersion.0")) != map.value(QLatin1String("QtVersion.1")))
|
QCOMPARE(result.value(QLatin1String("QtVersion.0")), map.value(QLatin1String("QtVersion.1")));
|
||||||
return false;
|
|
||||||
|
|
||||||
result = rmQt(result, QLatin1String("testId2"));
|
result = rmQt(result, QLatin1String("testId2"));
|
||||||
if (result == map)
|
QVERIFY(result != map);
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -153,4 +165,3 @@ QVariantMap RmQtOperation::rmQt(const QVariantMap &map, const QString &id)
|
|||||||
|
|
||||||
return newMap;
|
return newMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ public:
|
|||||||
int execute() const;
|
int execute() const;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const;
|
static void unittest();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QVariantMap rmQt(const QVariantMap &map, const QString &id);
|
static QVariantMap rmQt(const QVariantMap &map, const QString &id);
|
||||||
|
@@ -34,6 +34,14 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef WITH_TESTS
|
||||||
|
#include <QTest>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(rmtoolchainlog, "qtc.sdktool.operations.rmtoolchain", QtWarningMsg)
|
||||||
|
|
||||||
// ToolChain file stuff:
|
// ToolChain file stuff:
|
||||||
const char COUNT[] = "ToolChain.Count";
|
const char COUNT[] = "ToolChain.Count";
|
||||||
const char PREFIX[] = "ToolChain.";
|
const char PREFIX[] = "ToolChain.";
|
||||||
@@ -64,7 +72,7 @@ bool RmToolChainOperation::setArguments(const QStringList &args)
|
|||||||
|
|
||||||
if (current == "--id") {
|
if (current == "--id") {
|
||||||
if (next.isNull()) {
|
if (next.isNull()) {
|
||||||
std::cerr << "No parameter for --id given." << std::endl << std::endl;
|
qCCritical(rmtoolchainlog) << "No parameter for --id given.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++i; // skip next;
|
++i; // skip next;
|
||||||
@@ -74,7 +82,7 @@ bool RmToolChainOperation::setArguments(const QStringList &args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_id.isEmpty())
|
if (m_id.isEmpty())
|
||||||
std::cerr << "No id given." << std::endl << std::endl;
|
qCCritical(rmtoolchainlog) << "No id given.";
|
||||||
|
|
||||||
return !m_id.isEmpty();
|
return !m_id.isEmpty();
|
||||||
}
|
}
|
||||||
@@ -93,60 +101,72 @@ int RmToolChainOperation::execute() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool RmToolChainOperation::test() const
|
void RmToolChainOperation::unittest()
|
||||||
{
|
{
|
||||||
// Add toolchain:
|
// Add toolchain:
|
||||||
QVariantMap map = AddToolChainOperation::initializeToolChains();
|
QVariantMap map = AddToolChainOperation::initializeToolChains();
|
||||||
map = AddToolChainData{"testId", "langId", "name", "/tmp/test", "test-abi",
|
|
||||||
"test-abi,test-abi2", {{"ExtraKey", QVariant("ExtraValue")}}}
|
|
||||||
.addToolChain(map);
|
|
||||||
|
|
||||||
map = AddToolChainData{"testId2", "langId", "other name", "/tmp/test2", "test-abi",
|
AddToolChainData d;
|
||||||
"test-abi,test-abi2", {}}
|
d.m_id = "testId";
|
||||||
.addToolChain(map);
|
d.m_languageId = "langId";
|
||||||
|
d.m_displayName = "name";
|
||||||
|
d.m_path = "/tmp/test";
|
||||||
|
d.m_targetAbi = "test-abi";
|
||||||
|
d.m_supportedAbis = "test-abi,test-abi2";
|
||||||
|
d.m_extra = {{"ExtraKey", QVariant("ExtraValue")}};
|
||||||
|
|
||||||
|
map = d.addToolChain(map);
|
||||||
|
|
||||||
|
d.m_id = "testId2";
|
||||||
|
d.m_languageId = "langId";
|
||||||
|
d.m_displayName = "other name";
|
||||||
|
d.m_path = "/tmp/test2";
|
||||||
|
d.m_targetAbi = "test-abi";
|
||||||
|
d.m_supportedAbis = "test-abi,test-abi2";
|
||||||
|
d.m_extra = {};
|
||||||
|
map = d.addToolChain(map);
|
||||||
|
|
||||||
|
QTest::ignoreMessage(QtCriticalMsg, "Error: Count found in toolchains file seems wrong.");
|
||||||
QVariantMap result = rmToolChain(QVariantMap(), "nonexistent");
|
QVariantMap result = rmToolChain(QVariantMap(), "nonexistent");
|
||||||
if (!result.isEmpty())
|
QVERIFY(result.isEmpty());
|
||||||
return false;
|
|
||||||
|
|
||||||
result = rmToolChain(map, "nonexistent");
|
result = rmToolChain(map, "nonexistent");
|
||||||
if (result != map)
|
QCOMPARE(result, map);
|
||||||
return false;
|
|
||||||
|
|
||||||
result = rmToolChain(map, "testId2");
|
result = rmToolChain(map, "testId2");
|
||||||
if (result == map
|
QVERIFY(result != map);
|
||||||
|| result.value(COUNT, 0).toInt() != 1
|
QCOMPARE(result.value(COUNT, 0).toInt(), 1);
|
||||||
|| !result.contains("ToolChain.0") || result.value("ToolChain.0") != map.value("ToolChain.0"))
|
QVERIFY(result.contains("ToolChain.0"));
|
||||||
return false;
|
QCOMPARE(result.value("ToolChain.0"), map.value("ToolChain.0"));
|
||||||
|
|
||||||
result = rmToolChain(map, "testId");
|
result = rmToolChain(map, "testId");
|
||||||
if (result == map
|
QVERIFY(result != map);
|
||||||
|| result.value(COUNT, 0).toInt() != 1
|
QCOMPARE(result.value(COUNT, 0).toInt(), 1);
|
||||||
|| !result.contains("ToolChain.0") || result.value("ToolChain.0") != map.value("ToolChain.1"))
|
QVERIFY(result.contains("ToolChain.0"));
|
||||||
return false;
|
QCOMPARE(result.value("ToolChain.0"), map.value("ToolChain.1"));
|
||||||
|
|
||||||
result = rmToolChain(result, "testId2");
|
result = rmToolChain(result, "testId2");
|
||||||
if (result == map
|
QVERIFY(result != map);
|
||||||
|| result.value(COUNT, 0).toInt() != 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
QCOMPARE(result.value(COUNT, 0).toInt(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QVariantMap RmToolChainOperation::rmToolChain(const QVariantMap &map, const QString &id)
|
QVariantMap RmToolChainOperation::rmToolChain(const QVariantMap &map, const QString &id)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Find count of tool chains:
|
// Find count of tool chains:
|
||||||
bool ok;
|
bool ok;
|
||||||
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
int count = GetOperation::get(map, COUNT).toInt(&ok);
|
||||||
if (!ok || count < 0) {
|
if (!ok || count < 0) {
|
||||||
std::cerr << "Error: Count found in toolchains file seems wrong." << std::endl;
|
qCCritical(rmtoolchainlog) << "Error: Count found in toolchains file seems wrong.";
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList tcList;
|
QVariantList tcList;
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
QVariantMap tcData = GetOperation::get(map, QString::fromLatin1(PREFIX) + QString::number(i)).toMap();
|
QVariantMap tcData
|
||||||
|
= GetOperation::get(map, QString::fromLatin1(PREFIX) + QString::number(i)).toMap();
|
||||||
if (tcData.value(ID).toString() != id)
|
if (tcData.value(ID).toString() != id)
|
||||||
tcList.append(tcData);
|
tcList.append(tcData);
|
||||||
}
|
}
|
||||||
@@ -158,4 +178,3 @@ QVariantMap RmToolChainOperation::rmToolChain(const QVariantMap &map, const QStr
|
|||||||
|
|
||||||
return newMap;
|
return newMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,7 +41,8 @@ public:
|
|||||||
int execute() const final;
|
int execute() const final;
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool test() const final;
|
static void unittest();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QVariantMap rmToolChain(const QVariantMap &map, const QString &id);
|
static QVariantMap rmToolChain(const QVariantMap &map, const QString &id);
|
||||||
|
@@ -6,8 +6,7 @@ QtcTool {
|
|||||||
Depends { name: "Qt.core" }
|
Depends { name: "Qt.core" }
|
||||||
Depends { name: "app_version_header" }
|
Depends { name: "app_version_header" }
|
||||||
Depends { name: "Qt.testlib"; condition: project.withAutotests }
|
Depends { name: "Qt.testlib"; condition: project.withAutotests }
|
||||||
|
Depends { name: "sdktoolLib" }
|
||||||
property string libsDir: path + "/../../libs"
|
|
||||||
|
|
||||||
cpp.defines: base.concat([
|
cpp.defines: base.concat([
|
||||||
"UTILS_LIBRARY",
|
"UTILS_LIBRARY",
|
||||||
@@ -24,73 +23,8 @@ QtcTool {
|
|||||||
condition: qbs.targetOS.contains("macos")
|
condition: qbs.targetOS.contains("macos")
|
||||||
cpp.frameworks: ["Foundation"]
|
cpp.frameworks: ["Foundation"]
|
||||||
}
|
}
|
||||||
cpp.includePaths: base.concat([libsDir])
|
|
||||||
|
|
||||||
files: [
|
files: [
|
||||||
"addabiflavor.cpp", "addabiflavor.h",
|
|
||||||
"addcmakeoperation.cpp", "addcmakeoperation.h",
|
|
||||||
"adddebuggeroperation.cpp", "adddebuggeroperation.h",
|
|
||||||
"adddeviceoperation.cpp", "adddeviceoperation.h",
|
|
||||||
"addkeysoperation.cpp",
|
|
||||||
"addkeysoperation.h",
|
|
||||||
"addkitoperation.cpp",
|
|
||||||
"addkitoperation.h",
|
|
||||||
"addqtoperation.cpp",
|
|
||||||
"addqtoperation.h",
|
|
||||||
"addtoolchainoperation.cpp",
|
|
||||||
"addtoolchainoperation.h",
|
|
||||||
"addvalueoperation.cpp",
|
|
||||||
"addvalueoperation.h",
|
|
||||||
"findkeyoperation.cpp",
|
|
||||||
"findkeyoperation.h",
|
|
||||||
"findvalueoperation.cpp",
|
|
||||||
"findvalueoperation.h",
|
|
||||||
"getoperation.cpp",
|
|
||||||
"getoperation.h",
|
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
"operation.cpp",
|
|
||||||
"operation.h",
|
|
||||||
"rmcmakeoperation.cpp", "rmcmakeoperation.h",
|
|
||||||
"rmdebuggeroperation.cpp", "rmdebuggeroperation.h",
|
|
||||||
"rmdeviceoperation.cpp", "rmdeviceoperation.h",
|
|
||||||
"rmkeysoperation.cpp",
|
|
||||||
"rmkeysoperation.h",
|
|
||||||
"rmkitoperation.cpp",
|
|
||||||
"rmkitoperation.h",
|
|
||||||
"rmqtoperation.cpp",
|
|
||||||
"rmqtoperation.h",
|
|
||||||
"rmtoolchainoperation.cpp",
|
|
||||||
"rmtoolchainoperation.h",
|
|
||||||
"settings.cpp",
|
|
||||||
"settings.h",
|
|
||||||
]
|
|
||||||
|
|
||||||
Group {
|
|
||||||
name: "Utils"
|
|
||||||
prefix: libsDir + "/utils/"
|
|
||||||
files: [
|
|
||||||
"commandline.cpp", "commandline.h",
|
|
||||||
"environment.cpp", "environment.h",
|
|
||||||
"filepath.cpp", "filepath.h",
|
|
||||||
"fileutils.cpp", "fileutils.h",
|
|
||||||
"hostosinfo.cpp", "hostosinfo.h",
|
|
||||||
"macroexpander.cpp", "macroexpander.h",
|
|
||||||
"namevaluedictionary.cpp", "namevaluedictionary.h",
|
|
||||||
"namevalueitem.cpp", "namevalueitem.h",
|
|
||||||
"persistentsettings.cpp", "persistentsettings.h",
|
|
||||||
"porting.h",
|
|
||||||
"qtcassert.cpp", "qtcassert.h",
|
|
||||||
"savefile.cpp", "savefile.h",
|
|
||||||
"stringutils.cpp"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Group {
|
|
||||||
name: "Utils/macOS"
|
|
||||||
condition: qbs.targetOS.contains("macos")
|
|
||||||
prefix: libsDir + "/utils/"
|
|
||||||
files: [
|
|
||||||
"fileutils_mac.h",
|
|
||||||
"fileutils_mac.mm",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
109
src/tools/sdktool/sdktoollib.qbs
Normal file
109
src/tools/sdktool/sdktoollib.qbs
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import qbs 1.0
|
||||||
|
|
||||||
|
QtcLibrary {
|
||||||
|
name: "sdktoolLib"
|
||||||
|
|
||||||
|
type: "staticlibrary"
|
||||||
|
|
||||||
|
Depends { name: "Qt.core" }
|
||||||
|
Depends { name: "app_version_header" }
|
||||||
|
Depends { name: "Qt.testlib"; condition: project.withAutotests }
|
||||||
|
|
||||||
|
property string libsDir: path + "/../../libs"
|
||||||
|
|
||||||
|
cpp.defines: base.concat([
|
||||||
|
"UTILS_LIBRARY",
|
||||||
|
qbs.targetOS.contains("macos")
|
||||||
|
? 'DATA_PATH="."'
|
||||||
|
: qbs.targetOS.contains("windows") ? 'DATA_PATH="../share/qtcreator"'
|
||||||
|
: 'DATA_PATH="../../share/qtcreator"'
|
||||||
|
])
|
||||||
|
cpp.dynamicLibraries: {
|
||||||
|
if (qbs.targetOS.contains("windows"))
|
||||||
|
return ["user32", "shell32"]
|
||||||
|
}
|
||||||
|
Properties {
|
||||||
|
condition: qbs.targetOS.contains("macos")
|
||||||
|
cpp.frameworks: ["Foundation"]
|
||||||
|
}
|
||||||
|
cpp.includePaths: base.concat([libsDir])
|
||||||
|
|
||||||
|
Export {
|
||||||
|
Depends { name: "cpp" }
|
||||||
|
cpp.includePaths: [exportingProduct.sourceDirectory, exportingProduct.libsDir]
|
||||||
|
}
|
||||||
|
|
||||||
|
files: [
|
||||||
|
"addabiflavor.cpp",
|
||||||
|
"addabiflavor.h",
|
||||||
|
"addcmakeoperation.cpp",
|
||||||
|
"addcmakeoperation.h",
|
||||||
|
"adddebuggeroperation.cpp",
|
||||||
|
"adddebuggeroperation.h",
|
||||||
|
"adddeviceoperation.cpp",
|
||||||
|
"adddeviceoperation.h",
|
||||||
|
"addkeysoperation.cpp",
|
||||||
|
"addkeysoperation.h",
|
||||||
|
"addkitoperation.cpp",
|
||||||
|
"addkitoperation.h",
|
||||||
|
"addqtoperation.cpp",
|
||||||
|
"addqtoperation.h",
|
||||||
|
"addtoolchainoperation.cpp",
|
||||||
|
"addtoolchainoperation.h",
|
||||||
|
"addvalueoperation.cpp",
|
||||||
|
"addvalueoperation.h",
|
||||||
|
"findkeyoperation.cpp",
|
||||||
|
"findkeyoperation.h",
|
||||||
|
"findvalueoperation.cpp",
|
||||||
|
"findvalueoperation.h",
|
||||||
|
"getoperation.cpp",
|
||||||
|
"getoperation.h",
|
||||||
|
"operation.cpp",
|
||||||
|
"operation.h",
|
||||||
|
"rmcmakeoperation.cpp",
|
||||||
|
"rmcmakeoperation.h",
|
||||||
|
"rmdebuggeroperation.cpp",
|
||||||
|
"rmdebuggeroperation.h",
|
||||||
|
"rmdeviceoperation.cpp",
|
||||||
|
"rmdeviceoperation.h",
|
||||||
|
"rmkeysoperation.cpp",
|
||||||
|
"rmkeysoperation.h",
|
||||||
|
"rmkitoperation.cpp",
|
||||||
|
"rmkitoperation.h",
|
||||||
|
"rmqtoperation.cpp",
|
||||||
|
"rmqtoperation.h",
|
||||||
|
"rmtoolchainoperation.cpp",
|
||||||
|
"rmtoolchainoperation.h",
|
||||||
|
"settings.cpp",
|
||||||
|
"settings.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
Group {
|
||||||
|
name: "Utils"
|
||||||
|
prefix: libsDir + "/utils/"
|
||||||
|
files: [
|
||||||
|
"commandline.cpp", "commandline.h",
|
||||||
|
"environment.cpp", "environment.h",
|
||||||
|
"filepath.cpp", "filepath.h",
|
||||||
|
"fileutils.cpp", "fileutils.h",
|
||||||
|
"hostosinfo.cpp", "hostosinfo.h",
|
||||||
|
"macroexpander.cpp", "macroexpander.h",
|
||||||
|
"namevaluedictionary.cpp", "namevaluedictionary.h",
|
||||||
|
"namevalueitem.cpp", "namevalueitem.h",
|
||||||
|
"persistentsettings.cpp", "persistentsettings.h",
|
||||||
|
"porting.h",
|
||||||
|
"qtcassert.cpp", "qtcassert.h",
|
||||||
|
"savefile.cpp", "savefile.h",
|
||||||
|
"stringutils.cpp"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
Group {
|
||||||
|
name: "Utils/macOS"
|
||||||
|
condition: qbs.targetOS.contains("macos")
|
||||||
|
prefix: libsDir + "/utils/"
|
||||||
|
files: [
|
||||||
|
"fileutils_mac.h",
|
||||||
|
"fileutils_mac.mm",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@@ -15,6 +15,7 @@ Project {
|
|||||||
"qtc-askpass/qtc-askpass.qbs",
|
"qtc-askpass/qtc-askpass.qbs",
|
||||||
"qtpromaker/qtpromaker.qbs",
|
"qtpromaker/qtpromaker.qbs",
|
||||||
"sdktool/sdktool.qbs",
|
"sdktool/sdktool.qbs",
|
||||||
|
"sdktool/sdktoollib.qbs",
|
||||||
"valgrindfake/valgrindfake.qbs",
|
"valgrindfake/valgrindfake.qbs",
|
||||||
"iostool/iostool.qbs",
|
"iostool/iostool.qbs",
|
||||||
].concat(project.additionalTools)
|
].concat(project.additionalTools)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
qtc_output_binary_dir(_output_binary_dir)
|
qtc_output_binary_dir(_output_binary_dir)
|
||||||
add_qtc_test(tst_sdktool
|
add_qtc_test(tst_sdktool
|
||||||
DEPENDS Utils
|
DEPENDS sdktoolLib
|
||||||
DEFINES SDKTOOL_DIR="${_output_binary_dir}/${IDE_LIBEXEC_PATH}"
|
DEFINES SDKTOOL_DIR="${_output_binary_dir}/${IDE_LIBEXEC_PATH}"
|
||||||
SOURCES tst_sdktool.cpp
|
SOURCES tst_sdktool.cpp
|
||||||
)
|
)
|
||||||
|
@@ -3,6 +3,8 @@ import qbs.FileInfo
|
|||||||
QtcAutotest {
|
QtcAutotest {
|
||||||
name: "sdktool autotest"
|
name: "sdktool autotest"
|
||||||
|
|
||||||
|
Depends { name: "sdktoolLib" }
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
name: "Test sources"
|
name: "Test sources"
|
||||||
files: "tst_sdktool.cpp"
|
files: "tst_sdktool.cpp"
|
||||||
|
@@ -28,27 +28,56 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
|
#ifndef WITH_TESTS
|
||||||
|
#define WITH_TESTS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "addabiflavor.h"
|
||||||
|
#include "addcmakeoperation.h"
|
||||||
|
#include "adddebuggeroperation.h"
|
||||||
|
#include "adddeviceoperation.h"
|
||||||
|
#include "addkeysoperation.h"
|
||||||
|
#include "addqtoperation.h"
|
||||||
|
#include "addtoolchainoperation.h"
|
||||||
|
#include "addvalueoperation.h"
|
||||||
|
#include "findkeyoperation.h"
|
||||||
|
#include "findvalueoperation.h"
|
||||||
|
#include "getoperation.h"
|
||||||
|
#include "rmcmakeoperation.h"
|
||||||
|
#include "rmdebuggeroperation.h"
|
||||||
|
#include "rmdeviceoperation.h"
|
||||||
|
#include "rmkeysoperation.h"
|
||||||
|
#include "rmkitoperation.h"
|
||||||
|
#include "rmqtoperation.h"
|
||||||
|
#include "rmtoolchainoperation.h"
|
||||||
|
#include "addkitoperation.h"
|
||||||
|
|
||||||
class SdktoolTest : public QObject
|
class SdktoolTest : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void testSdktool();
|
void test_AddAbiFlavorOperation() { AddAbiFlavor::unittest(); }
|
||||||
|
void test_AddCMakeOperation() { AddCMakeOperation::unittest(); }
|
||||||
|
void test_AddDebuggerOperation() { AddDebuggerOperation::unittest(); }
|
||||||
|
void test_AddDeviceOperation() { AddDeviceOperation::unittest(); }
|
||||||
|
void test_AddKeysOperation() { AddKeysOperation::unittest(); }
|
||||||
|
void test_AddKitOperation() { AddKitOperation::unittest(); }
|
||||||
|
void test_AddQtOperation() { AddQtOperation::unittest(); }
|
||||||
|
void test_AddToolchainOperation() { AddToolChainOperation::unittest(); }
|
||||||
|
void test_AddValueOperation() { AddValueOperation::unittest(); }
|
||||||
|
void test_FindKeyOperation() { FindKeyOperation::unittest(); }
|
||||||
|
void test_FindValueOperation() { FindValueOperation::unittest(); }
|
||||||
|
void test_GetOperation() { GetOperation::unittest(); }
|
||||||
|
void test_RmCMakeOperation() { RmCMakeOperation::unittest(); }
|
||||||
|
void test_RmDebuggerOperation() { RmDebuggerOperation::unittest(); }
|
||||||
|
void test_RmDeviceOperation() { RmDeviceOperation::unittest(); }
|
||||||
|
void test_RmKeysOperation() { RmKeysOperation::unittest(); }
|
||||||
|
void test_RmKitOperation() { RmKitOperation::unittest(); }
|
||||||
|
void test_RmQtOperation() { RmQtOperation::unittest(); }
|
||||||
|
void test_RmToolChainOperation() { RmToolChainOperation::unittest(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
void SdktoolTest::testSdktool()
|
|
||||||
{
|
|
||||||
QDir rootDir(SDKTOOL_DIR);
|
|
||||||
QProcess process;
|
|
||||||
process.start(rootDir.absoluteFilePath(QLatin1String("sdktool")),
|
|
||||||
QStringList() << QLatin1String("-test"));
|
|
||||||
process.waitForFinished();
|
|
||||||
QByteArray output = process.readAllStandardError();
|
|
||||||
for (auto line : output.split('\n'))
|
|
||||||
qDebug() << line;
|
|
||||||
QCOMPARE(process.exitCode(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
QTEST_MAIN(SdktoolTest)
|
QTEST_MAIN(SdktoolTest)
|
||||||
|
|
||||||
#include "tst_sdktool.moc"
|
#include "tst_sdktool.moc"
|
||||||
|
Reference in New Issue
Block a user