Skip to content

Commit 6876f9b

Browse files
committed
filter linkcheck spurious failure
1 parent 9b91b9c commit 6876f9b

File tree

1 file changed

+35
-19
lines changed

1 file changed

+35
-19
lines changed

src/tools/rustbook/src/main.rs

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
use clap::{crate_version};
1+
use clap::crate_version;
22

33
use std::env;
44
use std::path::{Path, PathBuf};
55

6-
use clap::{App, ArgMatches, SubCommand, AppSettings};
6+
use clap::{App, AppSettings, ArgMatches, SubCommand};
77

8+
use mdbook::errors::Result as Result3;
89
use mdbook::MDBook;
9-
use mdbook::errors::{Result as Result3};
1010

11+
use failure::Error;
1112
#[cfg(feature = "linkcheck")]
1213
use mdbook::renderer::RenderContext;
1314
#[cfg(feature = "linkcheck")]
1415
use mdbook_linkcheck::{self, errors::BrokenLinks};
15-
use failure::Error;
1616

1717
fn main() {
1818
let d_message = "-d, --dest-dir=[dest-dir]
@@ -21,18 +21,22 @@ fn main() {
2121
'A directory for your book{n}(Defaults to Current Directory when omitted)'";
2222

2323
let matches = App::new("rustbook")
24-
.about("Build a book with mdBook")
25-
.author("Steve Klabnik <steve@steveklabnik.com>")
26-
.version(&*format!("v{}", crate_version!()))
27-
.setting(AppSettings::SubcommandRequired)
28-
.subcommand(SubCommand::with_name("build")
29-
.about("Build the book from the markdown files")
30-
.arg_from_usage(d_message)
31-
.arg_from_usage(dir_message))
32-
.subcommand(SubCommand::with_name("linkcheck")
33-
.about("Run linkcheck with mdBook 3")
34-
.arg_from_usage(dir_message))
35-
.get_matches();
24+
.about("Build a book with mdBook")
25+
.author("Steve Klabnik <steve@steveklabnik.com>")
26+
.version(&*format!("v{}", crate_version!()))
27+
.setting(AppSettings::SubcommandRequired)
28+
.subcommand(
29+
SubCommand::with_name("build")
30+
.about("Build the book from the markdown files")
31+
.arg_from_usage(d_message)
32+
.arg_from_usage(dir_message),
33+
)
34+
.subcommand(
35+
SubCommand::with_name("linkcheck")
36+
.about("Run linkcheck with mdBook 3")
37+
.arg_from_usage(dir_message),
38+
)
39+
.get_matches();
3640

3741
// Check which subcomamnd the user ran...
3842
match matches.subcommand() {
@@ -46,23 +50,35 @@ fn main() {
4650

4751
::std::process::exit(101);
4852
}
49-
},
53+
}
5054
("linkcheck", Some(sub_matches)) => {
5155
if let Err(err) = linkcheck(sub_matches) {
5256
eprintln!("Error: {}", err);
5357

58+
// HACK: ignore timeouts
59+
#[allow(unused_mut)]
60+
let mut actually_broken = false;
61+
5462
#[cfg(feature = "linkcheck")]
5563
{
5664
if let Ok(broken_links) = err.downcast::<BrokenLinks>() {
5765
for cause in broken_links.links().iter() {
5866
eprintln!("\tCaused By: {}", cause);
67+
68+
if cause.contains("timed out") {
69+
actually_broken = true;
70+
}
5971
}
6072
}
6173
}
6274

63-
::std::process::exit(101);
75+
if actually_broken {
76+
std::process::exit(101);
77+
} else {
78+
std::process::exit(0);
79+
}
6480
}
65-
},
81+
}
6682
(_, _) => unreachable!(),
6783
};
6884
}

0 commit comments

Comments
 (0)