Skip to content

Commit

Permalink
Add rustdoc-ui test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Apr 16, 2018
1 parent a6fefde commit b2192ae
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap/builder.rs
Expand Up @@ -326,7 +326,7 @@ impl<'a> Builder<'a> {
test::TheBook, test::UnstableBook,
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme,
// Run run-make last, since these won't pass without make on Windows
test::RunMake),
test::RunMake, test::RustdocUi),
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc,
Expand Down
28 changes: 21 additions & 7 deletions src/bootstrap/test.rs
Expand Up @@ -886,8 +886,12 @@ impl Step for Compiletest {
cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
cmd.arg("--rustc-path").arg(builder.rustc(compiler));

let is_rustdoc_ui = suite.ends_with("rustdoc-ui");

// Avoid depending on rustdoc when we don't need it.
if mode == "rustdoc" || (mode == "run-make" && suite.ends_with("fulldeps")) {
if mode == "rustdoc" ||
(mode == "run-make" && suite.ends_with("fulldeps")) ||
(mode == "ui" && is_rustdoc_ui) {
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host));
}

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

let mut flags = vec!["-Crpath".to_string()];
if build.config.rust_optimize_tests {
flags.push("-O".to_string());
let mut flags = if is_rustdoc_ui {
Vec::new()
} else {
vec!["-Crpath".to_string()]
};
if !is_rustdoc_ui {
if build.config.rust_optimize_tests {
flags.push("-O".to_string());
}
if build.config.rust_debuginfo_tests {
flags.push("-g".to_string());
}
}
if build.config.rust_debuginfo_tests {
flags.push("-g".to_string());
if !is_rustdoc_ui {
flags.push("-Zmiri -Zunstable-options".to_string());
} else {
flags.push("-Zunstable-options".to_string());
}
flags.push("-Zunstable-options".to_string());
flags.push(build.config.cmd.rustc_args().join(" "));

if let Some(linker) = build.linker(target) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render.rs
Expand Up @@ -107,7 +107,7 @@ pub struct SharedContext {
/// This describes the layout of each page, and is not modified after
/// creation of the context (contains info like the favicon and added html).
pub layout: layout::Layout,
/// This flag indicates whether [src] links should be generated or not. If
/// This flag indicates whether `[src]` links should be generated or not. If
/// the source files are present in the html rendering, then this will be
/// `true`.
pub include_sources: bool,
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/lib.rs
Expand Up @@ -44,10 +44,10 @@
//!
//! Once you are familiar with the contents of the standard library you may
//! begin to find the verbosity of the prose distracting. At this stage in your
//! development you may want to press the **[-]** button near the top of the
//! development you may want to press the `[-]` button near the top of the
//! page to collapse it into a more skimmable view.
//!
//! While you are looking at that **[-]** button also notice the **[src]**
//! While you are looking at that `[-]` button also notice the `[src]`
//! button. Rust's API documentation comes with the source code and you are
//! encouraged to read it. The standard library source is generally high
//! quality and a peek behind the curtains is often enlightening.
Expand Down
1 change: 0 additions & 1 deletion src/libtest/lib.rs
Expand Up @@ -1288,7 +1288,6 @@ fn get_concurrency() -> usize {

pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescAndFn> {
let mut filtered = tests;

// Remove tests that don't match the test filter
filtered = match opts.filter {
None => filtered,
Expand Down
19 changes: 19 additions & 0 deletions src/test/rustdoc-ui/intra-links-warning.rs
@@ -0,0 +1,19 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

// must-compile-successfully

//! Test with [Foo::baz], [Bar::foo], [Uniooon::X]

pub struct Foo {
pub bar: usize,
}
6 changes: 6 additions & 0 deletions src/test/rustdoc-ui/intra-links-warning.stderr
@@ -0,0 +1,6 @@
warning: [Foo::baz] cannot be resolved, ignoring it...

warning: [Bar::foo] cannot be resolved, ignoring it...

warning: [Uniooon::X] cannot be resolved, ignoring it...

6 changes: 4 additions & 2 deletions src/tools/compiletest/src/main.rs
Expand Up @@ -283,6 +283,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
),
};

let src_base = opt_path(matches, "src-base");
let run_ignored = matches.opt_present("ignored");
Config {
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
run_lib_path: make_absolute(opt_path(matches, "run-lib-path")),
Expand All @@ -293,15 +295,15 @@ pub fn parse_config(args: Vec<String>) -> Config {
valgrind_path: matches.opt_str("valgrind-path"),
force_valgrind: matches.opt_present("force-valgrind"),
llvm_filecheck: matches.opt_str("llvm-filecheck").map(|s| PathBuf::from(&s)),
src_base: opt_path(matches, "src-base"),
src_base,
build_base: opt_path(matches, "build-base"),
stage_id: matches.opt_str("stage-id").unwrap(),
mode: matches
.opt_str("mode")
.unwrap()
.parse()
.expect("invalid mode"),
run_ignored: matches.opt_present("ignored"),
run_ignored,
filter: matches.free.first().cloned(),
filter_exact: matches.opt_present("exact"),
logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)),
Expand Down
51 changes: 31 additions & 20 deletions src/tools/compiletest/src/runtest.rs
Expand Up @@ -1288,7 +1288,9 @@ impl<'test> TestCx<'test> {
// want to actually assert warnings about all this code. Instead
// let's just ignore unused code warnings by defaults and tests
// can turn it back on if needed.
rustc.args(&["-A", "unused"]);
if !self.config.src_base.ends_with("rustdoc-ui") {
rustc.args(&["-A", "unused"]);
}
}
_ => {}
}
Expand Down Expand Up @@ -1582,7 +1584,12 @@ impl<'test> TestCx<'test> {
}

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

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

if let Some(ref incremental_dir) = self.props.incremental_dir {
rustc.args(&[
"-C",
&format!("incremental={}", incremental_dir.display()),
]);
rustc.args(&["-Z", "incremental-verify-ich"]);
rustc.args(&["-Z", "incremental-queries"]);
}
if !is_rustdoc {
if let Some(ref incremental_dir) = self.props.incremental_dir {
rustc.args(&[
"-C",
&format!("incremental={}", incremental_dir.display()),
]);
rustc.args(&["-Z", "incremental-verify-ich"]);
rustc.args(&["-Z", "incremental-queries"]);
}

if self.config.mode == CodegenUnits {
rustc.args(&["-Z", "human_readable_cgu_names"]);
if self.config.mode == CodegenUnits {
rustc.args(&["-Z", "human_readable_cgu_names"]);
}
}

match self.config.mode {
Expand Down Expand Up @@ -1668,11 +1677,12 @@ impl<'test> TestCx<'test> {
}
}


if self.config.target == "wasm32-unknown-unknown" {
// rustc.arg("-g"); // get any backtrace at all on errors
} else if !self.props.no_prefer_dynamic {
rustc.args(&["-C", "prefer-dynamic"]);
if !is_rustdoc {
if self.config.target == "wasm32-unknown-unknown" {
// rustc.arg("-g"); // get any backtrace at all on errors
} else if !self.props.no_prefer_dynamic {
rustc.args(&["-C", "prefer-dynamic"]);
}
}

match output_file {
Expand All @@ -1696,8 +1706,10 @@ impl<'test> TestCx<'test> {
} else {
rustc.args(self.split_maybe_args(&self.config.target_rustcflags));
}
if let Some(ref linker) = self.config.linker {
rustc.arg(format!("-Clinker={}", linker));
if !is_rustdoc {
if let Some(ref linker) = self.config.linker {
rustc.arg(format!("-Clinker={}", linker));
}
}

rustc.args(&self.props.compile_flags);
Expand Down Expand Up @@ -2509,7 +2521,6 @@ impl<'test> TestCx<'test> {
.compile_flags
.iter()
.any(|s| s.contains("--error-format"));

let proc_res = self.compile_test();
self.check_if_test_should_compile(&proc_res);

Expand Down

0 comments on commit b2192ae

Please sign in to comment.