Rollup merge of #106334 - ehuss:fix-tidy-unittests, r=jyn514

Fix tidy unittest.

The tidy unittests weren't compiling due to a change made a long while ago to the `Version` type.
This commit is contained in:
Matthias Krüger 2022-12-31 23:51:35 +01:00 committed by GitHub
commit 0b3c3c9b64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 3 deletions

View File

@ -662,6 +662,7 @@ impl<'a> Builder<'a> {
crate::toolstate::ToolStateCheck,
test::ExpandYamlAnchors,
test::Tidy,
test::TidySelfTest,
test::Ui,
test::RunPassValgrind,
test::MirOpt,

View File

@ -1143,6 +1143,40 @@ help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy`
}
}
/// Runs tidy's own tests.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct TidySelfTest;
impl Step for TidySelfTest {
type Output = ();
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.alias("tidyselftest")
}
fn make_run(run: RunConfig<'_>) {
run.builder.ensure(TidySelfTest);
}
fn run(self, builder: &Builder<'_>) {
let bootstrap_host = builder.config.build;
let compiler = builder.compiler(0, bootstrap_host);
let cargo = tool::prepare_tool_cargo(
builder,
compiler,
Mode::ToolBootstrap,
bootstrap_host,
"test",
"src/tools/tidy",
SourceType::InTree,
&[],
);
try_run(builder, &mut cargo.into());
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct ExpandYamlAnchors;

View File

@ -33,4 +33,4 @@ COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/
ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
ENV SCRIPT python3 ../x.py test --stage 0 src/tools/tidy
ENV SCRIPT python3 ../x.py test --stage 0 src/tools/tidy tidyselftest

View File

@ -12,8 +12,8 @@ fn test_try_from_invalid_version() {
#[test]
fn test_try_from_single() {
assert_eq!("1.32.0".parse(), Ok(Version { parts: [1, 32, 0] }));
assert_eq!("1.0.0".parse(), Ok(Version { parts: [1, 0, 0] }));
assert_eq!("1.32.0".parse(), Ok(Version::Explicit { parts: [1, 32, 0] }));
assert_eq!("1.0.0".parse(), Ok(Version::Explicit { parts: [1, 0, 0] }));
}
#[test]