feat(cargo): support test target artifacts#149
Open
ZR233 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
审查总结
本次 PR 为 Cargo 构建系统新增了 test 目标选择功能,支持通过 [[test]] 构建 harness = false 的可执行测试产物。
变更概览
- 在
Cargo配置结构体中新增test字段,与bin互斥 - CLI 层面通过 clap
conflicts_with属性保证互斥,运行时在build_cargo_plan中再次校验 --test传递给 Cargo 构建命令,artifact selector 支持 test 目标选择- JSON message 解析器通过
is_executable_target_kind同时接受Bin和Test类型 - 将
BuildSystem::Cargo装箱以避免 clippy 大枚举变体警告 - README/README.en 文档已同步更新
- 新增了完整的单元测试覆盖
代码质量
整体质量很好,实现方式与现有 bin 的模式保持一致,互斥逻辑在三个层面(CLI clap、运行时 bail、selector 覆盖)都有保障。测试覆盖全面,包括正常路径和错误路径。
小建议(非阻塞)
artifact_selector.rs 中当存在多个可执行 artifact 且未指定选择器时,错误信息仅提示 pass system.Cargo.bin or --bin,但此时如果同时存在 bin 和 test 目标,建议也提及 --test / system.Cargo.test 选项。这不影响功能,只是一个体验改进点。
验证结果
cargo clippy -p ostool -- -D warnings✅ 通过cargo test -p ostool✅ 204 通过,5 个失败均为环境中缺少llvm-tools组件导致,与本次 PR 无关
结论:批准合并。
Powered by mimo-v2.5-pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
TGOSKits 的内核/QEMU 测试需要通过 Cargo
[[test]]目标构建harness = false的可执行测试产物,但 ostool 当前只能选择 Cargo bin artifact,无法用--test <target>指定 test target。修改
system.Cargo和命令行 selector 增加test目标选择,和bin保持互斥。--test <name>,并从 JSON message 中同时接受 bin/test executable artifact。--test与system.Cargo.test用法。BuildSystem::Cargo装箱,避免新增字段后触发 large enum variant clippy。验证
cargo test -p ostoolcargo clippy -p ostool -- -D warningscargo test -p axbuild ktest -- --nocapturecargo xtask clippy --package axbuildcargo xtask ktest qemu -p starry-kernel --test axtest_kernel --arch x86_64 --coveragecargo xtask ktest qemu -p axvisor --test axtest --arch x86_64