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

2024 年 12 月 9 日 · Jieyou Xu 代表 Bootstrap 团队

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

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

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

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

亮点

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

@ehuss 添加了一个 //@ proc-macro 指令,其行为类似于 //@ aux-build,但它打包了之前 proc-macro 辅助工具所需的常用 //@ force-host//@ no-prefer-dynamic 样板代码。 如果主测试文件也使用足够新的版本(即 2018 版或更高版本),则 proc-macro 辅助工具也可通过外部 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 列表

改进

清理

文档更新

正在进行的工作

注意:肯定还有更多自发的努力,这更像是我知道的“计划”。

  1. 此处的测试基础设施是指测试工具 compiletest 和我们在构建系统 bootstrap 中的支持组件。 此测试基础设施主要由 rustc 和 rustdoc 使用。 其他工具(如 cargo、miri 或 rustfmt)维护自己的测试基础设施。

  2. 用于内部测试用途。 其他任何依赖于此而发生故障的情况都将被视为 PEBKAC。

  3. //@ rustc-env 指令处理存在一个错误,即它在冒号和值之间对空格敏感,因此目前请避免使用空格。