Skip to content

Commit c0eedc0

Browse files
committed
Address review comments
- remove unused args - Fix formatting - Improve naming - Fix typo
1 parent 341eb6d commit c0eedc0

File tree

2 files changed

+21
-29
lines changed

2 files changed

+21
-29
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,9 +2212,14 @@ impl<'test> TestCx<'test> {
22122212
proc_res.fatal(None, || ());
22132213
}
22142214

2215-
fn fatal_proc_rec_with_ctx(&self, err: &str, proc_res: &ProcRes, ctx: impl FnOnce(Self)) -> ! {
2215+
fn fatal_proc_rec_with_ctx(
2216+
&self,
2217+
err: &str,
2218+
proc_res: &ProcRes,
2219+
on_failure: impl FnOnce(Self),
2220+
) -> ! {
22162221
self.error(err);
2217-
proc_res.fatal(None, || ctx(*self));
2222+
proc_res.fatal(None, || on_failure(*self));
22182223
}
22192224

22202225
// codegen tests (using FileCheck)
@@ -2376,7 +2381,7 @@ impl<'test> TestCx<'test> {
23762381
.wait()
23772382
.unwrap();
23782383
if !status.success() {
2379-
self.fatal("failed to run tidy - is installed?");
2384+
self.fatal("failed to run tidy - is it installed?");
23802385
}
23812386
let status = Command::new(tidy).arg(&compare_dir).spawn().unwrap().wait().unwrap();
23822387
if !status.success() {
@@ -3653,7 +3658,7 @@ pub struct ProcRes {
36533658
}
36543659

36553660
impl ProcRes {
3656-
pub fn fatal(&self, err: Option<&str>, ctx: impl FnOnce()) -> ! {
3661+
pub fn fatal(&self, err: Option<&str>, on_failure: impl FnOnce()) -> ! {
36573662
if let Some(e) = err {
36583663
println!("\nerror: {}", e);
36593664
}
@@ -3675,7 +3680,7 @@ impl ProcRes {
36753680
json::extract_rendered(&self.stdout),
36763681
json::extract_rendered(&self.stderr),
36773682
);
3678-
ctx();
3683+
on_failure();
36793684
// Use resume_unwind instead of panic!() to prevent a panic message + backtrace from
36803685
// compiletest, which is unnecessary noise.
36813686
std::panic::resume_unwind(Box::new(()));

src/tools/compiletest/tidy-rustdoc.sh

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,17 @@ set -euo pipefail
55
indir="${1:?Missing argument 1: input directory}"
66

77
tidy () {
8-
{
9-
# new-inline-tags is workaround for:
10-
# https://github.com/rust-lang/stdarch/issues/945
11-
# https://github.com/rust-lang/mdBook/issues/1372
12-
command tidy \
13-
--indent yes \
14-
--indent-spaces 2 \
15-
--wrap 0 \
16-
--show-warnings no \
17-
--markup yes \
18-
--quiet yes \
19-
--new-inline-tags 'c t' \
20-
"$@" \
21-
>/dev/null \
22-
|| {
23-
# tidy exits with code 1 if there were any warnings :facepalm:
24-
status=$?
25-
if [ $status != 0 ] && [ $status != 1 ]
26-
then
27-
echo "While tidying $1" >&2
28-
exit 1
29-
fi
30-
}
31-
} | sed -E 's/#[0-9]+(-[0-9]+)?/#line/g'
8+
command tidy \
9+
--indent yes \
10+
--indent-spaces 2 \
11+
--wrap 0 \
12+
--show-warnings no \
13+
--markup yes \
14+
--quiet yes \
15+
"$@" \
16+
>/dev/null \
17+
# tidy exits with code 1 if there were any warnings
18+
|| [ $? -eq 1 ]
3219
}
3320

3421
find "$indir" -type f -name '*.html' -print0 \

0 commit comments

Comments
 (0)