Summary
Stray console.log() statements in QML are not caught by CI, so they accumulate in the codebase unnoticed. They only surface later as failures when someone runs the strict-mode QML UI tests locally, because those tests treat any unexpected log message (including QML qml-category debug output) as a test failure.
Concrete example
While running the full UI test suite locally, APMSensorsCalibrationUITest failed with:
FAIL! : APMSensorsCalibrationUITest::_testCompassCalibration() Unexpected log messages (strict mode):
Loc: [../test/UnitTestFramework/UnitTest.cc(878)]
The unexpected messages were stray QML debug logs:
QDEBUG : APMSensorsCalibrationUITest::_testCompassCalibration() comparing 97539 with 97539 (index 0) - qml - (selectPriorityfromParams:389)
The source was a debug console.log in selectPriorityfromParams():
for (let prioIndex=0; prioIndex<3; prioIndex++) {
console.log(`comparing ${compassId} with ${sensorParams.rgCompassPrio[prioIndex].rawValue} (index ${prioIndex})`)
if (compassId == sensorParams.rgCompassPrio[prioIndex].rawValue) {
...
This line lived in src/AutoPilotPlugins/APM/APMSensorsComponent.qml and had been present since commit a2f0d7a14c (Dec 2021) — roughly 4 years — without ever failing CI.
Why CI doesn't catch it
The strict log-message check in UnitTest.cc (Unexpected log messages (strict mode)) fails a test on any non-ignored captured message, including the qml logging category that console.log feeds into. However, the QML Integration/UI tests that exercise this code (e.g. APMSensorsCalibrationUITest, PX4AirframeSetupUITest, the new AppCloseWarningUITest) either are not run in the standard CI test job or are run in an environment where the QML debug output is not captured the same way as locally. As a result, a console.log that would fail a local UI-test run passes CI.
This is the second such instance found recently — a similar stray console.log was just removed from src/AutoPilotPlugins/PX4/AirframeComponent.qml.
Impact
- Debug logging silently accumulates in shipped QML.
- Local UI-test runs fail for contributors with no change of their own, making the failures confusing to diagnose.
- The protection the strict log check is supposed to provide is effectively bypassed for QML output in CI.
Suggested follow-up
- Ensure the QML Integration/UI tests run in CI in the same strict-log configuration as local runs, so stray
console.log is caught.
- Optionally add a lint/pre-commit check that flags
console.log( in src/**/*.qml.
- Audit existing QML for remaining stray
console.log statements.
Workaround applied
The two known stray console.log lines (APMSensorsComponent.qml and AirframeComponent.qml) have been removed so the affected UI tests pass locally.
Summary
Stray
console.log()statements in QML are not caught by CI, so they accumulate in the codebase unnoticed. They only surface later as failures when someone runs the strict-mode QML UI tests locally, because those tests treat any unexpected log message (including QMLqml-category debug output) as a test failure.Concrete example
While running the full UI test suite locally,
APMSensorsCalibrationUITestfailed with:The unexpected messages were stray QML debug logs:
The source was a debug
console.loginselectPriorityfromParams():This line lived in
src/AutoPilotPlugins/APM/APMSensorsComponent.qmland had been present since commita2f0d7a14c(Dec 2021) — roughly 4 years — without ever failing CI.Why CI doesn't catch it
The strict log-message check in
UnitTest.cc(Unexpected log messages (strict mode)) fails a test on any non-ignored captured message, including theqmllogging category thatconsole.logfeeds into. However, the QML Integration/UI tests that exercise this code (e.g.APMSensorsCalibrationUITest,PX4AirframeSetupUITest, the newAppCloseWarningUITest) either are not run in the standard CI test job or are run in an environment where the QML debug output is not captured the same way as locally. As a result, aconsole.logthat would fail a local UI-test run passes CI.This is the second such instance found recently — a similar stray
console.logwas just removed fromsrc/AutoPilotPlugins/PX4/AirframeComponent.qml.Impact
Suggested follow-up
console.logis caught.console.log(insrc/**/*.qml.console.logstatements.Workaround applied
The two known stray
console.loglines (APMSensorsComponent.qml and AirframeComponent.qml) have been removed so the affected UI tests pass locally.