aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/blackbox/tst_blackboxapple.cpp
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2017-06-08 20:48:47 -0700
committerJake Petroules <jake.petroules@qt.io>2017-06-09 09:52:37 +0000
commit47f5c8f5d58e6dda33fa1c6229800bee2791dd89 (patch)
tree31ce5d7d7747fa3ef1a3d47860f1fea1a78ddf4c /tests/auto/blackbox/tst_blackboxapple.cpp
parentec3ef366a389ec9e6b23d9e3adf38988f2cceac2 (diff)
Find Xcode module properties using the standard mechanism
This is compatible with older versions of Xcode. Change-Id: I7828e7aa44ab7d29a62255bb0e3e891a97202f5e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests/auto/blackbox/tst_blackboxapple.cpp')
-rw-r--r--tests/auto/blackbox/tst_blackboxapple.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/tests/auto/blackbox/tst_blackboxapple.cpp b/tests/auto/blackbox/tst_blackboxapple.cpp
index 1ba0a5266..2af349e96 100644
--- a/tests/auto/blackbox/tst_blackboxapple.cpp
+++ b/tests/auto/blackbox/tst_blackboxapple.cpp
@@ -32,6 +32,7 @@
#include <tools/hostosinfo.h>
#include <tools/profile.h>
+#include <QtCore/qjsondocument.h>
#include <QtXml/qdom.h>
#include <regex>
@@ -50,28 +51,6 @@ public:
bool isDirSymLink() const { return isDir() && isSymLink(); }
};
-static qbs::Internal::Version findXcodeVersion()
-{
- QProcess process;
- process.start("pkgutil", QStringList("--pkg-info-plist=com.apple.pkg.Xcode"));
- process.waitForFinished();
-
- QDomDocument xcodeVersionDoc;
- if (xcodeVersionDoc.setContent(process.readAllStandardOutput())) {
- QDomNodeList nodes = xcodeVersionDoc.elementsByTagName(QStringLiteral("key"));
- for (int i = 0; i < nodes.count(); ++i) {
- QDomElement elem = nodes.at(i).toElement();
- if (elem.text().compare(QStringLiteral("pkg-version")) == 0) {
- return qbs::Internal::Version::fromString(
- QStringList(elem.nextSiblingElement().text().split(
- QLatin1Char('.')).mid(0, 3)).join(QLatin1Char('.')), true);
- }
- }
- }
-
- return qbs::Internal::Version();
-}
-
static QString getEmbeddedBinaryPlist(const QString &file)
{
QProcess p;
@@ -727,3 +706,25 @@ void TestBlackboxApple::xcode()
}
QTEST_MAIN(TestBlackboxApple)
+
+QVariantMap TestBlackboxApple::findXcode(int *status)
+{
+ QTemporaryDir temp;
+ QbsRunParameters params = QStringList({"-f", testDataDir + "/find/find-xcode.qbs",
+ "profile:none"});
+ params.useProfile = false;
+ params.buildDirectory = temp.path();
+ const int res = runQbs(params);
+ if (status)
+ *status = res;
+ QFile file(temp.path() + "/" + relativeProductBuildDir("find-xcode", "none")
+ + "/xcode.json");
+ if (!file.open(QIODevice::ReadOnly))
+ return QVariantMap { };
+ return QJsonDocument::fromJson(file.readAll()).toVariant().toMap();
+}
+
+qbs::Internal::Version TestBlackboxApple::findXcodeVersion()
+{
+ return qbs::Internal::Version::fromString(findXcode().value("version").toString());
+}