Repository navigation
test: isolate PerformanceMonitor UT from runner log rules - #752
Conversation
1. UT task task-1b84a8cf failed 4 PerformanceMonitorTest cases: all logsContain() assertions false and timeCalls short by 2 2. Root cause: runner script now exports QT_LOGGING_RULES="*.debug=false;*.info=false" (upstream cc549b5, added to stay under the 256MB platform log cap); this short-circuits qCDebug/qCInfo(appLog), so messages never reach the test's capture handler and QDateTime::currentDateTime() calls inside the stream expressions no longer execute 3. Fixture now force-enables org.deepin.editor debug/info via QLoggingCategory::setFilterRules (which overrides the env rules) in SetUp, and restores the ambient QT_LOGGING_RULES in TearDown; the runner's log cap for all other suites is untouched Log: No user-facing changes Influence: 1. Run tests/test-prj-running.sh on the AT/UT cluster and verify the four PerformanceMonitorTest cases pass with the log cap in place 2. Check the UT log stays well below the 256MB platform limit 3. Confirm no Qt debug/info leakage from later suites in test_common2 after the fixture restores ambient rules test: 隔离 PerformanceMonitor UT 与运行脚本的日志规则 1. UT 任务 task-1b84a8cf 中 PerformanceMonitorTest 4 个用例失败: logsContain() 断言全为 false 且 timeCalls 少 2 次 2. 根因:运行脚本新增导出 QT_LOGGING_RULES="*.debug=false;*.info=false" (上游 cc549b5,为避免超出平台 256MB 日志上限),该规则使 qCDebug/qCInfo(appLog) 整体短路:消息到不了测试的捕获 handler, 流表达式内的 QDateTime::currentDateTime() 调用也不再执行 3. 夹具 SetUp 用 QLoggingCategory::setFilterRules(优先级高于环境 变量)显式放开 org.deepin.editor 的 debug/info,TearDown 恢复 环境原有 QT_LOGGING_RULES;运行脚本对其他套件的日志限流不受影响 Log: 无用户可见变化 Influence: 1. 在 AT/UT 集群跑 tests/test-prj-running.sh,验证日志限流在位时 PerformanceMonitorTest 四个用例全部通过 2. 检查 UT 日志总量仍远低于平台 256MB 上限 3. 确认夹具恢复环境规则后 test_common2 后续套件无 debug/info 泄漏 PMS: TASK-398635
Reviewer's GuideTestsMake the PerformanceMonitor test fixture temporarily enable its logging categories and restore the environment’s rules afterward, so logging assertions remain deterministic under runner-wide log filters.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/common2/test_performancemonitor.cpp" line_range="76" />
<code_context>
+ // setFilterRules 优先级高于环境变量,夹具内显式放开 appLog,保证用例
+ // 不随运行环境的日志配置漂移;TearDown 恢复原规则。
+ QLoggingCategory::setFilterRules(QStringLiteral(
+ "org.deepin.editor.debug=true\norg.deepin.editor.info=true"));
stub.clear();
logs.clear();
</code_context>
<issue_to_address>
**Unrelated logs reach the platform cap**
When an unrelated category emits debug or info messages while a PerformanceMonitor test runs, `setFilterRules` replaces the runner’s rules and drops its `*.debug=false` and `*.info=false` filters, so other categories use Qt’s enabled defaults and their messages reach the test log, potentially hitting the platform cap.
Preserve the runner’s filters when adding the `org.deepin.editor` overrides.
</issue_to_address>
### Comment 2
<location path="tests/common2/test_performancemonitor.cpp" line_range="95" />
<code_context>
{
+ // 先恢复运行环境自带的日志规则(无则清空回到进程默认),再恢复默认
+ // handler,避免中间窗口 debug/info 直接打到 stderr
+ QLoggingCategory::setFilterRules(QString::fromLatin1(qgetenv("QT_LOGGING_RULES")));
qInstallMessageHandler(nullptr); // 恢复默认 handler
g_capturedLogs = nullptr;
</code_context>
<issue_to_address>
**Runner log filters are not restored**
When the runner provides multiple logging rules separated by semicolons, `QLoggingCategory::setFilterRules` receives the runner’s semicolon-separated `QT_LOGGING_RULES` value as-is; the rules are not restored as separate filters, so later tests run without the debug/info suppression and emit excess logs.
Convert semicolons to newlines before passing the saved environment value to `setFilterRules`.
</issue_to_address>| // setFilterRules 优先级高于环境变量,夹具内显式放开 appLog,保证用例 | ||
| // 不随运行环境的日志配置漂移;TearDown 恢复原规则。 | ||
| QLoggingCategory::setFilterRules(QStringLiteral( | ||
| "org.deepin.editor.debug=true\norg.deepin.editor.info=true")); |
There was a problem hiding this comment.
🟡 Medium · Unrelated logs reach the platform cap
When an unrelated category emits debug or info messages while a PerformanceMonitor test runs, setFilterRules replaces the runner’s rules and drops its *.debug=false and *.info=false filters, so other categories use Qt’s enabled defaults and their messages reach the test log, potentially hitting the platform cap.
Preserve the runner’s filters when adding the org.deepin.editor overrides.
Prompt for AI agents
In `tests/common2/test_performancemonitor.cpp` at line 76:
**Unrelated logs reach the platform cap**
When an unrelated category emits debug or info messages while a PerformanceMonitor test runs, `setFilterRules` replaces the runner’s rules and drops its `*.debug=false` and `*.info=false` filters, so other categories use Qt’s enabled defaults and their messages reach the test log, potentially hitting the platform cap.
Preserve the runner’s filters when adding the `org.deepin.editor` overrides.| { | ||
| // 先恢复运行环境自带的日志规则(无则清空回到进程默认),再恢复默认 | ||
| // handler,避免中间窗口 debug/info 直接打到 stderr | ||
| QLoggingCategory::setFilterRules(QString::fromLatin1(qgetenv("QT_LOGGING_RULES"))); |
There was a problem hiding this comment.
🟡 Medium · Runner log filters are not restored
When the runner provides multiple logging rules separated by semicolons, QLoggingCategory::setFilterRules receives the runner’s semicolon-separated QT_LOGGING_RULES value as-is; the rules are not restored as separate filters, so later tests run without the debug/info suppression and emit excess logs.
Convert semicolons to newlines before passing the saved environment value to setFilterRules.
Prompt for AI agents
In `tests/common2/test_performancemonitor.cpp` at line 95:
**Runner log filters are not restored**
When the runner provides multiple logging rules separated by semicolons, `QLoggingCategory::setFilterRules` receives the runner’s semicolon-separated `QT_LOGGING_RULES` value as-is; the rules are not restored as separate filters, so later tests run without the debug/info suppression and emit excess logs.
Convert semicolons to newlines before passing the saved environment value to `setFilterRules`.|
TAG Bot New tag: 6.6.11 |
|
TAG Bot New tag: 6.6.12 |
|
TAG Bot New tag: 6.6.13 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Log: No user-facing changes
PMS: TASK-398635
UT 验证任务:http://10.8.12.70:18780/task?task_id=task-857329ea212e45faa79df1c122ea9f08
Summary by Sourcery
Ensure PerformanceMonitor tests remain deterministic without changing logging behavior for other test suites.
Bug Fixes:
Enhancements:
Tests: