Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行和记录文档测试情况 #10

Open
zjp-CN opened this issue Nov 20, 2024 · 0 comments
Open

运行和记录文档测试情况 #10

zjp-CN opened this issue Nov 20, 2024 · 0 comments

Comments

@zjp-CN
Copy link
Member

zjp-CN commented Nov 20, 2024

目前测试信息不含文档测试,运行它们只需要 cargo test --doc 命令,但解析它们需要额外的技巧,或许可以参考我之前写的解析测试输出的正则表达式:

https://github.com/josecelano/cargo-pretty-test/blob/23e7a940f1e3c4a778f0ed1aebb67a31b5a85c70/src/regex.rs#L30


轶事 1:Rust For Linux 手动把文档测试抽取成单元测试文件

由于没有直接的方式获取 doc tests 信息,RFL 利用 rustdoc 不稳定的命令行参数手动解析和抽取出文档测试,写入到额外的测试文件。
https://rust-lang.zulipchat.com/#narrow/channel/425075-rust-for-linux/topic/what's.20the.20rustdoc.20hack.3F

/// `rustdoc` generated `file`s look like `sync_locked_by_rs`. Underscores (except the last one)
/// may represent an actual underscore in a directory/file, or a path separator. Thus the actual
/// file might be `sync_locked_by.rs`, `sync/locked_by.rs`, `sync_locked/by.rs` or
/// `sync/locked/by.rs`. This function walks the file system to determine which is the real one.
///
/// This does require that ambiguities do not exist, but that seems fair, especially since this is
/// all supposed to be temporary until `rustdoc` gives us proper metadata to build this. If such
/// ambiguities are detected, they are diagnosed and the script panics.

轶事 2:文档测试的奇怪运行方式甚至不被 nextest 支持 nextest-rs/nextest#16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant