diff options
| author | Brad Gibson <b2b@humanenginuity.com> | 2018-05-06 07:56:53 -0700 |
|---|---|---|
| committer | Brad Gibson <b2b@humanenginuity.com> | 2018-05-06 07:56:53 -0700 |
| commit | 6a78c0a10f2e719117fe4bb929bfb38549acfeec (patch) | |
| tree | 0089dcdd34bfa5ba430ed33163264b147677be59 /src/tools | |
| parent | e1d5509bf381d978a1894b6ba869c3b56dd3eeca (diff) | |
| parent | 6f721f54c6fb1de9cf00eb9d2d050f818c882871 (diff) | |
| download | rust-6a78c0a10f2e719117fe4bb929bfb38549acfeec.tar.gz rust-6a78c0a10f2e719117fe4bb929bfb38549acfeec.zip | |
resolved conflict with upstream commit
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/build-manifest/src/main.rs | 1 | ||||
| m--------- | src/tools/cargo | 0 | ||||
| m--------- | src/tools/clippy | 34 | ||||
| -rw-r--r-- | src/tools/compiletest/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/tools/compiletest/src/common.rs | 43 | ||||
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 10 | ||||
| -rw-r--r-- | src/tools/compiletest/src/main.rs | 4 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 76 | ||||
| m--------- | src/tools/rls | 0 | ||||
| -rw-r--r-- | src/tools/rustdoc-js/tester.js | 18 | ||||
| m--------- | src/tools/rustfmt | 22 | ||||
| -rw-r--r-- | src/tools/tidy/src/deps.rs | 1 | ||||
| -rw-r--r-- | src/tools/tidy/src/lib.rs | 1 | ||||
| -rw-r--r-- | src/tools/tidy/src/libcoretest.rs | 34 | ||||
| -rw-r--r-- | src/tools/tidy/src/main.rs | 1 |
15 files changed, 182 insertions, 65 deletions
diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 9f238929215..6b548742fb3 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -57,6 +57,7 @@ static TARGETS: &'static [&'static str] = &[ "arm-unknown-linux-musleabi", "arm-unknown-linux-musleabihf", "armv5te-unknown-linux-gnueabi", + "armv5te-unknown-linux-musleabi", "armv7-apple-ios", "armv7-linux-androideabi", "armv7-unknown-cloudabi-eabihf", diff --git a/src/tools/cargo b/src/tools/cargo -Subproject 0a1add2d8689ad12a86f6c32d0a5cd0393dc5d8 +Subproject af3f1cd29bc872b932a13083e531255aab233a7 diff --git a/src/tools/clippy b/src/tools/clippy -Subproject c5b39a5917ffc0f1349b6e414fa3b874fdcf842 +Subproject 1742229ebb7843a65c05ee495d8de5366fcc556 diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index 7d02f0b746d..45cb147fbbc 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -13,10 +13,12 @@ regex = "0.2" serde = "1.0" serde_json = "1.0" serde_derive = "1.0" +rustfix = "0.2" [target.'cfg(unix)'.dependencies] libc = "0.2" [target.'cfg(windows)'.dependencies] +lazy_static = "1.0" miow = "0.3" winapi = { version = "0.3", features = ["winerror"] } diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 365b47447f2..2df52816599 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -74,30 +74,30 @@ impl FromStr for Mode { impl fmt::Display for Mode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(match *self { - CompileFail => "compile-fail", - ParseFail => "parse-fail", - RunFail => "run-fail", - RunPass => "run-pass", - RunPassValgrind => "run-pass-valgrind", - Pretty => "pretty", - DebugInfoGdb => "debuginfo-gdb", - DebugInfoLldb => "debuginfo-lldb", - Codegen => "codegen", - Rustdoc => "rustdoc", - CodegenUnits => "codegen-units", - Incremental => "incremental", - RunMake => "run-make", - Ui => "ui", - MirOpt => "mir-opt", - }, - f) + let s = match *self { + CompileFail => "compile-fail", + ParseFail => "parse-fail", + RunFail => "run-fail", + RunPass => "run-pass", + RunPassValgrind => "run-pass-valgrind", + Pretty => "pretty", + DebugInfoGdb => "debuginfo-gdb", + DebugInfoLldb => "debuginfo-lldb", + Codegen => "codegen", + Rustdoc => "rustdoc", + CodegenUnits => "codegen-units", + Incremental => "incremental", + RunMake => "run-make", + Ui => "ui", + MirOpt => "mir-opt", + }; + fmt::Display::fmt(s, f) } } -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub enum CompareMode { - Nll + Nll, } impl CompareMode { @@ -269,6 +269,7 @@ pub fn expected_output_path(testpaths: &TestPaths, testpaths.file.with_extension(extension) } -pub const UI_EXTENSIONS: &[&str] = &[UI_STDERR, UI_STDOUT]; +pub const UI_EXTENSIONS: &[&str] = &[UI_STDERR, UI_STDOUT, UI_FIXED]; pub const UI_STDERR: &str = "stderr"; pub const UI_STDOUT: &str = "stdout"; +pub const UI_FIXED: &str = "fixed"; diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 73dd079cf0c..7ac3f5b5b25 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -236,6 +236,7 @@ pub struct TestProps { pub normalize_stdout: Vec<(String, String)>, pub normalize_stderr: Vec<(String, String)>, pub failure_status: i32, + pub run_rustfix: bool, } impl TestProps { @@ -267,6 +268,7 @@ impl TestProps { normalize_stdout: vec![], normalize_stderr: vec![], failure_status: 101, + run_rustfix: false, } } @@ -403,6 +405,10 @@ impl TestProps { if let Some(code) = config.parse_failure_status(ln) { self.failure_status = code; } + + if !self.run_rustfix { + self.run_rustfix = config.parse_run_rustfix(ln); + } }); for key in &["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] { @@ -642,6 +648,10 @@ impl Config { None } + + fn parse_run_rustfix(&self, line: &str) -> bool { + self.parse_name_directive(line, "run-rustfix") + } } pub fn lldb_version_to_int(version_string: &str) -> isize { diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 37f7af0abe8..e2b446c99dc 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -23,9 +23,13 @@ extern crate libc; extern crate log; extern crate regex; #[macro_use] +#[cfg(windows)] +extern crate lazy_static; +#[macro_use] extern crate serde_derive; extern crate serde_json; extern crate test; +extern crate rustfix; use std::env; use std::ffi::OsString; diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 85434bb8a69..1bac9ef66bb 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -12,7 +12,7 @@ use common::{Config, TestPaths}; use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc}; use common::{Incremental, MirOpt, RunMake, Ui}; -use common::{expected_output_path, UI_STDERR, UI_STDOUT}; +use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED}; use common::CompareMode; use diff; use errors::{self, Error, ErrorKind}; @@ -21,6 +21,7 @@ use json; use header::TestProps; use util::logv; use regex::Regex; +use rustfix::{apply_suggestions, get_suggestions_from_json}; use std::collections::VecDeque; use std::collections::HashMap; @@ -37,6 +38,39 @@ use std::str; use extract_gdb_version; +#[cfg(windows)] +fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R { + use std::sync::Mutex; + const SEM_NOGPFAULTERRORBOX: u32 = 0x0002; + extern "system" { + fn SetErrorMode(mode: u32) -> u32; + } + + lazy_static! { + static ref LOCK: Mutex<()> = { + Mutex::new(()) + }; + } + // Error mode is a global variable, so lock it so only one thread will change it + let _lock = LOCK.lock().unwrap(); + + // Tell Windows to not show any UI on errors (such as terminating abnormally). + // This is important for running tests, since some of them use abnormal + // termination by design. This mode is inherited by all child processes. + unsafe { + let old_mode = SetErrorMode(SEM_NOGPFAULTERRORBOX); // read inherited flags + SetErrorMode(old_mode | SEM_NOGPFAULTERRORBOX); + let r = f(); + SetErrorMode(old_mode); + r + } +} + +#[cfg(not(windows))] +fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R { + f() +} + /// The name of the environment variable that holds dynamic library locations. pub fn dylib_env_var() -> &'static str { if cfg!(windows) { @@ -1168,6 +1202,8 @@ impl<'test> TestCx<'test> { for line in proc_res.stderr.lines() { if line.contains("error: internal compiler error") { self.fatal_proc_rec("compiler encountered internal error", proc_res); + } else if line.contains(" panicked at ") { + self.fatal_proc_rec("compiler panicked", proc_res); } } } @@ -1575,8 +1611,7 @@ impl<'test> TestCx<'test> { let newpath = env::join_paths(&path).unwrap(); command.env(dylib_env_var(), newpath); - let mut child = command - .spawn() + let mut child = disable_error_reporting(|| command.spawn()) .expect(&format!("failed to exec `{:?}`", &command)); if let Some(input) = input { child @@ -2550,6 +2585,7 @@ impl<'test> TestCx<'test> { let expected_stderr = self.load_expected_output(UI_STDERR); let expected_stdout = self.load_expected_output(UI_STDOUT); + let expected_fixed = self.load_expected_output(UI_FIXED); let normalized_stdout = self.normalize_output(&proc_res.stdout, &self.props.normalize_stdout); @@ -2566,6 +2602,21 @@ impl<'test> TestCx<'test> { errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout); errors += self.compare_output("stderr", &normalized_stderr, &expected_stderr); + if self.config.compare_mode.is_some() { + // don't test rustfix with nll right now + } else if self.props.run_rustfix { + // Apply suggestions from rustc to the code itself + let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file) + .unwrap(); + let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap(); + let fixed_code = apply_suggestions(&unfixed_code, &suggestions); + + errors += self.compare_output("fixed", &fixed_code, &expected_fixed); + } else if !expected_fixed.is_empty() { + panic!("the `// run-rustfix` directive wasn't found but a `*.fixed` \ + file was found"); + } + if errors > 0 { println!("To update references, run this command from build directory:"); let relative_path_to_file = self.testpaths @@ -2601,6 +2652,23 @@ impl<'test> TestCx<'test> { self.check_error_patterns(&proc_res.stderr, &proc_res); } } + + if self.props.run_rustfix && self.config.compare_mode.is_none() { + // And finally, compile the fixed code and make sure it both + // succeeds and has no diagnostics. + let mut rustc = self.make_compile_args( + &self.testpaths.file.with_extension(UI_FIXED), + TargetLocation::ThisFile(self.make_exe_name()), + ); + rustc.arg("-L").arg(&self.aux_output_dir_name()); + let res = self.compose_and_run_compiler(rustc, None); + if !res.status.success() { + self.fatal_proc_rec("failed to compile fixed code", &res); + } + if !res.stderr.is_empty() { + self.fatal_proc_rec("fixed code is still producing diagnostics", &res); + } + } } fn run_mir_opt_test(&self) { @@ -2733,10 +2801,12 @@ impl<'test> TestCx<'test> { panic!( "Did not find expected line, error: {}\n\ Expected Line: {:?}\n\ + Test Name: {}\n\ Expected:\n{}\n\ Actual:\n{}", extra_msg, expected_line, + test_name, expected_content, normalize_all ); diff --git a/src/tools/rls b/src/tools/rls -Subproject 9144e223a5b90e078366275ff3dcdd406e62eae +Subproject d2f44357fef6d61f316abc403e0a5d917f2771c diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js index 6992f2ba123..1c79443dedf 100644 --- a/src/tools/rustdoc-js/tester.js +++ b/src/tools/rustdoc-js/tester.js @@ -87,6 +87,7 @@ function loadContent(content) { var Module = module.constructor; var m = new Module(); m._compile(content, "tmp.js"); + m.exports.ignore_order = content.indexOf("\n// ignore-order\n") !== -1; return m.exports; } @@ -130,10 +131,10 @@ function lookForEntry(entry, data) { } } if (allGood === true) { - return true; + return i; } } - return false; + return null; } function main(argv) { @@ -177,6 +178,7 @@ function main(argv) { 'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;'); const expected = loadedFile.EXPECTED; const query = loadedFile.QUERY; + const ignore_order = loadedFile.ignore_order; var results = loaded.execSearch(loaded.getQuery(query), index); process.stdout.write('Checking "' + file + '" ... '); var error_text = []; @@ -189,13 +191,17 @@ function main(argv) { break; } var entry = expected[key]; - var found = false; + var prev_pos = 0; for (var i = 0; i < entry.length; ++i) { - if (lookForEntry(entry[i], results[key]) === true) { - found = true; - } else { + var entry_pos = lookForEntry(entry[i], results[key]); + if (entry_pos === null) { error_text.push("==> Result not found in '" + key + "': '" + JSON.stringify(entry[i]) + "'"); + } else if (entry_pos < prev_pos && ignore_order === false) { + error_text.push("==> '" + JSON.stringify(entry[i]) + "' was supposed to be " + + " before '" + JSON.stringify(results[key][entry_pos]) + "'"); + } else { + prev_pos = entry_pos; } } } diff --git a/src/tools/rustfmt b/src/tools/rustfmt -Subproject ac8ae0062544743aaea1719a34f299b66f2b7dc +Subproject b6cd17f28ae314f2484ff05d3ce57652d51c5e8 diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 8caf39fc27b..9a87fcb00d5 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -73,6 +73,7 @@ static WHITELIST: &'static [Crate] = &[ Crate("flate2"), Crate("fuchsia-zircon"), Crate("fuchsia-zircon-sys"), + Crate("getopts"), Crate("humantime"), Crate("jobserver"), Crate("kernel32-sys"), diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index fa227436640..022ef57503a 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -51,6 +51,7 @@ pub mod pal; pub mod deps; pub mod ui_tests; pub mod unstable_book; +pub mod libcoretest; fn filter_dirs(path: &Path) -> bool { let skip = [ diff --git a/src/tools/tidy/src/libcoretest.rs b/src/tools/tidy/src/libcoretest.rs new file mode 100644 index 00000000000..ef8b55186b1 --- /dev/null +++ b/src/tools/tidy/src/libcoretest.rs @@ -0,0 +1,34 @@ +// 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. + +//! Tidy check to ensure `#[test]` is not used directly inside `libcore`. +//! +//! `#![no_core]` libraries cannot be tested directly due to duplicating lang +//! item. All tests must be written externally in `libcore/tests`. + +use std::path::Path; +use std::fs::read_to_string; + +pub fn check(path: &Path, bad: &mut bool) { + let libcore_path = path.join("libcore"); + super::walk( + &libcore_path, + &mut |subpath| t!(subpath.strip_prefix(&libcore_path)).starts_with("tests"), + &mut |subpath| { + if t!(read_to_string(subpath)).contains("#[test]") { + tidy_error!( + bad, + "{} contains #[test]; libcore tests must be placed inside `src/libcore/tests/`", + subpath.display() + ); + } + }, + ); +} diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 24974192795..7b86650823a 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -41,6 +41,7 @@ fn main() { features::check(&path, &mut bad, quiet); pal::check(&path, &mut bad); unstable_book::check(&path, &mut bad); + libcoretest::check(&path, &mut bad); if !args.iter().any(|s| *s == "--no-vendor") { deps::check(&path, &mut bad); } |
