Skip to content

Commit 067d8ea

Browse files
Add rustdoc-ui test suite
1 parent 4d941e5 commit 067d8ea

File tree

9 files changed

+85
-34
lines changed

9 files changed

+85
-34
lines changed

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl<'a> Builder<'a> {
326326
test::TheBook, test::UnstableBook,
327327
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme,
328328
// Run run-make last, since these won't pass without make on Windows
329-
test::RunMake),
329+
test::RunMake, test::RustdocUi),
330330
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
331331
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
332332
doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc,

src/bootstrap/test.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,12 @@ impl Step for Compiletest {
886886
cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
887887
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
888888

889+
let is_rustdoc_ui = suite.ends_with("rustdoc-ui");
890+
889891
// Avoid depending on rustdoc when we don't need it.
890-
if mode == "rustdoc" || (mode == "run-make" && suite.ends_with("fulldeps")) {
892+
if mode == "rustdoc" ||
893+
(mode == "run-make" && suite.ends_with("fulldeps")) ||
894+
(mode == "ui" && is_rustdoc_ui) {
891895
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host));
892896
}
893897

@@ -903,14 +907,24 @@ impl Step for Compiletest {
903907
cmd.arg("--nodejs").arg(nodejs);
904908
}
905909

906-
let mut flags = vec!["-Crpath".to_string()];
907-
if build.config.rust_optimize_tests {
908-
flags.push("-O".to_string());
910+
let mut flags = if is_rustdoc_ui {
911+
Vec::new()
912+
} else {
913+
vec!["-Crpath".to_string()]
914+
};
915+
if !is_rustdoc_ui {
916+
if build.config.rust_optimize_tests {
917+
flags.push("-O".to_string());
918+
}
919+
if build.config.rust_debuginfo_tests {
920+
flags.push("-g".to_string());
921+
}
909922
}
910-
if build.config.rust_debuginfo_tests {
911-
flags.push("-g".to_string());
923+
if !is_rustdoc_ui {
924+
flags.push("-Zmiri -Zunstable-options".to_string());
925+
} else {
926+
flags.push("-Zunstable-options".to_string());
912927
}
913-
flags.push("-Zunstable-options".to_string());
914928
flags.push(build.config.cmd.rustc_args().join(" "));
915929

916930
if let Some(linker) = build.linker(target) {

src/librustdoc/html/render.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub struct SharedContext {
107107
/// This describes the layout of each page, and is not modified after
108108
/// creation of the context (contains info like the favicon and added html).
109109
pub layout: layout::Layout,
110-
/// This flag indicates whether [src] links should be generated or not. If
110+
/// This flag indicates whether `[src]` links should be generated or not. If
111111
/// the source files are present in the html rendering, then this will be
112112
/// `true`.
113113
pub include_sources: bool,

src/libstd/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
//!
4545
//! Once you are familiar with the contents of the standard library you may
4646
//! begin to find the verbosity of the prose distracting. At this stage in your
47-
//! development you may want to press the **[-]** button near the top of the
47+
//! development you may want to press the `[-]` button near the top of the
4848
//! page to collapse it into a more skimmable view.
4949
//!
50-
//! While you are looking at that **[-]** button also notice the **[src]**
50+
//! While you are looking at that `[-]` button also notice the `[src]`
5151
//! button. Rust's API documentation comes with the source code and you are
5252
//! encouraged to read it. The standard library source is generally high
5353
//! quality and a peek behind the curtains is often enlightening.

src/libtest/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,6 @@ fn get_concurrency() -> usize {
12881288

12891289
pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescAndFn> {
12901290
let mut filtered = tests;
1291-
12921291
// Remove tests that don't match the test filter
12931292
filtered = match opts.filter {
12941293
None => filtered,
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![deny(warnings)]
12+
13+
// must-compile-successfully
14+
15+
//! Test with [Foo::baz], [Bar::foo], [Uniooon::X]
16+
17+
pub struct Foo {
18+
pub bar: usize,
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: [Foo::baz] cannot be resolved, ignoring it...
2+
3+
warning: [Bar::foo] cannot be resolved, ignoring it...
4+
5+
warning: [Uniooon::X] cannot be resolved, ignoring it...
6+

src/tools/compiletest/src/main.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
283283
),
284284
};
285285

286+
let src_base = opt_path(matches, "src-base");
287+
let run_ignored = matches.opt_present("ignored");
286288
Config {
287289
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
288290
run_lib_path: make_absolute(opt_path(matches, "run-lib-path")),
@@ -293,15 +295,15 @@ pub fn parse_config(args: Vec<String>) -> Config {
293295
valgrind_path: matches.opt_str("valgrind-path"),
294296
force_valgrind: matches.opt_present("force-valgrind"),
295297
llvm_filecheck: matches.opt_str("llvm-filecheck").map(|s| PathBuf::from(&s)),
296-
src_base: opt_path(matches, "src-base"),
298+
src_base,
297299
build_base: opt_path(matches, "build-base"),
298300
stage_id: matches.opt_str("stage-id").unwrap(),
299301
mode: matches
300302
.opt_str("mode")
301303
.unwrap()
302304
.parse()
303305
.expect("invalid mode"),
304-
run_ignored: matches.opt_present("ignored"),
306+
run_ignored,
305307
filter: matches.free.first().cloned(),
306308
filter_exact: matches.opt_present("exact"),
307309
logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)),

src/tools/compiletest/src/runtest.rs

+31-20
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,9 @@ impl<'test> TestCx<'test> {
12881288
// want to actually assert warnings about all this code. Instead
12891289
// let's just ignore unused code warnings by defaults and tests
12901290
// can turn it back on if needed.
1291-
rustc.args(&["-A", "unused"]);
1291+
if !self.config.src_base.ends_with("rustdoc-ui") {
1292+
rustc.args(&["-A", "unused"]);
1293+
}
12921294
}
12931295
_ => {}
12941296
}
@@ -1582,7 +1584,12 @@ impl<'test> TestCx<'test> {
15821584
}
15831585

15841586
fn make_compile_args(&self, input_file: &Path, output_file: TargetLocation) -> Command {
1585-
let mut rustc = Command::new(&self.config.rustc_path);
1587+
let is_rustdoc = self.config.src_base.ends_with("rustdoc-ui");
1588+
let mut rustc = if !is_rustdoc {
1589+
Command::new(&self.config.rustc_path)
1590+
} else {
1591+
Command::new(&self.config.rustdoc_path.clone().expect("no rustdoc built yet"))
1592+
};
15861593
rustc.arg(input_file).arg("-L").arg(&self.config.build_base);
15871594

15881595
// Optionally prevent default --target if specified in test compile-flags.
@@ -1605,17 +1612,19 @@ impl<'test> TestCx<'test> {
16051612
rustc.args(&["--cfg", revision]);
16061613
}
16071614

1608-
if let Some(ref incremental_dir) = self.props.incremental_dir {
1609-
rustc.args(&[
1610-
"-C",
1611-
&format!("incremental={}", incremental_dir.display()),
1612-
]);
1613-
rustc.args(&["-Z", "incremental-verify-ich"]);
1614-
rustc.args(&["-Z", "incremental-queries"]);
1615-
}
1615+
if !is_rustdoc {
1616+
if let Some(ref incremental_dir) = self.props.incremental_dir {
1617+
rustc.args(&[
1618+
"-C",
1619+
&format!("incremental={}", incremental_dir.display()),
1620+
]);
1621+
rustc.args(&["-Z", "incremental-verify-ich"]);
1622+
rustc.args(&["-Z", "incremental-queries"]);
1623+
}
16161624

1617-
if self.config.mode == CodegenUnits {
1618-
rustc.args(&["-Z", "human_readable_cgu_names"]);
1625+
if self.config.mode == CodegenUnits {
1626+
rustc.args(&["-Z", "human_readable_cgu_names"]);
1627+
}
16191628
}
16201629

16211630
match self.config.mode {
@@ -1668,11 +1677,12 @@ impl<'test> TestCx<'test> {
16681677
}
16691678
}
16701679

1671-
1672-
if self.config.target == "wasm32-unknown-unknown" {
1673-
// rustc.arg("-g"); // get any backtrace at all on errors
1674-
} else if !self.props.no_prefer_dynamic {
1675-
rustc.args(&["-C", "prefer-dynamic"]);
1680+
if !is_rustdoc {
1681+
if self.config.target == "wasm32-unknown-unknown" {
1682+
// rustc.arg("-g"); // get any backtrace at all on errors
1683+
} else if !self.props.no_prefer_dynamic {
1684+
rustc.args(&["-C", "prefer-dynamic"]);
1685+
}
16761686
}
16771687

16781688
match output_file {
@@ -1696,8 +1706,10 @@ impl<'test> TestCx<'test> {
16961706
} else {
16971707
rustc.args(self.split_maybe_args(&self.config.target_rustcflags));
16981708
}
1699-
if let Some(ref linker) = self.config.linker {
1700-
rustc.arg(format!("-Clinker={}", linker));
1709+
if !is_rustdoc {
1710+
if let Some(ref linker) = self.config.linker {
1711+
rustc.arg(format!("-Clinker={}", linker));
1712+
}
17011713
}
17021714

17031715
rustc.args(&self.props.compile_flags);
@@ -2509,7 +2521,6 @@ impl<'test> TestCx<'test> {
25092521
.compile_flags
25102522
.iter()
25112523
.any(|s| s.contains("--error-format"));
2512-
25132524
let proc_res = self.compile_test();
25142525
self.check_if_test_should_compile(&proc_res);
25152526

0 commit comments

Comments
 (0)