X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fcompiletest%2Fruntest.rs;h=c7561248eb7fb4397b74b9c98193b9bda76c8447;hb=862911df9af8216edc94458df2084143aad7be5b;hp=8042e2f966ca73e8582579b9f9619dbcc7968e56;hpb=2f59977d96ebe5cf5fc000bf27e3f663cad3250c;p=rust.git diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 8042e2f966c..c7561248eb7 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use self::TargetLocation::*; - use common::Config; use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; -use common::{Codegen, DebugInfoLldb, DebugInfoGdb, Rustdoc}; +use common::{Codegen, DebugInfoLldb, DebugInfoGdb, Rustdoc, CodegenUnits}; use errors; use header::TestProps; use header; @@ -20,6 +18,7 @@ use util::logv; use std::env; +use std::collections::HashSet; use std::fmt; use std::fs::{self, File}; use std::io::BufReader; @@ -58,6 +57,7 @@ pub fn run(config: Config, testfile: &Path) { DebugInfoLldb => run_debuginfo_lldb_test(&config, &props, &testfile), Codegen => run_codegen_test(&config, &props, &testfile), Rustdoc => run_rustdoc_test(&config, &props, &testfile), + CodegenUnits => run_codegen_units_test(&config, &props, &testfile), } } @@ -1009,15 +1009,12 @@ fn continuation( line: &str) -> bool { } } -fn is_compiler_error_or_warning(mut line: &str) -> bool { - // Remove initial prefix which may contain a colon - let mut components = Path::new(line).components(); - if let Some(Component::Prefix(_)) = components.peek() { - components.next(); - } - - // Safe as path was originally constructed from a &str ^ - line = components.as_path().to_str().unwrap(); +fn is_compiler_error_or_warning(line: &str) -> bool { + let mut c = Path::new(line).components(); + let line = match c.next() { + Some(Component::Prefix(_)) => c.as_path().to_str().unwrap(), + _ => line, + }; let mut i = 0; return @@ -1149,11 +1146,20 @@ fn compile_test(config: &Config, props: &TestProps, } fn document(config: &Config, props: &TestProps, - testfile: &Path) -> (ProcRes, PathBuf) { + testfile: &Path, out_dir: &Path) -> ProcRes { + if props.build_aux_docs { + for rel_ab in &props.aux_builds { + let abs_ab = config.aux_base.join(rel_ab); + let aux_props = header::load_props(&abs_ab); + + let auxres = document(config, &aux_props, &abs_ab, out_dir); + if !auxres.status.success() { + return auxres; + } + } + } + let aux_dir = aux_output_dir_name(config, testfile); - let out_dir = output_base_name(config, testfile); - let _ = fs::remove_dir_all(&out_dir); - ensure_dir(&out_dir); let mut args = vec!["-L".to_owned(), aux_dir.to_str().unwrap().to_owned(), "-o".to_owned(), @@ -1164,7 +1170,7 @@ fn document(config: &Config, props: &TestProps, prog: config.rustdoc_path.to_str().unwrap().to_owned(), args: args, }; - (compose_and_run_compiler(config, props, testfile, args, None), out_dir) + compose_and_run_compiler(config, props, testfile, args, None) } fn exec_compiled_test(config: &Config, props: &TestProps, @@ -1305,7 +1311,7 @@ fn make_compile_args(config: &Config, "-L".to_owned(), config.build_base.to_str().unwrap().to_owned(), format!("--target={}", target)); - args.push_all(&extras); + args.extend_from_slice(&extras); if !props.no_prefer_dynamic { args.push("-C".to_owned()); args.push("prefer-dynamic".to_owned()); @@ -1723,7 +1729,11 @@ fn charset() -> &'static str { } fn run_rustdoc_test(config: &Config, props: &TestProps, testfile: &Path) { - let (proc_res, out_dir) = document(config, props, testfile); + let out_dir = output_base_name(config, testfile); + let _ = fs::remove_dir_all(&out_dir); + ensure_dir(&out_dir); + + let proc_res = document(config, props, testfile, &out_dir); if !proc_res.status.success() { fatal_proc_rec("rustdoc failed!", &proc_res); } @@ -1739,3 +1749,44 @@ fn run_rustdoc_test(config: &Config, props: &TestProps, testfile: &Path) { fatal_proc_rec("htmldocck failed!", &res); } } + +fn run_codegen_units_test(config: &Config, props: &TestProps, testfile: &Path) { + let proc_res = compile_test(config, props, testfile); + + if !proc_res.status.success() { + fatal_proc_rec("compilation failed!", &proc_res); + } + + check_no_compiler_crash(&proc_res); + + let prefix = "TRANS_ITEM "; + + let actual: HashSet = proc_res + .stdout + .lines() + .filter(|line| line.starts_with(prefix)) + .map(|s| (&s[prefix.len()..]).to_string()) + .collect(); + + let expected: HashSet = errors::load_errors(testfile) + .iter() + .map(|e| e.msg.trim().to_string()) + .collect(); + + if actual != expected { + let mut missing: Vec<_> = expected.difference(&actual).collect(); + missing.sort(); + + let mut too_much: Vec<_> = actual.difference(&expected).collect(); + too_much.sort(); + + println!("Expected and actual sets of codegen-items differ.\n\ + These items should have been contained but were not:\n\n\ + {}\n\n\ + These items were contained but should not have been:\n\n\ + {}\n\n", + missing.iter().fold("".to_string(), |s1, s2| s1 + "\n" + s2), + too_much.iter().fold("".to_string(), |s1, s2| s1 + "\n" + s2)); + panic!(); + } +}