Add rustdoc-ui test suite

This commit is contained in:
Guillaume Gomez 2018-04-01 21:06:35 +02:00
parent a6fefdecdf
commit b2192ae157
9 changed files with 85 additions and 34 deletions

View File

@ -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,

View File

@ -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));
}
@ -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) {

View File

@ -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,

View File

@ -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.

View File

@ -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,

View File

@ -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,
}

View File

@ -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...

View File

@ -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")),
@ -293,7 +295,7 @@ 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
@ -301,7 +303,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
.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)),

View File

@ -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"]);
}
}
_ => {}
}
@ -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.
@ -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 {
@ -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 {
@ -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);
@ -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);