aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2016-08-24 17:34:53 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2016-10-06 15:10:09 +0000
commit2c75537141283895da9b80e249b391bc38d63505 (patch)
tree02c826f75b808de3a532df3d53e006ecb42115a6 /tests
parentd5c52a0b517505d10a090dd47dc04f9a09ca5c2a (diff)
Do not auto-convert values to property types
The JavaScript-style conversions are often unexpected and mask user errors. They also make a mockery of our type system. The exceptions are as follows: - Boolean properties are still auto-converted according to the JS rules, because otherwise user code would get tedious to write. - Lists of strings can still be assigned a single string, so the convenience pattern "files: 'main.cpp'" still works. This patch also fixes some bugs in our own modules that were uncovered by the change. [ChangeLog] Added stricter type checking for properties. Task-number: QBS-1013 Change-Id: I282c23eca3b3877c5551a49ef5c6dd8da91488fe Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/blackbox/testdata/invalid-library-names/invalid-library-names.qbs6
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp32
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
3 files changed, 30 insertions, 9 deletions
diff --git a/tests/auto/blackbox/testdata/invalid-library-names/invalid-library-names.qbs b/tests/auto/blackbox/testdata/invalid-library-names/invalid-library-names.qbs
index 4d43ad2b9..1ddfecd38 100644
--- a/tests/auto/blackbox/testdata/invalid-library-names/invalid-library-names.qbs
+++ b/tests/auto/blackbox/testdata/invalid-library-names/invalid-library-names.qbs
@@ -2,9 +2,11 @@ import qbs
Project {
minimumQbsVersion: "1.6"
+ property var values: [null, undefined, 5, [], ""]
+ property int valueIndex
CppApplication {
- cpp.dynamicLibraries: [undefined, ""]
- cpp.staticLibraries: [null, []]
+ cpp.dynamicLibraries: [project.values[project.valueIndex]]
+ cpp.staticLibraries: [project.values[project.valueIndex]]
files: ["main.cpp"]
}
}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index b1ad35771..8572ecc36 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -2481,13 +2481,31 @@ void TestBlackbox::invalidCommandProperty()
void TestBlackbox::invalidLibraryNames()
{
QDir::setCurrent(testDataDir + "/invalid-library-names");
- QCOMPARE(runQbs(), 0);
- qDebug() << m_qbsStderr;
- QCOMPARE(m_qbsStderr.count("WARNING"), 4);
- QCOMPARE(m_qbsStderr.count("WARNING: Removing empty string from value of property "
- "'cpp.dynamicLibraries' in product 'invalid-library-names'."), 2);
- QCOMPARE(m_qbsStderr.count("WARNING: Removing empty string from value of property "
- "'cpp.staticLibraries' in product 'invalid-library-names'."), 2);
+ QFETCH(QString, index);
+ QFETCH(bool, success);
+ QFETCH(QStringList, diagnostics);
+ QbsRunParameters params(QStringList("project.valueIndex:" + index));
+ params.expectFailure = !success;
+ QCOMPARE(runQbs(params) == 0, success);
+ foreach (const QString &diag, diagnostics)
+ QVERIFY2(m_qbsStderr.contains(diag.toLocal8Bit()), m_qbsStderr.constData());
+}
+
+void TestBlackbox::invalidLibraryNames_data()
+{
+ QTest::addColumn<QString>("index");
+ QTest::addColumn<bool>("success");
+ QTest::addColumn<QStringList>("diagnostics");
+
+ QTest::newRow("null") << "0" << false << QStringList("is null");
+ QTest::newRow("undefined") << "1" << false << QStringList("is undefined");
+ QTest::newRow("number") << "2" << false << QStringList("does not have string type");
+ QTest::newRow("array") << "3" << false << QStringList("does not have string type");
+ QTest::newRow("empty string") << "4" << true << (QStringList()
+ << "WARNING: Removing empty string from value of property "
+ "'cpp.dynamicLibraries' in product 'invalid-library-names'."
+ << "WARNING: Removing empty string from value of property "
+ "'cpp.staticLibraries' in product 'invalid-library-names'.");
}
void TestBlackbox::invalidExtensionInstantiation()
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index cde842552..69ffc5341 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -96,6 +96,7 @@ private slots:
void invalidExtensionInstantiation();
void invalidExtensionInstantiation_data();
void invalidLibraryNames();
+ void invalidLibraryNames_data();
void jsExtensionsFile();
void jsExtensionsFileInfo();
void jsExtensionsProcess();