|
1 | 1 | //! Auxiliary tools for checking various documentation. |
2 | 2 |
|
3 | 3 | use super::test_helpers::run_cargo_test; |
| 4 | +use crate::core::build_steps::compile; |
4 | 5 | use crate::core::build_steps::tool::{self, SourceType, Tool}; |
5 | | -use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; |
| 6 | +use crate::core::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step}; |
6 | 7 | use crate::core::config::TargetSelection; |
7 | | -use crate::utils::exec::command; |
8 | | -use crate::utils::helpers::{self}; |
| 8 | +use crate::utils::exec::{BootstrapCommand, command}; |
| 9 | +use crate::utils::helpers; |
9 | 10 | use crate::{DocTests, Mode}; |
10 | 11 |
|
11 | 12 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -139,3 +140,86 @@ impl Step for HtmlCheck { |
139 | 140 | .run(builder); |
140 | 141 | } |
141 | 142 | } |
| 143 | + |
| 144 | +#[derive(Debug, Clone, PartialEq, Eq, Hash)] |
| 145 | +pub struct TierCheck { |
| 146 | + pub compiler: Compiler, |
| 147 | +} |
| 148 | + |
| 149 | +impl Step for TierCheck { |
| 150 | + type Output = (); |
| 151 | + const DEFAULT: bool = true; |
| 152 | + const ONLY_HOSTS: bool = true; |
| 153 | + |
| 154 | + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
| 155 | + run.path("src/tools/tier-check") |
| 156 | + } |
| 157 | + |
| 158 | + fn make_run(run: RunConfig<'_>) { |
| 159 | + let compiler = |
| 160 | + run.builder.compiler_for(run.builder.top_stage, run.builder.build.build, run.target); |
| 161 | + run.builder.ensure(TierCheck { compiler }); |
| 162 | + } |
| 163 | + |
| 164 | + /// Tests the Platform Support page in the rustc book. |
| 165 | + fn run(self, builder: &Builder<'_>) { |
| 166 | + builder.ensure(compile::Std::new(self.compiler, self.compiler.host)); |
| 167 | + let mut cargo = tool::prepare_tool_cargo( |
| 168 | + builder, |
| 169 | + self.compiler, |
| 170 | + Mode::ToolStd, |
| 171 | + self.compiler.host, |
| 172 | + Kind::Run, |
| 173 | + "src/tools/tier-check", |
| 174 | + SourceType::InTree, |
| 175 | + &[], |
| 176 | + ); |
| 177 | + cargo.arg(builder.src.join("src/doc/rustc/src/platform-support.md")); |
| 178 | + cargo.arg(builder.rustc(self.compiler)); |
| 179 | + if builder.is_verbose() { |
| 180 | + cargo.arg("--verbose"); |
| 181 | + } |
| 182 | + |
| 183 | + let _guard = builder.msg( |
| 184 | + Kind::Test, |
| 185 | + self.compiler.stage, |
| 186 | + "platform support check", |
| 187 | + self.compiler.host, |
| 188 | + self.compiler.host, |
| 189 | + ); |
| 190 | + BootstrapCommand::from(cargo).delay_failure().run(builder); |
| 191 | + } |
| 192 | +} |
| 193 | + |
| 194 | +#[derive(Debug, Clone, PartialEq, Eq, Hash)] |
| 195 | +pub struct LintDocs { |
| 196 | + pub compiler: Compiler, |
| 197 | + pub target: TargetSelection, |
| 198 | +} |
| 199 | + |
| 200 | +impl Step for LintDocs { |
| 201 | + type Output = (); |
| 202 | + const DEFAULT: bool = true; |
| 203 | + const ONLY_HOSTS: bool = true; |
| 204 | + |
| 205 | + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
| 206 | + run.path("src/tools/lint-docs") |
| 207 | + } |
| 208 | + |
| 209 | + fn make_run(run: RunConfig<'_>) { |
| 210 | + run.builder.ensure(LintDocs { |
| 211 | + compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), |
| 212 | + target: run.target, |
| 213 | + }); |
| 214 | + } |
| 215 | + |
| 216 | + /// Tests that the lint examples in the rustc book generate the correct lints and have the |
| 217 | + /// expected format. |
| 218 | + fn run(self, builder: &Builder<'_>) { |
| 219 | + builder.ensure(crate::core::build_steps::doc::RustcBook { |
| 220 | + compiler: self.compiler, |
| 221 | + target: self.target, |
| 222 | + validate: true, |
| 223 | + }); |
| 224 | + } |
| 225 | +} |
0 commit comments