aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/blackbox
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
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')
-rw-r--r--tests/auto/blackbox/find/find-xcode.qbs41
-rw-r--r--tests/auto/blackbox/tst_blackboxapple.cpp45
-rw-r--r--tests/auto/blackbox/tst_blackboxapple.h10
3 files changed, 74 insertions, 22 deletions
diff --git a/tests/auto/blackbox/find/find-xcode.qbs b/tests/auto/blackbox/find/find-xcode.qbs
new file mode 100644
index 000000000..b42b2deb7
--- /dev/null
+++ b/tests/auto/blackbox/find/find-xcode.qbs
@@ -0,0 +1,41 @@
+import qbs
+import qbs.TextFile
+
+Product {
+ Depends { name: "xcode"; required: false }
+ type: ["json"]
+ Rule {
+ multiplex: true
+ Artifact {
+ filePath: ["xcode.json"]
+ fileTags: ["json"]
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = output.filePath;
+ cmd.sourceCode = function() {
+ var tools = {};
+ if (product.moduleProperty("xcode", "present")) {
+ var keys = [
+ "developerPath",
+ "version"
+ ];
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ tools[key] = product.xcode[key];
+ }
+ }
+
+ var tf;
+ try {
+ tf = new TextFile(output.filePath, TextFile.WriteOnly);
+ tf.writeLine(JSON.stringify(tools, undefined, 4));
+ } finally {
+ if (tf)
+ tf.close();
+ }
+ };
+ return cmd;
+ }
+ }
+}
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());
+}
diff --git a/tests/auto/blackbox/tst_blackboxapple.h b/tests/auto/blackbox/tst_blackboxapple.h
index e53c4c6dd..1b203bed2 100644
--- a/tests/auto/blackbox/tst_blackboxapple.h
+++ b/tests/auto/blackbox/tst_blackboxapple.h
@@ -31,6 +31,12 @@
#include "tst_blackboxbase.h"
+namespace qbs {
+namespace Internal {
+class Version;
+} // namespace Internal
+} // namespace qbs
+
class TestBlackboxApple : public TestBlackboxBase
{
Q_OBJECT
@@ -56,6 +62,10 @@ private slots:
void infoPlist();
void objcArc();
void xcode();
+
+private:
+ QVariantMap findXcode(int *status = nullptr);
+ qbs::Internal::Version findXcodeVersion();
};
#endif // TST_BLACKBOXAPPLE_H