aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/pkgconfig
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/pkgconfig')
-rw-r--r--tests/auto/pkgconfig/CMakeLists.txt2
-rw-r--r--tests/auto/pkgconfig/testdata/empty-variable.json21
-rw-r--r--tests/auto/pkgconfig/testdata/empty-variable.pc13
-rw-r--r--tests/auto/pkgconfig/testdata/lib/pkgconfig/prefix.pc13
-rw-r--r--tests/auto/pkgconfig/testdata/requires-test-merged-static.json22
-rw-r--r--tests/auto/pkgconfig/testdata/requires-test-merged.json19
-rw-r--r--tests/auto/pkgconfig/tst_pkgconfig.cpp81
-rw-r--r--tests/auto/pkgconfig/tst_pkgconfig.h4
8 files changed, 118 insertions, 57 deletions
diff --git a/tests/auto/pkgconfig/CMakeLists.txt b/tests/auto/pkgconfig/CMakeLists.txt
index 4d60491ba..74a13a8ab 100644
--- a/tests/auto/pkgconfig/CMakeLists.txt
+++ b/tests/auto/pkgconfig/CMakeLists.txt
@@ -4,5 +4,5 @@ add_qbs_test(pkgconfig
tst_pkgconfig.h
DEPENDS
qbspkgconfig
- qbsscriptengine
+ qbsquickjsheaders
)
diff --git a/tests/auto/pkgconfig/testdata/empty-variable.json b/tests/auto/pkgconfig/testdata/empty-variable.json
new file mode 100644
index 000000000..b96689979
--- /dev/null
+++ b/tests/auto/pkgconfig/testdata/empty-variable.json
@@ -0,0 +1,21 @@
+{
+ "Name": "Empty Variable test",
+ "Description": "Checks that empty variables are handled correcty",
+ "Version": "1.0.0",
+ "Vars": {
+ "rootprefix": "",
+ "prefix": "/usr",
+ "exec_prefix": "//usr",
+ "libdir": "//usr/lib",
+ "includedir": "//usr/include"
+ },
+ "Libs": [
+ {"Type": "LibraryName", "Value": "simple"}
+ ],
+ "LibsPrivate": [
+ {"Type": "LibraryName", "Value": "m"}
+ ],
+ "Cflags": [
+ {"Type": "IncludePath", "Value": "//usr/include"}
+ ]
+}
diff --git a/tests/auto/pkgconfig/testdata/empty-variable.pc b/tests/auto/pkgconfig/testdata/empty-variable.pc
new file mode 100644
index 000000000..581382b7e
--- /dev/null
+++ b/tests/auto/pkgconfig/testdata/empty-variable.pc
@@ -0,0 +1,13 @@
+rootprefix=
+prefix=/usr
+exec_prefix=${rootprefix}/${prefix}
+libdir=${exec_prefix}/lib
+includedir=${rootprefix}/${prefix}/include
+
+Name: Empty Variable test
+Description: Checks that empty variables are handled correcty
+Version: 1.0.0
+Requires:
+Libs: -lsimple
+Libs.private: -lm
+Cflags: -I${includedir}
diff --git a/tests/auto/pkgconfig/testdata/lib/pkgconfig/prefix.pc b/tests/auto/pkgconfig/testdata/lib/pkgconfig/prefix.pc
new file mode 100644
index 000000000..64b980803
--- /dev/null
+++ b/tests/auto/pkgconfig/testdata/lib/pkgconfig/prefix.pc
@@ -0,0 +1,13 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=/usr/include
+usrdir=/usrdir
+
+Name: Prefix test
+Description: This tests prefix auto detection
+Version: 1.0.0
+Requires:
+Libs: -lprefix
+Libs.private: -lm
+Cflags: -I${includedir}
diff --git a/tests/auto/pkgconfig/testdata/requires-test-merged-static.json b/tests/auto/pkgconfig/testdata/requires-test-merged-static.json
deleted file mode 100644
index 2c43b2d40..000000000
--- a/tests/auto/pkgconfig/testdata/requires-test-merged-static.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "Name": "Requires test package",
- "Description": "Dummy pkgconfig test package for testing Requires/Requires.private",
- "Version": "1.0.0",
- "Libs": [
- {"Type": "LibraryPath", "Value": "/public-dep/lib"},
- {"Type": "LibraryName", "Value": "public-dep"},
- {"Type": "LibraryPath", "Value": "/private-dep/lib"},
- {"Type": "LibraryName", "Value": "private-dep"},
- {"Type": "LibraryPath", "Value": "/requires-test/lib"},
- {"Type": "LibraryName", "Value": "requires-test"}
- ],
- "Cflags": [
- {"Type": "IncludePath", "Value": "/public-dep/include"},
- {"Type": "IncludePath", "Value": "/private-dep/include"},
- {"Type": "IncludePath", "Value": "/requires-test/include"}
- ],
- "Requires": [
- ],
- "RequiresPrivate": [
- ]
-}
diff --git a/tests/auto/pkgconfig/testdata/requires-test-merged.json b/tests/auto/pkgconfig/testdata/requires-test-merged.json
deleted file mode 100644
index 88114ba30..000000000
--- a/tests/auto/pkgconfig/testdata/requires-test-merged.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "Name": "Requires test package",
- "Description": "Dummy pkgconfig test package for testing Requires/Requires.private",
- "Version": "1.0.0",
- "Libs": [
- {"Type": "LibraryPath", "Value": "/public-dep/lib"},
- {"Type": "LibraryName", "Value": "public-dep"},
- {"Type": "LibraryPath", "Value": "/requires-test/lib"},
- {"Type": "LibraryName", "Value": "requires-test"}
- ],
- "Cflags": [
- {"Type": "IncludePath", "Value": "/public-dep/include"},
- {"Type": "IncludePath", "Value": "/requires-test/include"}
- ],
- "Requires": [
- ],
- "RequiresPrivate": [
- ]
-}
diff --git a/tests/auto/pkgconfig/tst_pkgconfig.cpp b/tests/auto/pkgconfig/tst_pkgconfig.cpp
index ec62e1a7f..86d954259 100644
--- a/tests/auto/pkgconfig/tst_pkgconfig.cpp
+++ b/tests/auto/pkgconfig/tst_pkgconfig.cpp
@@ -33,6 +33,7 @@
#include <tools/fileinfo.h>
#include <tools/hostosinfo.h>
#include <pkgconfig.h>
+#include <pcparser.h>
#include <jsextensions/pkgconfigjs.h>
#include <QJsonArray>
@@ -58,6 +59,48 @@ void TestPkgConfig::initTestCase()
qPrintable(errorMessage));
}
+void TestPkgConfig::fileName()
+{
+ QCOMPARE(qbs::Internal::fileName(""), "");
+ QCOMPARE(qbs::Internal::fileName("file.txt"), "file.txt");
+ QCOMPARE(qbs::Internal::fileName("/home/user/file.txt"), "file.txt");
+ QCOMPARE(qbs::Internal::fileName("/"), "");
+#if defined(Q_OS_WIN)
+ QCOMPARE(qbs::Internal::fileName("c:file.txt"), "file.txt");
+ QCOMPARE(qbs::Internal::fileName("c:"), "");
+#endif
+}
+
+void TestPkgConfig::completeBaseName()
+{
+ QCOMPARE(qbs::Internal::completeBaseName(""), "");
+ QCOMPARE(qbs::Internal::completeBaseName("file.txt"), "file");
+ QCOMPARE(qbs::Internal::completeBaseName("archive.tar.gz"), "archive.tar");
+ QCOMPARE(qbs::Internal::completeBaseName("/home/user/file.txt"), "file");
+#if defined(Q_OS_WIN)
+ QCOMPARE(qbs::Internal::completeBaseName("c:file.txt"), "file");
+ QCOMPARE(qbs::Internal::completeBaseName("c:archive.tar.gz"), "archive.tar");
+ QCOMPARE(qbs::Internal::completeBaseName("c:"), "");
+#endif
+}
+
+void TestPkgConfig::parentPath()
+{
+ QCOMPARE(qbs::Internal::parentPath(""), "");
+ QCOMPARE(qbs::Internal::parentPath("file.txt"), ".");
+ QCOMPARE(qbs::Internal::parentPath("/home/user/file.txt"), "/home/user");
+ QCOMPARE(qbs::Internal::parentPath("/home/user/"), "/home/user");
+ QCOMPARE(qbs::Internal::parentPath("/home"), "/");
+ QCOMPARE(qbs::Internal::parentPath("/"), "/");
+#if defined(Q_OS_WIN)
+ QCOMPARE(qbs::Internal::parentPath("c:/folder/file.txt"), "c:/folder");
+ QCOMPARE(qbs::Internal::parentPath("c:/folder/"), "c:/folder");
+ QCOMPARE(qbs::Internal::parentPath("c:/folder"), "c:/");
+ QCOMPARE(qbs::Internal::parentPath("c:/"), "c:/");
+ QCOMPARE(qbs::Internal::parentPath("c:"), "c:");
+#endif
+}
+
void TestPkgConfig::pkgConfig()
{
QFETCH(QString, pcFileName);
@@ -67,9 +110,6 @@ void TestPkgConfig::pkgConfig()
if (jsonFileName.isEmpty())
jsonFileName = pcFileName;
- if (!optionsMap.contains("mergeDependencies"))
- optionsMap["mergeDependencies"] = false;
-
Options options = qbs::Internal::PkgConfigJs::convertOptions(
QProcessEnvironment::systemEnvironment(), optionsMap);
options.libDirs.push_back(m_workingDataDir.toStdString());
@@ -168,20 +208,14 @@ void TestPkgConfig::pkgConfig_data()
QTest::addColumn<QString>("jsonFileName");
QTest::addColumn<QVariantMap>("optionsMap");
+ QTest::newRow("empty-variable")
+ << QStringLiteral("empty-variable") << QString() << QVariantMap();
QTest::newRow("non-l-required")
<< QStringLiteral("non-l-required") << QString() << QVariantMap();
QTest::newRow("simple")
<< QStringLiteral("simple") << QString() << QVariantMap();
QTest::newRow("requires-test")
<< QStringLiteral("requires-test") << QString() << QVariantMap();
- QTest::newRow("requires-test-merged")
- << QStringLiteral("requires-test")
- << QStringLiteral("requires-test-merged")
- << QVariantMap({{"mergeDependencies", true}});
- QTest::newRow("requires-test-merged-static")
- << QStringLiteral("requires-test")
- << QStringLiteral("requires-test-merged-static")
- << QVariantMap({{"mergeDependencies", true}, {"staticMode", true}});
QTest::newRow("special-flags")
<< QStringLiteral("special-flags") << QString() << QVariantMap();
QTest::newRow("system")
@@ -192,10 +226,6 @@ void TestPkgConfig::pkgConfig_data()
<< QStringLiteral("tilde") << QString() << QVariantMap();
QTest::newRow("variables")
<< QStringLiteral("variables") << QString() << QVariantMap();
- QTest::newRow("variables-merged")
- << QStringLiteral("variables")
- << QString()
- << QVariantMap({{"mergeDependencies", true}});
QTest::newRow("whitespace")
<< QStringLiteral("whitespace") << QString() << QVariantMap();
QTest::newRow("base.name")
@@ -212,4 +242,25 @@ void TestPkgConfig::benchSystem()
}
}
+void TestPkgConfig::prefix()
+{
+ const auto prefixDir = m_workingDataDir;
+ const auto libDir = m_workingDataDir + "/lib";
+ const auto includeDir = m_workingDataDir + "/include";
+ const auto pkgconfigDir = libDir + "/pkgconfig";
+ Options options = qbs::Internal::PkgConfigJs::convertOptions(
+ QProcessEnvironment::systemEnvironment(), {});
+ options.definePrefix = true;
+ options.libDirs.push_back(pkgconfigDir.toStdString());
+ PkgConfig pkgConfig(std::move(options));
+ const auto &packageOr = pkgConfig.getPackage("prefix");
+ QVERIFY(packageOr.isValid());
+ const auto &package = packageOr.asPackage();
+ QCOMPARE(package.variables.at("prefix"), prefixDir.toStdString());
+ QCOMPARE(package.variables.at("exec_prefix"), prefixDir.toStdString());
+ QCOMPARE(package.variables.at("libdir"), libDir.toStdString());
+ QCOMPARE(package.variables.at("includedir"), includeDir.toStdString());
+ QCOMPARE(package.variables.at("usrdir"), "/usrdir");
+}
+
QTEST_MAIN(TestPkgConfig)
diff --git a/tests/auto/pkgconfig/tst_pkgconfig.h b/tests/auto/pkgconfig/tst_pkgconfig.h
index 687411862..47654e1ec 100644
--- a/tests/auto/pkgconfig/tst_pkgconfig.h
+++ b/tests/auto/pkgconfig/tst_pkgconfig.h
@@ -41,9 +41,13 @@ public:
private slots:
void initTestCase();
+ void fileName();
+ void completeBaseName();
+ void parentPath();
void pkgConfig();
void pkgConfig_data();
void benchSystem();
+ void prefix();
private:
const QString m_sourceDataDir;