Skip to content

Commit f87696b

Browse files
Test rustdoc unit tests.
Doc tests are temporarily disabled until next release cycle, since current beta Cargo errors on them. Upgrade should be smooth as the relevant tests are already fixed in this commit.
1 parent 2f1ef9e commit f87696b

File tree

5 files changed

+79
-13
lines changed

5 files changed

+79
-13
lines changed

src/bootstrap/builder.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ impl<'a> Builder<'a> {
251251
tool::RustInstaller, tool::Cargo, tool::Rls, tool::Rustdoc, tool::Clippy,
252252
native::Llvm),
253253
Kind::Test => describe!(check::Tidy, check::Bootstrap, check::DefaultCompiletest,
254-
check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Linkcheck,
255-
check::Cargotest, check::Cargo, check::Rls, check::Docs, check::ErrorIndex,
256-
check::Distcheck),
254+
check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Rustdoc,
255+
check::Linkcheck, check::Cargotest, check::Cargo, check::Rls, check::Docs,
256+
check::ErrorIndex, check::Distcheck),
257257
Kind::Bench => describe!(check::Crate, check::CrateLibrustc),
258258
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
259259
doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon,

src/bootstrap/check.rs

+68-1
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,6 @@ impl Step for CrateLibrustc {
900900
}
901901
}
902902

903-
904903
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
905904
pub struct Crate {
906905
compiler: Compiler,
@@ -1080,6 +1079,74 @@ impl Step for Crate {
10801079
}
10811080
}
10821081

1082+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1083+
pub struct Rustdoc {
1084+
host: Interned<String>,
1085+
test_kind: TestKind,
1086+
}
1087+
1088+
impl Step for Rustdoc {
1089+
type Output = ();
1090+
const DEFAULT: bool = true;
1091+
const ONLY_HOSTS: bool = true;
1092+
1093+
fn should_run(run: ShouldRun) -> ShouldRun {
1094+
run.path("src/librustdoc").path("src/tools/rustdoc")
1095+
}
1096+
1097+
fn make_run(run: RunConfig) {
1098+
let builder = run.builder;
1099+
1100+
let test_kind = if builder.kind == Kind::Test {
1101+
TestKind::Test
1102+
} else if builder.kind == Kind::Bench {
1103+
TestKind::Bench
1104+
} else {
1105+
panic!("unexpected builder.kind in crate: {:?}", builder.kind);
1106+
};
1107+
1108+
builder.ensure(Rustdoc {
1109+
host: run.host,
1110+
test_kind,
1111+
});
1112+
}
1113+
1114+
fn run(self, builder: &Builder) {
1115+
let build = builder.build;
1116+
let test_kind = self.test_kind;
1117+
1118+
let compiler = builder.compiler(builder.top_stage, self.host);
1119+
let target = compiler.host;
1120+
1121+
builder.ensure(RemoteCopyLibs { compiler, target });
1122+
1123+
let mut cargo = builder.cargo(compiler, Mode::Librustc, target, test_kind.subcommand());
1124+
compile::rustc_cargo(build, &compiler, target, &mut cargo);
1125+
let _folder = build.fold_output(|| {
1126+
format!("{}_stage{}-rustdoc", test_kind.subcommand(), compiler.stage)
1127+
});
1128+
println!("{} rustdoc stage{} ({} -> {})", test_kind, compiler.stage,
1129+
&compiler.host, target);
1130+
1131+
if test_kind.subcommand() == "test" && !build.fail_fast {
1132+
cargo.arg("--no-fail-fast");
1133+
}
1134+
1135+
cargo.arg("-p").arg("rustdoc:0.0.0");
1136+
1137+
cargo.arg("--");
1138+
cargo.args(&build.config.cmd.test_args());
1139+
1140+
if build.config.quiet_tests {
1141+
cargo.arg("--quiet");
1142+
}
1143+
1144+
let _time = util::timeit();
1145+
1146+
try_run(build, &mut cargo);
1147+
}
1148+
}
1149+
10831150
fn envify(s: &str) -> String {
10841151
s.chars().map(|c| {
10851152
match c {

src/librustdoc/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ build = "build.rs"
77
[lib]
88
name = "rustdoc"
99
path = "lib.rs"
10+
# SNAP/stage0(cargo)
11+
doctest = false
1012

1113
[dependencies]
1214
env_logger = { version = "0.4", default-features = false }

src/librustdoc/clean/simplify.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@
1515
//! the AST (e.g. see all of `clean::inline`), but this is not always a
1616
//! non-lossy transformation. The current format of storage for where clauses
1717
//! for functions and such is simply a list of predicates. One example of this
18-
//! is that the AST predicate of:
19-
//!
20-
//! where T: Trait<Foo=Bar>
21-
//!
22-
//! is encoded as:
23-
//!
24-
//! where T: Trait, <T as Trait>::Foo = Bar
18+
//! is that the AST predicate of: `where T: Trait<Foo=Bar>` is encoded as:
19+
//! `where T: Trait, <T as Trait>::Foo = Bar`.
2520
//!
2621
//! This module attempts to reconstruct the original where and/or parameter
2722
//! bounds by special casing scenarios such as these. Fun!

src/librustdoc/html/markdown.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
//! of `fmt::Display`. Example usage:
1717
//!
1818
//! ```
19-
//! use rustdoc::html::markdown::Markdown;
19+
//! #![feature(rustc_private)]
20+
//!
21+
//! use rustdoc::html::markdown::{RenderType, Markdown};
2022
//!
2123
//! let s = "My *markdown* _text_";
22-
//! let html = format!("{}", Markdown(s));
24+
//! let html = format!("{}", Markdown(s, RenderType::Pulldown));
2325
//! // ... something using html
2426
//! ```
2527

0 commit comments

Comments
 (0)