aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/blackbox/tst_blackbox.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2022-09-22 17:14:55 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2022-10-04 07:43:01 +0000
commita29bbf5568bf651b076f051720a98e9d0297faa9 (patch)
tree5d99c12c7d9735e7f113c3a04ccf95746ef8dedc /tests/auto/blackbox/tst_blackbox.cpp
parent512001849af89e4b2c5bfb18b039387d6fe7aaa6 (diff)
Make handling of deprecated items and properties configurable
As of now, a newly deprecated property leads to users getting bombarded with warnings, even though they did not yet have a chance to adapt their project. Now the warnings appear by default one minor version before removal, which together with our convention of keeping deprecated properties for at least two minor versions gives users enough time to adapt without getting spammed. There is also a mode for switching to the previous behavior (for early detection), as well as the possibility to trigger errors instead of warnings, which should be helpful in CI configurations. To support the case where the user cannot do anything about them, the warnings can also be suppressed altogether. Change-Id: I295f816758f0f111fcb0351581a4328be3af5668 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Diffstat (limited to 'tests/auto/blackbox/tst_blackbox.cpp')
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp61
1 files changed, 54 insertions, 7 deletions
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 679972d37..8bc905929 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -53,6 +53,7 @@
#include <QtCore/qsettings.h>
#include <QtCore/qtemporarydir.h>
#include <QtCore/qtemporaryfile.h>
+#include <QtCore/qversionnumber.h>
#include <algorithm>
#include <functional>
@@ -1055,22 +1056,68 @@ void TestBlackbox::dependencyScanningLoop()
void TestBlackbox::deprecatedProperty()
{
+ QFETCH(QString, version);
+ QFETCH(QString, mode);
+ QFETCH(bool, expiringWarning);
+ QFETCH(bool, expiringError);
+
QDir::setCurrent(testDataDir + "/deprecated-property");
QbsRunParameters params(QStringList("-q"));
params.expectFailure = true;
+ params.environment.insert("REMOVAL_VERSION", version);
+ if (!mode.isEmpty())
+ params.arguments << "--deprecation-warnings" << mode;
QVERIFY(runQbs(params) != 0);
m_qbsStderr = QDir::fromNativeSeparators(QString::fromLocal8Bit(m_qbsStderr)).toLocal8Bit();
- QVERIFY2(m_qbsStderr.contains("deprecated-property.qbs:6:24 The property 'oldProp' is "
- "deprecated and will be removed in Qbs 99.9.0."), m_qbsStderr.constData());
- QVERIFY2(m_qbsStderr.contains("deprecated-property.qbs:7:28 The property 'veryOldProp' can no "
- "longer be used. It was removed in Qbs 1.3.0."), m_qbsStderr.constData());
+ const bool hasExpiringWarning = m_qbsStderr.contains(QByteArray(
+ "deprecated-property.qbs:6:29 The property 'expiringProp' is "
+ "deprecated and will be removed in Qbs ") + version.toLocal8Bit());
+ QVERIFY2(expiringWarning == hasExpiringWarning, m_qbsStderr.constData());
+ const bool hasRemovedOutput = m_qbsStderr.contains(
+ "deprecated-property.qbs:7:28 The property 'veryOldProp' can no "
+ "longer be used. It was removed in Qbs 1.3.0.");
+ QVERIFY2(hasRemovedOutput == !expiringError, m_qbsStderr.constData());
QVERIFY2(m_qbsStderr.contains("Property 'forgottenProp' was scheduled for removal in version "
"1.8.0, but is still present."), m_qbsStderr.constData());
QVERIFY2(m_qbsStderr.contains("themodule/m.qbs:22:5 Removal version for 'forgottenProp' "
"specified here."), m_qbsStderr.constData());
- QVERIFY2(m_qbsStderr.count("Use newProp instead.") == 2, m_qbsStderr.constData());
- QVERIFY2(m_qbsStderr.count("is deprecated") == 1, m_qbsStderr.constData());
- QVERIFY2(m_qbsStderr.count("was removed") == 1, m_qbsStderr.constData());
+ QVERIFY2(m_qbsStderr.count("Use newProp instead.") == 1
+ + int(expiringWarning && !expiringError), m_qbsStderr.constData());
+ QVERIFY2(m_qbsStderr.count("is deprecated") == int(expiringWarning), m_qbsStderr.constData());
+ QVERIFY2(m_qbsStderr.count("was removed") == int(!expiringError), m_qbsStderr.constData());
+}
+
+void TestBlackbox::deprecatedProperty_data()
+{
+ QTest::addColumn<QString>("version");
+ QTest::addColumn<QString>("mode");
+ QTest::addColumn<bool>("expiringWarning");
+ QTest::addColumn<bool>("expiringError");
+
+ const auto current = QVersionNumber::fromString(QBS_VERSION);
+ const QString next = QVersionNumber(current.majorVersion(), current.minorVersion() + 1)
+ .toString();
+ const QString nextNext = QVersionNumber(current.majorVersion(), current.minorVersion() + 2)
+ .toString();
+ const QString nextMajor = QVersionNumber(current.majorVersion() + 1).toString();
+
+ QTest::newRow("default/next") << next << QString() << true << false;
+ QTest::newRow("default/nextnext") << nextNext << QString() << false << false;
+ QTest::newRow("default/nextmajor") << nextMajor << QString() << true << false;
+ QTest::newRow("error/next") << next << QString("error") << true << true;
+ QTest::newRow("error/nextnext") << nextNext << QString("error") << true << true;
+ QTest::newRow("error/nextmajor") << nextMajor << QString("error") << true << true;
+ QTest::newRow("on/next") << next << QString("on") << true << false;
+ QTest::newRow("on/nextnext") << nextNext << QString("on") << true << false;
+ QTest::newRow("on/nextmajor") << nextMajor << QString("on") << true << false;
+ QTest::newRow("before-removal/next") << next << QString("before-removal") << true << false;
+ QTest::newRow("before-removal/nextnext") << nextNext << QString("before-removal")
+ << false << false;
+ QTest::newRow("before-removal/nextmajor") << nextMajor << QString("before-removal")
+ << true << false;
+ QTest::newRow("off/next") << next << QString("off") << false << false;
+ QTest::newRow("off/nextnext") << nextNext << QString("off") << false << false;
+ QTest::newRow("off/nextmajor") << nextMajor << QString("off") << false << false;
}
void TestBlackbox::disappearedProfile()