本月测试基础设施更新:2024 年 12 月
新年快乐,亲爱的读者!这是 2024 年最后一期《本月测试基础设施更新》。
这是针对 rust-lang/rust 仓库测试基础设施在 2024 年 12 月 变更的快速总结1。
照例,如果您在使用我们的测试基础设施时遇到 bug 或用户体验问题,请提交 issue。如果我们不知道 bug 和小问题,就无法修复它们!
感谢所有为我们的测试基础设施做出贡献的人!
重点更新
rustc-dev-guide
现已成为 josh
子树!
以前,rustc-dev-guide 是 rust-lang/rust 内部的一个子模块,rustc-dev-guide 的更新必须在 rustc-dev-guide 仓库中通过单独的 PR 进行。
现在,感谢 @Kobzol 的努力(克服了许多不可预见的障碍),rustc-dev-guide
现在是 josh
子树。这对贡献工作流程来说是一个显著改进,因为它意味着 rustc-dev-guide 的文档更新可以与 rust-lang/rust 中的实现变更在同一个 PR 中一同进行。贡献摩擦的减少也鼓励了 rustc-dev-guide 的更新,因为您不再需要编写和维护两个独立的 PR。
compiletest 现在将显示不同行上标准化输出与实际输出之间的差异
以前,当 ui 测试失败时,很难分辨标准化之前的实际输出是什么,您必须使用 --nocapture
或类似的方法。
现在,compiletest 在失败时也会显示标准化之前不匹配的输出行,以便更容易分辨。 输出示例
failures:
---- [ui] tests/ui/layout/enum.rs stdout ----
diff of stderr:
- error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIGN }
+ error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIN }
2 --> $DIR/enum.rs:9:1
3 |
4 LL | enum UninhabitedVariantAlign {
Note: some mismatched output was normalized before being compared
- error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: Align(8 bytes) }
- --> /home/jyn/src/rust2/tests/ui/layout/enum.rs:9:1
+ error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIN }
compiletest 现在允许在运行 debuginfo 测试时使用特定调试器
长期以来,只有安装了所有被测试的调试器(即 lldb
、gdb
、cdb
),tests/debuginfo
测试套件才能成功运行。这在本地非常烦人,如果
- 这些调试器中的一个或多个在本地不可用或无法工作2。
- 您只想查看给定调试器的测试失败情况。
现在,您可以使用 特定 调试器运行 tests/debuginfo
测试套件,仅针对该指定调试器运行测试。 使用示例
ui
测试现在支持 //@ forbid-output
ui
测试现在可以使用 //@ forbid-output: REGEX
指令来检查 stderr 中不能出现的模式。如果 REGEX
模式匹配,则 ui
测试将失败。
更多详细信息请查阅 rustc-dev-guide。
./x test
现在接受一个 --no-capture
标志,该标志将转发给 compiletest(并因此转发给 libtest)
以前,如果您想通过 bootstrap、通过 compiletest 将 --nocapture
标志传递给底层的 libtest 运行器,在 Linux 上您必须写
在原生的 Windows msvc 上甚至更糟,我记得必须写
PS> ./x test tests/ui -- -- --nocapture
这很难发现,是贡献者的一个痛点3。
现在,您只需写
bootstrap 将把此标志作为 --nocapture
转发给底层的 libtest。
值得关注的变更
本节旨在成为类似“兼容性说明”的内容,但面向测试编写者。
FileCheck
的测试套件不再预定义 MSVC
和 NONMSVC
FileCheck
前缀
基于 在 当前 设置中,compiletest 将为每个 compiletest //@ revision
注册一个 FileCheck
自定义前缀。然而,由于历史原因,compiletest 还根据 主机 预定义了 MSVC
和 NONMSVC
FileCheck
前缀。但这令人非常意外,原因有二
- 这是“远距离幽灵行动”,因为用户从未声明过这些自定义前缀,并且这些前缀是根据主机有条件设置的。这也使得调试困难。
- 如果用户还想添加自己的
//@ revision: MSVC NONMSVC
revisions,因为 compiletest 会为这些名称两次传递--check-prefix
,这将导致FileCheck
报告关于重复前缀的错误。
因此,在 compiletest: don't register predefined MSVC
/NONMSVC
FileCheck
prefixes #134463 中,我们不再预定义这两个 FileCheck
前缀。
如果您想要以前的 MSVC
vs NONMSVC
行为,您需要明确写出
//@ revisions: MSVC NONMSVC
//@[MSVC] only-windows-msvc
//@[NONMSVC] ignore-windows-msvc
normalize-{stderr,stdout}-test
指令已重命名为 normalize-{stderr,stdout}
主要是清理工作,-test
后缀没有提供额外有用信息,只会让这两个 normalize-*
指令难以发现。
normalize-{stderr,stdout}-test
指令现已重命名为 normalize-{stderr,stdout}
。 normalize-{stderr,stdout}-{32,64}bit
指令不受影响。
FileCheck
后缀作为 revision 名称(对于基于 FileCheck
的测试套件)
compiletest 现在将拒绝使用内置 对于 FileCheck
-based test suites (assembly
, codegen
, mir-opt
),compiletest 将为每个 compiletest //@ revision
注册一个自定义 FileCheck
前缀。然而,FileCheck
也有一些 内置后缀,例如
// COM:
// CHECK:
// CHECK-NEXT:
// CHECK-SAME:
// CHECK-EMPTY:
// CHECK-NOT:
// CHECK-COUNT:
// CHECK-DAG:
// CHECK-LABEL:
组合时,这以前意味着 compiletest revision + 内置 FileCheck
后缀结构,例如
// next:
// same-SAME:
// not-NOT:
// next-NEXT:
// not-SAME:
被 compiletest 允许,这极其令人困惑。
因此,compiletest 现在将拒绝在基于 FileCheck
的测试套件中使用 CHECK
、COM
、NEXT
、SAME
、EMPTY
、NOT
、COUNT
、DAG
、LABEL
作为 revision 名称。
PR 列表
改进
- rustc-dev-guide: Turn
rustc-dev-guide
into ajosh
subtree #134907 - compiletest: Show the difference between the normalized output and the actual output for lines which didn't match #133733
- compiletest: Explain that UI tests are expected not to compile by default #133813
- compiletest: Allow using a specific debugger when running
debuginfo
tests #134629 - compiletest, run-make-support: Improve
compiletest
andrun-make-support
symlink handling - compiletest: Support
forbid-output
in UI tests #134738 - bootstrap: Add
--no-capture
/--nocapture
as bootstrap arguments #134809 - bootstrap: Allow
./x check compiletest
#134848 - compiletest: Deny usage of special
FileCheck
suffixes as revision names #134925 - tidy: Run Python formatting check in
tidy
on CI #134964 - tidy: Print how to rebless Python formatting in
tidy
#134968
修复
- compiletest: Fix
--nocapture
forrun-make
tests #134111 - compiletest: Remove empty 'expected' files when blessing #134808
- run-make: Fix
assert_stderr_not_contains_regex
#1341134
清理
- compiletest: Don't register predefined
MSVC
/NONMSVC
FileCheck
prefixes - compiletest: Remove the
-test
suffix fromnormalize-*
directives #134759 - compiletest: Only pass the post-colon value to
parse_normalize_rule
#134840 - compiletest: Slightly simplify the handling of debugger directive prefixes #134849
- bootstrap: Consolidate the macros for declaring compiletest test suites #134876
- tidy: Replace
black
withruff
intidy
#133821
文档更新
- Document how to run the split Docker pipelines #134894
- Document the
--dev
flag forsrc/ci/docker/run.sh
#134669 - rustc-dev-guide:
compiletest
: Document the--debugger
flag #2170 - rustc-dev-guide: Document
forbid-output
for UI tests #2171 - rustc-dev-guide: Remove the
-test
suffix from normalize directives #2172 - rustc-dev-guide: Document
x test --no-capture
#2174 - rustc-dev-guide: Describe how to use rust-analyzer with
rmake.rs
#2191