如何在rustc bootstrap构建测试中跳过/禁用单元测试?
Rustc Bootstrap测试失败排查与临时解决方案
问题场景
执行rustc bootstrap测试命令:
python3 src/bootstrap/bootstrap.py test --exclude "some excluded test cases list" --no-fail-fast --bless --target x86_64-poky-linux-gnu
出现测试失败,报错信息如下:
Running unittests src/lib.rs (/home/build-st/tmp/work/core2-64-poky-linux/rust/1.77.0/rustc-1.77.0-src/build /bootstrap/debug/deps/bootstrap-fca753a60bf3f353) uploaded "/home/build-st/tmp/work/core2-64-poky-linux/rust/1.77.0/rustc-1.77.0-src/build/bootstrap/debug/deps/bootstrap-fca753a60bf3f353", waiting for result thread 'main' panicked at src/tools/remote-test-client/src/main.rs:310:9: client.read_exact(&mut header) failed with failed to fill whole buffer note: run with RUST_BACKTRACE=1 environment variable to display a backtrace error: test failed, to rerun pass --lib error: test failed, to rerun pass --bin bootstrap error: test failed, to rerun pass --bin rustc error: test failed, to rerun pass --bin rustdoc error: test failed, to rerun pass --bin sccache-plus-cl error: 5 targets failed: --lib --bin bootstrap --bin rustc --bin rustdoc --bin sccache-plus-cl
此前在Rust 1.75版本中,使用--doc参数可跳过单元测试,但1.76版本后该参数在跨目标环境下无法运行任何测试(单元测试和集成测试),取消该参数后出现大量单元测试失败。
失败原因
报错中的client.read_exact(&mut header) failed with failed to fill whole buffer,是远程测试客户端与测试服务端通信时的异常:客户端尝试读取完整响应头,但未获取到足够数据。
大概率是跨目标测试环境中,远程测试的网络链路不稳定、测试服务端提前退出,或者目标环境资源不足导致测试进程异常中断,最终引发通信失败。
临时解决方案:禁用所有单元测试
无需逐个修改代码添加#[ignore]属性,可直接在bootstrap命令中添加--no-unit-tests参数,跳过所有单元测试,仅运行集成测试:
python3 src/bootstrap/bootstrap.py test --exclude "some excluded test cases list" --no-fail-fast --bless --target x86_64-poky-linux-gnu --no-unit-tests
如果需要彻底跳过所有测试直接完成构建,可将test命令替换为build命令:
python3 src/bootstrap/bootstrap.py build --target x86_64-poky-linux-gnu
内容的提问来源于stack exchange,提问作者Yashinde
相关产品推荐
相关产品推荐

