Skip to content

All unit tests should run in strict log mode #14484

@DonLakeFlyer

Description

@DonLakeFlyer

Currently UnitTest::_strictLogCheck defaults to false and only QmlUITestBase opts in via setStrictLogCheck(true). This means any unexpected qCWarning or qCDebug from production code that fires during a unit test is silently ignored.

All unit tests should run in strict mode so that unexpected log output (warnings, debug messages from any category) causes a test failure. This would catch regressions where code paths emit unexpected warnings during tests.

Change needed: Set _strictLogCheck = true by default in UnitTest, or call setStrictLogCheck(true) in UnitTest::init(). Tests that legitimately emit warnings would need to use expectLogMessage() to declare them.


Related: bare qDebug() in test code silently passes CI

Several test files contain bare qDebug() calls (uncategorized, category = "default"). These cause QFAIL locally in a Debug build because Qt's built-in filter enables the default category debug messages, which are then captured and flagged by cleanup().

However, they pass silently in CI because cmake/QGCTest.cmake sets the CTest ENVIRONMENT property:

set(_test_env "QT_LOGGING_RULES=*.debug=false")

This suppresses all debug-level messages — including the default category — before they reach the message handler, so captureIfEnabled() never sees them and cleanup() finds nothing to fail on.

This means the bare qDebug() hygiene check only works locally and is invisible in CI. The fix for the existing bare qDebug() calls has already been applied (replaced with qCDebug(UnitTestLog)), but the underlying asymmetry between local and CI behavior should be documented and understood when enabling strict mode globally.

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions