From c0eedc0b6ad30dfa1eb2b225246b4b3debed1cdb Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 6 Nov 2020 17:37:29 -0500 Subject: [PATCH] Address review comments - remove unused args - Fix formatting - Improve naming - Fix typo --- src/tools/compiletest/src/runtest.rs | 15 ++++++++---- src/tools/compiletest/tidy-rustdoc.sh | 35 +++++++++------------------ 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 819f7257eee6..59c650d94cdc 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2212,9 +2212,14 @@ impl<'test> TestCx<'test> { proc_res.fatal(None, || ()); } - fn fatal_proc_rec_with_ctx(&self, err: &str, proc_res: &ProcRes, ctx: impl FnOnce(Self)) -> ! { + fn fatal_proc_rec_with_ctx( + &self, + err: &str, + proc_res: &ProcRes, + on_failure: impl FnOnce(Self), + ) -> ! { self.error(err); - proc_res.fatal(None, || ctx(*self)); + proc_res.fatal(None, || on_failure(*self)); } // codegen tests (using FileCheck) @@ -2376,7 +2381,7 @@ impl<'test> TestCx<'test> { .wait() .unwrap(); if !status.success() { - self.fatal("failed to run tidy - is installed?"); + self.fatal("failed to run tidy - is it installed?"); } let status = Command::new(tidy).arg(&compare_dir).spawn().unwrap().wait().unwrap(); if !status.success() { @@ -3653,7 +3658,7 @@ pub struct ProcRes { } impl ProcRes { - pub fn fatal(&self, err: Option<&str>, ctx: impl FnOnce()) -> ! { + pub fn fatal(&self, err: Option<&str>, on_failure: impl FnOnce()) -> ! { if let Some(e) = err { println!("\nerror: {}", e); } @@ -3675,7 +3680,7 @@ impl ProcRes { json::extract_rendered(&self.stdout), json::extract_rendered(&self.stderr), ); - ctx(); + on_failure(); // Use resume_unwind instead of panic!() to prevent a panic message + backtrace from // compiletest, which is unnecessary noise. std::panic::resume_unwind(Box::new(())); diff --git a/src/tools/compiletest/tidy-rustdoc.sh b/src/tools/compiletest/tidy-rustdoc.sh index ce2c99d94d0c..b31957058e8c 100755 --- a/src/tools/compiletest/tidy-rustdoc.sh +++ b/src/tools/compiletest/tidy-rustdoc.sh @@ -5,30 +5,17 @@ set -euo pipefail indir="${1:?Missing argument 1: input directory}" tidy () { - { - # new-inline-tags is workaround for: - # https://github.com/rust-lang/stdarch/issues/945 - # https://github.com/rust-lang/mdBook/issues/1372 - command tidy \ - --indent yes \ - --indent-spaces 2 \ - --wrap 0 \ - --show-warnings no \ - --markup yes \ - --quiet yes \ - --new-inline-tags 'c t' \ - "$@" \ - >/dev/null \ - || { - # tidy exits with code 1 if there were any warnings :facepalm: - status=$? - if [ $status != 0 ] && [ $status != 1 ] - then - echo "While tidying $1" >&2 - exit 1 - fi - } - } | sed -E 's/#[0-9]+(-[0-9]+)?/#line/g' + command tidy \ + --indent yes \ + --indent-spaces 2 \ + --wrap 0 \ + --show-warnings no \ + --markup yes \ + --quiet yes \ + "$@" \ + >/dev/null \ + # tidy exits with code 1 if there were any warnings + || [ $? -eq 1 ] } find "$indir" -type f -name '*.html' -print0 \