1
Fork 0

Use coverage-dump --demangle as the demangler for coverage-run tests

This avoids the need to build `rust-demangler` when running coverage tests,
since we typically need to build `coverage-dump` anyway.
This commit is contained in:
Zalathar 2024-05-30 16:21:42 +10:00
parent 9abfebdf1e
commit 10ffc228a8
2 changed files with 13 additions and 17 deletions

View file

@ -1781,7 +1781,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
.arg(builder.ensure(tool::JsonDocLint { compiler: json_compiler, target })); .arg(builder.ensure(tool::JsonDocLint { compiler: json_compiler, target }));
} }
if mode == "coverage-map" { if matches!(mode, "coverage-map" | "coverage-run") {
let coverage_dump = builder.ensure(tool::CoverageDump { let coverage_dump = builder.ensure(tool::CoverageDump {
compiler: compiler.with_stage(0), compiler: compiler.with_stage(0),
target: compiler.host, target: compiler.host,
@ -1789,17 +1789,6 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
cmd.arg("--coverage-dump-path").arg(coverage_dump); cmd.arg("--coverage-dump-path").arg(coverage_dump);
} }
if mode == "coverage-run" {
// The demangler doesn't need the current compiler, so we can avoid
// unnecessary rebuilds by using the bootstrap compiler instead.
let rust_demangler = builder.ensure(tool::RustDemangler {
compiler: compiler.with_stage(0),
target: compiler.host,
extra_features: Vec::new(),
});
cmd.arg("--rust-demangler-path").arg(rust_demangler);
}
cmd.arg("--src-base").arg(builder.src.join("tests").join(suite)); cmd.arg("--src-base").arg(builder.src.join("tests").join(suite));
cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite)); cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite));

View file

@ -10,10 +10,15 @@ use crate::common::{UI_COVERAGE, UI_COVERAGE_MAP};
use crate::runtest::{static_regex, Emit, ProcRes, TestCx, WillExecute}; use crate::runtest::{static_regex, Emit, ProcRes, TestCx, WillExecute};
impl<'test> TestCx<'test> { impl<'test> TestCx<'test> {
fn coverage_dump_path(&self) -> &Path {
self.config
.coverage_dump_path
.as_deref()
.unwrap_or_else(|| self.fatal("missing --coverage-dump"))
}
pub(crate) fn run_coverage_map_test(&self) { pub(crate) fn run_coverage_map_test(&self) {
let Some(coverage_dump_path) = &self.config.coverage_dump_path else { let coverage_dump_path = self.coverage_dump_path();
self.fatal("missing --coverage-dump");
};
let (proc_res, llvm_ir_path) = self.compile_test_and_save_ir(); let (proc_res, llvm_ir_path) = self.compile_test_and_save_ir();
if !proc_res.status.success() { if !proc_res.status.success() {
@ -102,8 +107,10 @@ impl<'test> TestCx<'test> {
let proc_res = self.run_llvm_tool("llvm-cov", |cmd| { let proc_res = self.run_llvm_tool("llvm-cov", |cmd| {
cmd.args(["show", "--format=text", "--show-line-counts-or-regions"]); cmd.args(["show", "--format=text", "--show-line-counts-or-regions"]);
cmd.arg("--Xdemangler"); // Specify the demangler binary and its arguments.
cmd.arg(self.config.rust_demangler_path.as_ref().unwrap()); let coverage_dump_path = self.coverage_dump_path();
cmd.arg("--Xdemangler").arg(coverage_dump_path);
cmd.arg("--Xdemangler").arg("--demangle");
cmd.arg("--instr-profile"); cmd.arg("--instr-profile");
cmd.arg(&profdata_path); cmd.arg(&profdata_path);