summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-04-14 15:13:28 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-04-18 21:09:43 +0000
commit47cc9e23a313d67a4a3107242f205d2473842021 (patch)
treefd07839558d94af9be04d7ede63c1af62eb9f480 /tests/auto/corelib/io
parent9595622e366fcbef6bcc3a2ee08597959e3e2bd2 (diff)
Initialize QLoggingRegistry rules on first use, not qApp construction
Allows categorized logging before QCoreApplication has been created, which otherwise would silently fail to output anything because the category would never be enabled, despite QT_LOGGING_RULES being set. Change-Id: Ia733105c5b6f28e22af511ced5271e45782da12b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
index 0a74dc64c0..c697cb2203 100644
--- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
+++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
@@ -197,9 +197,23 @@ private slots:
// Check whether QT_LOGGING_CONF is picked up from environment
//
- qputenv("QT_LOGGING_CONF", QFINDTESTDATA("qtlogging.ini").toLocal8Bit());
+ Q_ASSERT(!qApp);
+
+ qputenv("QT_LOGGING_RULES", "qt.foo.bar=true");
QLoggingRegistry registry;
+ QCOMPARE(registry.apiRules.size(), 0);
+ QCOMPARE(registry.configRules.size(), 0);
+ QCOMPARE(registry.envRules.size(), 1);
+ QCOMPARE(registry.rules.size(), 1);
+
+ QLoggingCategory qtEnabledByLoggingRule("qt.foo.bar");
+ QCOMPARE(qtEnabledByLoggingRule.isDebugEnabled(), true);
+ QLoggingCategory qtDisabledByDefault("qt.foo.baz");
+ QCOMPARE(qtDisabledByDefault.isDebugEnabled(), false);
+
+ qunsetenv("QT_LOGGING_RULES");
+ qputenv("QT_LOGGING_CONF", QFINDTESTDATA("qtlogging.ini").toLocal8Bit());
registry.init();
QCOMPARE(registry.apiRules.size(), 0);
@@ -304,6 +318,6 @@ private slots:
}
};
-QTEST_MAIN(tst_QLoggingRegistry)
+QTEST_APPLESS_MAIN(tst_QLoggingRegistry)
#include "tst_qloggingregistry.moc"