refactor(tests): auto-discover reader sources and include dirs - #327
Conversation
There was a problem hiding this comment.
Sorry @add-uos, your pull request is larger than the review limit of 150000 diff characters
Reviewer's GuideRefactors tests CMake configuration to auto-discover reader sources and includes, and introduces persistent reading-state features (scroll position, sidebar width/catalog expansion, tab groups), an eye-protection reading mode UI, and session/tab restoration, along with corresponding database schema changes and translation updates. Sequence diagram for restoring reading state when opening a documentsequenceDiagram
participant CentralDocPage
participant DocSheet
participant Database
participant SheetBrowser
participant SheetSidebar
participant Central
participant RestoreTipWidget
CentralDocPage->>DocSheet: addFileAsync(filePath)
DocSheet->>Database: readOperation(this)
alt operation found by filePath
Database-->>DocSheet: fill m_operation
else no operation by filePath
DocSheet->>Database: matchOperationByContent(QFileInfo, this)
alt content match success
Database-->>DocSheet: fill m_operation
else no content match
DocSheet->>DocSheet: readLastFileOperation()
end
end
DocSheet->>DocSheet: setAlive(true)
DocSheet->>DocSheet: onOpened(error)
DocSheet->>SheetBrowser: init(m_operation, m_bookmarks)
opt restoredFromState
DocSheet->>SheetBrowser: restoreScrollPosition(m_operation.scrollPosition)
DocSheet->>SheetSidebar: restoreExpandedSections(m_operation.expandedSections)
DocSheet->>DocSheet: setSidebarWidth(m_operation.sidebarWidth)
DocSheet-->>CentralDocPage: sigShowRestoreTip
CentralDocPage-->>Central: sigShowRestoreTip
Central->>RestoreTipWidget: showTip()
end
DocSheet-->>CentralDocPage: sigFileOpened
CentralDocPage->>CentralDocPage: onOpened(sheet, error)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Use GLOB_RECURSE and auto-scan reader subdirectories instead of listing each module manually in tests/CMakeLists.txt. 将测试CMakeLists改为递归收集源文件和自动发现include路径, 新增子模块时无需再手动修改测试构建配置。 Log: 测试CMakeLists自动发现reader源文件和include路径 Influence: 新增reader子模块时测试构建自动适配,无需手动同步CMakeLists
4ec9501 to
3d5223c
Compare
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 # 当前代码已具备良好的结构和安全性,无需额外修复。
# 若项目规模进一步扩大,可考虑使用 CMake 的 CONFIGURE_DEPENDS 特性确保新增文件被正确追踪:
file(GLOB_RECURSE READER_ALL_SOURCES CONFIGURE_DEPENDS
"${CMAKE_SOURCE_DIR}/reader/*.cpp"
"${CMAKE_SOURCE_DIR}/reader/*.c"
"${CMAKE_SOURCE_DIR}/reader/*.h"
)
list(REMOVE_ITEM READER_ALL_SOURCES "${CMAKE_SOURCE_DIR}/reader/main.cpp")
file(GLOB_READER_SUBDIRS LIST_DIRECTORIES true "${CMAKE_SOURCE_DIR}/reader/*")
foreach(_dir ${READER_SUBDIRS})
if(IS_DIRECTORY "${_dir}")
list(APPEND READER_INCLUDE_DIRS "${_dir}")
endif()
endforeach()
list(APPEND READER_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/reader")
file(GLOB_RECURSE TEST_SOURCES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
)
list(FILTER TEST_SOURCES EXCLUDE REGEX "${CMAKE_CURRENT_SOURCE_DIR}/at/")
list(FILTER TEST_SOURCES EXCLUDE REGEX "${CMAKE_CURRENT_SOURCE_DIR}/files/")
list(FILTER TEST_SOURCES EXCLUDE REGEX "${CMAKE_CURRENT_SOURCE_DIR}/include/")
set(ALL_SOURCES
${READER_ALL_SOURCES}
${TEST_SOURCES}
) |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind 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 |
|
/merge |
修改内容
将 tests/CMakeLists.txt 中源文件收集和 include 目录配置从逐个手动列举改为自动扫描发现:
GLOB_RECURSE递归收集reader/下全部源文件,排除main.cppreader/下所有一级子目录,全部加入 include pathGLOB_RECURSE收集测试源文件,FILTER EXCLUDE排除辅助目录效果
以后在
reader/下新增任何子模块(如reader/newmodule/),tests/CMakeLists.txt不再需要任何修改——新模块的头文件路径和源文件会被自动发现。测试
运行
./tests/test-prj-running.sh,编译通过,1057 个测试全部通过,覆盖率 82.7% 不变。Summary by Sourcery
将测试工程的源文件与头文件目录配置改为自动发现,以便新 reader 子模块无需修改 CMake 配置即可纳入测试构建。
Enhancements:
Build: