X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fcompiletest%2Fruntest.rs;h=c7561248eb7fb4397b74b9c98193b9bda76c8447;hb=862911df9af8216edc94458df2084143aad7be5b;hp=459b43b4ffe5d8ca23ffaa60a0ead444d88d871e;hpb=158a1bdd7dac47356a0cc44dd52308c7145f4afe;p=rust.git diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 459b43b4ffe..c7561248eb7 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -10,7 +10,7 @@ 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; @@ -18,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; @@ -56,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), } } @@ -1747,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!(); + } +}