Skip to content

Commit

Permalink
Move from bash to rust
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Nov 21, 2020
1 parent 4d44d77 commit 25a3ffe
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 40 deletions.
49 changes: 33 additions & 16 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2390,22 +2390,39 @@ impl<'test> TestCx<'test> {
proc_res.fatal(Some("failed to run nightly rustdoc"), || ());
}

// NOTE: this is fine since compiletest never runs out-of-tree
let tidy = concat!(env!("CARGO_MANIFEST_DIR"), "/tidy-rustdoc.sh");
// FIXME: this overwrites `out_dir` in place, maybe we should make a copy?
let status = Command::new(tidy)
.arg(out_dir)
.spawn()
.expect("tidy-rustdoc not found")
.wait()
.unwrap();
if !status.success() {
self.fatal("failed to run tidy - is it installed?");
}
let status = Command::new(tidy).arg(&compare_dir).spawn().unwrap().wait().unwrap();
if !status.success() {
self.fatal("failed to run tidy");
}
#[rustfmt::skip]
let tidy_args = [
"--indent", "yes",
"--indent-spaces", "2",
"--wrap", "0",
"--show-warnings", "no",
"--markup", "yes",
"--quiet", "yes",
"-modify",
];
let tidy_dir = |dir| {
let tidy = |file: &_| {
Command::new("tidy")
.args(&tidy_args)
.arg(file)
.spawn()
.unwrap_or_else(|err| {
self.fatal(&format!("failed to run tidy - is it installed? - {}", err))
})
.wait()
.unwrap()
};
for entry in walkdir::WalkDir::new(dir) {
let entry = entry.expect("failed to read file");
if entry.file_type().is_file()
&& entry.path().extension().and_then(|p| p.to_str()) == Some("html".into())
{
tidy(entry.path());
}
}
};
tidy_dir(out_dir);
tidy_dir(&compare_dir);

let pager = {
let output = Command::new("git").args(&["config", "--get", "core.pager"]).output().ok();
Expand Down
24 changes: 0 additions & 24 deletions src/tools/compiletest/tidy-rustdoc.sh

This file was deleted.

0 comments on commit 25a3ffe

Please sign in to comment.