forked from qt-creator/qt-creator
Vcpkg: Parse dependencies from vcpkg.json manifest
Also, extend the tests accordingly. Task-number: QTCREATORBUG-29333 Change-Id: I24104b6b0bdbbd47c36cc4d43f4647169fa619d8 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -21,6 +21,7 @@ void VcpkgSearchTest::testVcpkgJsonParser_data()
|
|||||||
QTest::addColumn<QString>("name");
|
QTest::addColumn<QString>("name");
|
||||||
QTest::addColumn<QString>("version");
|
QTest::addColumn<QString>("version");
|
||||||
QTest::addColumn<QString>("license");
|
QTest::addColumn<QString>("license");
|
||||||
|
QTest::addColumn<QStringList>("dependencies");
|
||||||
QTest::addColumn<QString>("shortDescription");
|
QTest::addColumn<QString>("shortDescription");
|
||||||
QTest::addColumn<QStringList>("description");
|
QTest::addColumn<QStringList>("description");
|
||||||
QTest::addColumn<QUrl>("homepage");
|
QTest::addColumn<QUrl>("homepage");
|
||||||
@@ -33,6 +34,7 @@ void VcpkgSearchTest::testVcpkgJsonParser_data()
|
|||||||
"description": "The CImg Library is a small, open-source, and modern C++ toolkit for image processing",
|
"description": "The CImg Library is a small, open-source, and modern C++ toolkit for image processing",
|
||||||
"homepage": "https://github.com/dtschump/CImg",
|
"homepage": "https://github.com/dtschump/CImg",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
"fmt",
|
||||||
{
|
{
|
||||||
"name": "vcpkg-cmake",
|
"name": "vcpkg-cmake",
|
||||||
"host": true
|
"host": true
|
||||||
@@ -42,6 +44,7 @@ void VcpkgSearchTest::testVcpkgJsonParser_data()
|
|||||||
<< "cimg"
|
<< "cimg"
|
||||||
<< "2.9.9"
|
<< "2.9.9"
|
||||||
<< ""
|
<< ""
|
||||||
|
<< QStringList({"fmt", "vcpkg-cmake"})
|
||||||
<< "The CImg Library is a small, open-source, and modern C++ toolkit for image processing"
|
<< "The CImg Library is a small, open-source, and modern C++ toolkit for image processing"
|
||||||
<< QStringList()
|
<< QStringList()
|
||||||
<< QUrl::fromUserInput("https://github.com/dtschump/CImg")
|
<< QUrl::fromUserInput("https://github.com/dtschump/CImg")
|
||||||
@@ -62,6 +65,7 @@ void VcpkgSearchTest::testVcpkgJsonParser_data()
|
|||||||
<< "catch-classic"
|
<< "catch-classic"
|
||||||
<< "1.12.2"
|
<< "1.12.2"
|
||||||
<< ""
|
<< ""
|
||||||
|
<< QStringList()
|
||||||
<< "A modern, header-only test framework for unit tests"
|
<< "A modern, header-only test framework for unit tests"
|
||||||
<< QStringList({"This is specifically the legacy 1.x branch provided for compatibility",
|
<< QStringList({"This is specifically the legacy 1.x branch provided for compatibility",
|
||||||
"with older compilers."})
|
"with older compilers."})
|
||||||
@@ -77,6 +81,7 @@ void VcpkgSearchTest::testVcpkgJsonParser_data()
|
|||||||
<< ""
|
<< ""
|
||||||
<< "1.0"
|
<< "1.0"
|
||||||
<< "WTFPL"
|
<< "WTFPL"
|
||||||
|
<< QStringList()
|
||||||
<< "foo"
|
<< "foo"
|
||||||
<< QStringList()
|
<< QStringList()
|
||||||
<< QUrl()
|
<< QUrl()
|
||||||
@@ -89,6 +94,7 @@ void VcpkgSearchTest::testVcpkgJsonParser()
|
|||||||
QFETCH(QString, name);
|
QFETCH(QString, name);
|
||||||
QFETCH(QString, version);
|
QFETCH(QString, version);
|
||||||
QFETCH(QString, license);
|
QFETCH(QString, license);
|
||||||
|
QFETCH(QStringList, dependencies);
|
||||||
QFETCH(QString, shortDescription);
|
QFETCH(QString, shortDescription);
|
||||||
QFETCH(QStringList, description);
|
QFETCH(QStringList, description);
|
||||||
QFETCH(QUrl, homepage);
|
QFETCH(QUrl, homepage);
|
||||||
@@ -101,6 +107,7 @@ void VcpkgSearchTest::testVcpkgJsonParser()
|
|||||||
QCOMPARE(mf.name, name);
|
QCOMPARE(mf.name, name);
|
||||||
QCOMPARE(mf.version, version);
|
QCOMPARE(mf.version, version);
|
||||||
QCOMPARE(mf.license, license);
|
QCOMPARE(mf.license, license);
|
||||||
|
QCOMPARE(mf.dependencies, dependencies);
|
||||||
QCOMPARE(mf.shortDescription, shortDescription);
|
QCOMPARE(mf.shortDescription, shortDescription);
|
||||||
QCOMPARE(mf.description, description);
|
QCOMPARE(mf.description, description);
|
||||||
QCOMPARE(mf.homepage, homepage);
|
QCOMPARE(mf.homepage, homepage);
|
||||||
|
|||||||
@@ -169,6 +169,15 @@ VcpkgManifest parseVcpkgManifest(const QByteArray &vcpkgManifestJsonData, bool *
|
|||||||
}
|
}
|
||||||
if (const QJsonValue license = jsonObject.value("license"); !license.isUndefined())
|
if (const QJsonValue license = jsonObject.value("license"); !license.isUndefined())
|
||||||
result.license = license.toString();
|
result.license = license.toString();
|
||||||
|
if (const QJsonValue deps = jsonObject.value("dependencies"); !deps.isUndefined()) {
|
||||||
|
const QJsonArray dependencies = deps.toArray();
|
||||||
|
for (const QJsonValue &dependency : dependencies) {
|
||||||
|
if (dependency.isString())
|
||||||
|
result.dependencies.append(dependency.toString());
|
||||||
|
else if (const QJsonValue name = dependency.toObject().value("name"); name.isString())
|
||||||
|
result.dependencies.append(name.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
if (const QJsonValue description = jsonObject.value("description"); !description.isUndefined()) {
|
if (const QJsonValue description = jsonObject.value("description"); !description.isUndefined()) {
|
||||||
if (description.isArray()) {
|
if (description.isArray()) {
|
||||||
const QJsonArray descriptionLines = description.toArray();
|
const QJsonArray descriptionLines = description.toArray();
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ struct VcpkgManifest
|
|||||||
QString name;
|
QString name;
|
||||||
QString version;
|
QString version;
|
||||||
QString license;
|
QString license;
|
||||||
|
QStringList dependencies;
|
||||||
QString shortDescription;
|
QString shortDescription;
|
||||||
QStringList description;
|
QStringList description;
|
||||||
QUrl homepage;
|
QUrl homepage;
|
||||||
|
|||||||
Reference in New Issue
Block a user