Skip to content

Commit fcdbb4a

Browse files
committed
bootstrap: Add check/test/run steps for src/tools/coverage-dump
This also causes the coverage-dump unit tests to run in CI and `./x test` by default.
1 parent fa58ce3 commit fcdbb4a

File tree

5 files changed

+89
-6
lines changed

5 files changed

+89
-6
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,3 +527,59 @@ tool_check_step!(Bootstrap { path: "src/bootstrap", default: false });
527527
// `run-make-support` will be built as part of suitable run-make compiletest test steps, but support
528528
// check to make it easier to work on.
529529
tool_check_step!(RunMakeSupport { path: "src/tools/run-make-support", default: false });
530+
531+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
532+
pub(crate) struct CoverageDump {}
533+
534+
impl CoverageDump {
535+
pub(crate) const DISPLAY_NAME: &str = "coverage-dump";
536+
pub(crate) const PATH: &str = "src/tools/coverage-dump";
537+
}
538+
539+
impl Step for CoverageDump {
540+
type Output = ();
541+
542+
const DEFAULT: bool = false;
543+
const ONLY_HOSTS: bool = true;
544+
545+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
546+
run.path(Self::PATH)
547+
}
548+
549+
fn make_run(run: RunConfig<'_>) {
550+
run.builder.ensure(Self {});
551+
}
552+
553+
fn run(self, builder: &Builder<'_>) -> Self::Output {
554+
let Self {} = self;
555+
let display_name = Self::DISPLAY_NAME;
556+
let host = builder.config.build;
557+
let target = host;
558+
let mode = Mode::ToolBootstrap;
559+
560+
let compiler = builder.compiler(0, host);
561+
let cargo = prepare_tool_cargo(
562+
builder,
563+
compiler,
564+
mode,
565+
target,
566+
builder.kind,
567+
Self::PATH,
568+
SourceType::InTree,
569+
&[],
570+
);
571+
572+
let stamp = BuildStamp::new(&builder.cargo_out(compiler, mode, target))
573+
.with_prefix(&format!("{display_name}-check"));
574+
575+
let _guard = builder.msg_tool(
576+
builder.kind,
577+
mode,
578+
display_name,
579+
compiler.stage,
580+
&compiler.host,
581+
&target,
582+
);
583+
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
584+
}
585+
}

src/bootstrap/src/core/build_steps/run.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use std::path::PathBuf;
77

88
use crate::Mode;
99
use crate::core::build_steps::dist::distdir;
10-
use crate::core::build_steps::test;
1110
use crate::core::build_steps::tool::{self, SourceType, Tool};
1211
use crate::core::build_steps::vendor::{Vendor, default_paths_to_vendor};
12+
use crate::core::build_steps::{check, test};
1313
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
1414
use crate::core::config::TargetSelection;
1515
use crate::core::config::flags::get_completion;
@@ -392,3 +392,31 @@ impl Step for CyclicStep {
392392
builder.ensure(CyclicStep { n: self.n.saturating_sub(1) })
393393
}
394394
}
395+
396+
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
397+
pub struct CoverageDump {}
398+
399+
impl CoverageDump {
400+
const PATH: &str = check::CoverageDump::PATH;
401+
}
402+
403+
impl Step for CoverageDump {
404+
type Output = ();
405+
406+
const DEFAULT: bool = false;
407+
const ONLY_HOSTS: bool = true;
408+
409+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
410+
run.path(Self::PATH)
411+
}
412+
413+
fn make_run(run: RunConfig<'_>) {
414+
run.builder.ensure(Self {});
415+
}
416+
417+
fn run(self, builder: &Builder<'_>) {
418+
let mut cmd = builder.tool_cmd(Tool::CoverageDump);
419+
cmd.args(&builder.config.free_args);
420+
cmd.run(builder);
421+
}
422+
}

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::core::build_steps::llvm::get_llvm_version;
1717
use crate::core::build_steps::synthetic_targets::MirOptPanicAbortSyntheticTarget;
1818
use crate::core::build_steps::tool::{self, COMPILETEST_ALLOW_FEATURES, SourceType, Tool};
1919
use crate::core::build_steps::toolstate::ToolState;
20-
use crate::core::build_steps::{compile, dist, llvm};
20+
use crate::core::build_steps::{check, compile, dist, llvm};
2121
use crate::core::builder::{
2222
self, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, crate_description,
2323
};
@@ -54,6 +54,7 @@ impl Step for CrateBootstrap {
5454
run.path("src/tools/jsondoclint")
5555
.path("src/tools/suggest-tests")
5656
.path("src/tools/replace-version-placeholder")
57+
.path(check::CoverageDump::PATH)
5758
// We want `./x test tidy` to _run_ the tidy tool, not its tests.
5859
// So we need a separate alias to test the tidy tool itself.
5960
.alias("tidyselftest")

src/bootstrap/src/core/builder/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ impl<'a> Builder<'a> {
961961
check::RunMakeSupport,
962962
check::Compiletest,
963963
check::FeaturesStatusDump,
964+
check::CoverageDump,
964965
),
965966
Kind::Test => describe!(
966967
crate::core::build_steps::toolstate::ToolStateCheck,
@@ -1114,6 +1115,7 @@ impl<'a> Builder<'a> {
11141115
run::UnicodeTableGenerator,
11151116
run::FeaturesStatusDump,
11161117
run::CyclicStep,
1118+
run::CoverageDump,
11171119
),
11181120
Kind::Setup => {
11191121
describe!(setup::Profile, setup::Hook, setup::Link, setup::Editor)

src/tools/coverage-dump/src/parser/tests.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
use super::unescape_llvm_string_contents;
22

3-
// WARNING: These tests don't necessarily run in CI, and were mainly used to
4-
// help track down problems when originally developing this tool.
5-
// (The tool is still tested indirectly by snapshot tests that rely on it.)
6-
73
// Tests for `unescape_llvm_string_contents`:
84

95
#[test]

0 commit comments

Comments
 (0)