From 879ba2626d28beabdc6c0ff0c482c81b20a54f61 Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Thu, 22 Feb 2024 01:29:02 +0000 Subject: [PATCH] Convert `format_util_readmes` to Rust test --- .github/workflows/ci.yml | 5 +---- cargo-dylint/tests/ci.rs | 17 ++++++++++++++++- scripts/update_util_READMEs.sh | 17 ----------------- 3 files changed, 17 insertions(+), 22 deletions(-) delete mode 100755 scripts/update_util_READMEs.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9aecce07..886dd8151 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,7 +85,6 @@ jobs: rm -f "$HOME"/.cargo/bin/rustfmt rustup install nightly rustup component add rustfmt --toolchain nightly - cargo install cargo-rdme || true - name: Format run: ./scripts/format.sh && git diff --exit-code @@ -93,9 +92,6 @@ jobs: - name: Format example READMEs run: ./scripts/update_example_READMEs.sh && git diff --exit-code - - name: Format util READMEs - run: ./scripts/update_util_READMEs.sh && git diff --exit-code - - name: Lint run: ./scripts/lint.sh @@ -145,6 +141,7 @@ jobs: cargo install cargo-hack || true cargo install cargo-license || true cargo install cargo-msrv || true + cargo install cargo-rdme || true cargo install cargo-sort || true cargo install cargo-supply-chain || true cargo install cargo-udeps --locked || true diff --git a/cargo-dylint/tests/ci.rs b/cargo-dylint/tests/ci.rs index 236b956e2..38d3273e3 100644 --- a/cargo-dylint/tests/ci.rs +++ b/cargo-dylint/tests/ci.rs @@ -11,7 +11,7 @@ use similar_asserts::SimpleDiff; use std::{ env::{set_current_dir, set_var}, ffi::OsStr, - fs::{read_to_string, write}, + fs::{read_dir, read_to_string, write}, io::{stderr, Write}, path::{Component, Path, PathBuf}, str::FromStr, @@ -122,6 +122,21 @@ fn cargo_dylint_and_dylint_readmes_are_equal() { compare_lines(&cargo_dylint_readme, &dylint_readme); } +#[test] +fn format_util_readmes() { + preserves_cleanliness("format_util_readmes", false, || { + for entry in read_dir("utils").unwrap() { + let entry = entry.unwrap(); + let path = entry.path(); + Command::new("cargo") + .arg("rdme") + .current_dir(path) + .assert() + .success(); + } + }); +} + #[test] fn hack_feature_powerset_udeps() { Command::new("rustup") diff --git a/scripts/update_util_READMEs.sh b/scripts/update_util_READMEs.sh deleted file mode 100755 index 00b61eb2a..000000000 --- a/scripts/update_util_READMEs.sh +++ /dev/null @@ -1,17 +0,0 @@ -#! /bin/bash - -# set -x -set -euo pipefail - -SCRIPTS="$(dirname "$(realpath "$0")")" -WORKSPACE="$(realpath "$SCRIPTS"/..)" - -cd "$WORKSPACE"/utils - -for UTIL in *; do - pushd "$UTIL" >/dev/null - - cargo rdme "$@" - - popd >/dev/null -done