From 4620f82a13adce6c324baa6ed77dce511a586504 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 31 Dec 2022 11:52:16 -0800 Subject: [PATCH 1/2] Fix tidy unittest. --- src/tools/tidy/src/features/version/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/tidy/src/features/version/tests.rs b/src/tools/tidy/src/features/version/tests.rs index 31224fdf1ea..7701dce2df1 100644 --- a/src/tools/tidy/src/features/version/tests.rs +++ b/src/tools/tidy/src/features/version/tests.rs @@ -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] From 59b80f598fd983a3800d6f2ffd23f0a5a89c3f4f Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 31 Dec 2022 12:31:42 -0800 Subject: [PATCH 2/2] Run `cargo test` on tidy itself. --- src/bootstrap/builder.rs | 1 + src/bootstrap/test.rs | 34 +++++++++++++++++++ .../host-x86_64/mingw-check-tidy/Dockerfile | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 66bc0f023b6..b54bf432621 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -662,6 +662,7 @@ impl<'a> Builder<'a> { crate::toolstate::ToolStateCheck, test::ExpandYamlAnchors, test::Tidy, + test::TidySelfTest, test::Ui, test::RunPassValgrind, test::MirOpt, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index d5bec268a45..ea906be7e3a 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -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; diff --git a/src/ci/docker/host-x86_64/mingw-check-tidy/Dockerfile b/src/ci/docker/host-x86_64/mingw-check-tidy/Dockerfile index 78fee152eb9..c340294fc73 100644 --- a/src/ci/docker/host-x86_64/mingw-check-tidy/Dockerfile +++ b/src/ci/docker/host-x86_64/mingw-check-tidy/Dockerfile @@ -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