Skip to content

Stray console.log in QML not caught by CI (fails strict-mode UI tests locally) #14526

Description

@DonLakeFlyer

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

  1. Ensure the QML Integration/UI tests run in CI in the same strict-log configuration as local runs, so stray console.log is caught.
  2. Optionally add a lint/pre-commit check that flags console.log( in src/**/*.qml.
  3. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions