本月测试基础设施动态:2024 年 11 月

2024 年 12 月 9 日 · 徐杰佑 代表 Bootstrap 团队

本月测试基础设施动态:2024 年 11 月

这是 **2024 年 11 月** rust-lang/rust 仓库1 测试基础设施变化的快速总结。它还包含正在进行工作的简要描述。

像往常一样,如果您在使用我们的测试基础设施时遇到 bug 或用户体验问题,请提交 issue。如果我们不知道 bug 和小问题,它们就无法得到修复!

感谢所有为我们的测试基础设施做出贡献的人!

亮点

compiletest:添加 proc-macro 辅助构建指令

@ehuss 添加了一个 //@ proc-macro 指令,其行为类似于 //@ aux-build,但它包含了 proc-macro 辅助功能之前所需的常规 //@ force-host//@ no-prefer-dynamic 样板代码。如果主测试文件也使用了足够新的版本(例如 2018 版本及以后),则 proc-macro 辅助功能也可以通过 extern prelude 使用。

之前:测试编写者需要为每一个 proc-macro 辅助功能编写 //@ force-host//@ no-prefer-dynamic

// tests/ui/foo/my-main-test.rs
//@ aux-build: my-proc-macro.rs
// tests/ui/foo/auxiliary/my-proc-macro.rs
//@ no-prefer-dynamic
//@ force-host

之后:主测试文件中只需要 //@ proc-macro 指令。

// tests/ui/foo/my-main-test.rs
//@ proc-macro: my-proc-macro.rs
// tests/ui/foo/auxiliary/my-proc-macro.rs

谢谢 Eric!

rustc:当 RUSTC_BOOTSTRAP=-1 设置时,让 rustc 认为自己是稳定版编译器

#132993 中,我修改了 rustc 的稳定性检查逻辑,使其现在也能识别 RUSTC_BOOTSTRAP=-1,以强制任何 rustc 认为自己是稳定版编译器,无论它来自哪个通道(例如 beta、dev、nightly 或 stable)2。这对于在 nightly 和 stable 版本之间有所不同的诊断信息很有用,也提供了一种使被测试的 rustc 表现得如同稳定版编译器一样的方式。

在测试中,//@ rustc-env 指令可以与 RUSTC_BOOTSTRAP=-1 一起使用3

//@ rustc-env:RUSTC_BOOTSTRAP=-1
//@ compile-flags: -Z unstable-options
//@ regex-error-pattern: error: the option `Z` is only accepted on the nightly compiler
// This will fail because the `rustc` under test rejects the `-Z unstable-options` unstable flag.

PR 列表

改进

清理

文档更新

正在进行的努力

注意:当然还有许多自发性的努力,这里列出的是我所知的“计划内”的。