auto merge of #15173 : Sawyer47/rust/de-to-string, r=alexcrichton
This commit is contained in:
commit
7da94c1a00
4 changed files with 77 additions and 95 deletions
|
@ -48,9 +48,7 @@ fn start(argc: int, argv: **u8) -> int {
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let args = os::args();
|
let args = os::args();
|
||||||
let config = parse_config(args.move_iter()
|
let config = parse_config(args);
|
||||||
.map(|x| x.to_string())
|
|
||||||
.collect());
|
|
||||||
log_config(&config);
|
log_config(&config);
|
||||||
run_tests(&config);
|
run_tests(&config);
|
||||||
}
|
}
|
||||||
|
@ -131,17 +129,15 @@ pub fn parse_config(args: Vec<String> ) -> Config {
|
||||||
};
|
};
|
||||||
|
|
||||||
Config {
|
Config {
|
||||||
compile_lib_path: matches.opt_str("compile-lib-path")
|
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
|
||||||
.unwrap()
|
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
|
||||||
.to_string(),
|
|
||||||
run_lib_path: matches.opt_str("run-lib-path").unwrap().to_string(),
|
|
||||||
rustc_path: opt_path(matches, "rustc-path"),
|
rustc_path: opt_path(matches, "rustc-path"),
|
||||||
clang_path: matches.opt_str("clang-path").map(|s| Path::new(s)),
|
clang_path: matches.opt_str("clang-path").map(|s| Path::new(s)),
|
||||||
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::new(s)),
|
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::new(s)),
|
||||||
src_base: opt_path(matches, "src-base"),
|
src_base: opt_path(matches, "src-base"),
|
||||||
build_base: opt_path(matches, "build-base"),
|
build_base: opt_path(matches, "build-base"),
|
||||||
aux_base: opt_path(matches, "aux-base"),
|
aux_base: opt_path(matches, "aux-base"),
|
||||||
stage_id: matches.opt_str("stage-id").unwrap().to_string(),
|
stage_id: matches.opt_str("stage-id").unwrap(),
|
||||||
mode: FromStr::from_str(matches.opt_str("mode")
|
mode: FromStr::from_str(matches.opt_str("mode")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_slice()).expect("invalid mode"),
|
.as_slice()).expect("invalid mode"),
|
||||||
|
@ -155,32 +151,23 @@ pub fn parse_config(args: Vec<String> ) -> Config {
|
||||||
ratchet_noise_percent:
|
ratchet_noise_percent:
|
||||||
matches.opt_str("ratchet-noise-percent")
|
matches.opt_str("ratchet-noise-percent")
|
||||||
.and_then(|s| from_str::<f64>(s.as_slice())),
|
.and_then(|s| from_str::<f64>(s.as_slice())),
|
||||||
runtool: matches.opt_str("runtool").map(|x| x.to_string()),
|
runtool: matches.opt_str("runtool"),
|
||||||
host_rustcflags: matches.opt_str("host-rustcflags")
|
host_rustcflags: matches.opt_str("host-rustcflags"),
|
||||||
.map(|x| x.to_string()),
|
target_rustcflags: matches.opt_str("target-rustcflags"),
|
||||||
target_rustcflags: matches.opt_str("target-rustcflags")
|
|
||||||
.map(|x| x.to_string()),
|
|
||||||
jit: matches.opt_present("jit"),
|
jit: matches.opt_present("jit"),
|
||||||
target: opt_str2(matches.opt_str("target").map(|x| x.to_string())),
|
target: opt_str2(matches.opt_str("target")),
|
||||||
host: opt_str2(matches.opt_str("host").map(|x| x.to_string())),
|
host: opt_str2(matches.opt_str("host")),
|
||||||
android_cross_path: opt_path(matches, "android-cross-path"),
|
android_cross_path: opt_path(matches, "android-cross-path"),
|
||||||
adb_path: opt_str2(matches.opt_str("adb-path")
|
adb_path: opt_str2(matches.opt_str("adb-path")),
|
||||||
.map(|x| x.to_string())),
|
adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")),
|
||||||
adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")
|
|
||||||
.map(|x| x.to_string())),
|
|
||||||
adb_device_status:
|
adb_device_status:
|
||||||
"arm-linux-androideabi" ==
|
"arm-linux-androideabi" ==
|
||||||
opt_str2(matches.opt_str("target")
|
opt_str2(matches.opt_str("target")).as_slice() &&
|
||||||
.map(|x| x.to_string())).as_slice() &&
|
|
||||||
"(none)" !=
|
"(none)" !=
|
||||||
opt_str2(matches.opt_str("adb-test-dir")
|
opt_str2(matches.opt_str("adb-test-dir")).as_slice() &&
|
||||||
.map(|x| x.to_string())).as_slice() &&
|
!opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
|
||||||
!opt_str2(matches.opt_str("adb-test-dir")
|
lldb_python_dir: matches.opt_str("lldb-python-dir"),
|
||||||
.map(|x| x.to_string())).is_empty(),
|
test_shard: test::opt_shard(matches.opt_str("test-shard")),
|
||||||
lldb_python_dir: matches.opt_str("lldb-python-dir")
|
|
||||||
.map(|x| x.to_string()),
|
|
||||||
test_shard: test::opt_shard(matches.opt_str("test-shard")
|
|
||||||
.map(|x| x.to_string())),
|
|
||||||
verbose: matches.opt_present("verbose")
|
verbose: matches.opt_present("verbose")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,23 +170,23 @@ fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_error_pattern(line: &str) -> Option<String> {
|
fn parse_error_pattern(line: &str) -> Option<String> {
|
||||||
parse_name_value_directive(line, "error-pattern".to_string())
|
parse_name_value_directive(line, "error-pattern")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_aux_build(line: &str) -> Option<String> {
|
fn parse_aux_build(line: &str) -> Option<String> {
|
||||||
parse_name_value_directive(line, "aux-build".to_string())
|
parse_name_value_directive(line, "aux-build")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_compile_flags(line: &str) -> Option<String> {
|
fn parse_compile_flags(line: &str) -> Option<String> {
|
||||||
parse_name_value_directive(line, "compile-flags".to_string())
|
parse_name_value_directive(line, "compile-flags")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_run_flags(line: &str) -> Option<String> {
|
fn parse_run_flags(line: &str) -> Option<String> {
|
||||||
parse_name_value_directive(line, "run-flags".to_string())
|
parse_name_value_directive(line, "run-flags")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_check_line(line: &str) -> Option<String> {
|
fn parse_check_line(line: &str) -> Option<String> {
|
||||||
parse_name_value_directive(line, "check".to_string())
|
parse_name_value_directive(line, "check")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_force_host(line: &str) -> bool {
|
fn parse_force_host(line: &str) -> bool {
|
||||||
|
@ -206,7 +206,7 @@ fn parse_no_pretty_expanded(line: &str) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_exec_env(line: &str) -> Option<(String, String)> {
|
fn parse_exec_env(line: &str) -> Option<(String, String)> {
|
||||||
parse_name_value_directive(line, "exec-env".to_string()).map(|nv| {
|
parse_name_value_directive(line, "exec-env").map(|nv| {
|
||||||
// nv is either FOO or FOO=BAR
|
// nv is either FOO or FOO=BAR
|
||||||
let mut strs: Vec<String> = nv.as_slice()
|
let mut strs: Vec<String> = nv.as_slice()
|
||||||
.splitn('=', 1)
|
.splitn('=', 1)
|
||||||
|
@ -225,7 +225,7 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
|
fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
|
||||||
match parse_name_value_directive(line, "pp-exact".to_string()) {
|
match parse_name_value_directive(line, "pp-exact") {
|
||||||
Some(s) => Some(Path::new(s)),
|
Some(s) => Some(Path::new(s)),
|
||||||
None => {
|
None => {
|
||||||
if parse_name_directive(line, "pp-exact") {
|
if parse_name_directive(line, "pp-exact") {
|
||||||
|
@ -241,7 +241,7 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
|
||||||
line.contains(directive)
|
line.contains(directive)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_name_value_directive(line: &str, directive: String)
|
pub fn parse_name_value_directive(line: &str, directive: &str)
|
||||||
-> Option<String> {
|
-> Option<String> {
|
||||||
let keycolon = format!("{}:", directive);
|
let keycolon = format!("{}:", directive);
|
||||||
match line.find_str(keycolon.as_slice()) {
|
match line.find_str(keycolon.as_slice()) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ fn run_cfail_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
let proc_res = compile_test(config, props, testfile);
|
let proc_res = compile_test(config, props, testfile);
|
||||||
|
|
||||||
if proc_res.status.success() {
|
if proc_res.status.success() {
|
||||||
fatal_proc_rec("compile-fail test compiled successfully!".to_string(),
|
fatal_proc_rec("compile-fail test compiled successfully!",
|
||||||
&proc_res);
|
&proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +82,7 @@ fn run_cfail_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
let expected_errors = errors::load_errors(&config.cfail_regex, testfile);
|
let expected_errors = errors::load_errors(&config.cfail_regex, testfile);
|
||||||
if !expected_errors.is_empty() {
|
if !expected_errors.is_empty() {
|
||||||
if !props.error_patterns.is_empty() {
|
if !props.error_patterns.is_empty() {
|
||||||
fatal("both error pattern and expected errors \
|
fatal("both error pattern and expected errors specified");
|
||||||
specified".to_string());
|
|
||||||
}
|
}
|
||||||
check_expected_errors(expected_errors, testfile, &proc_res);
|
check_expected_errors(expected_errors, testfile, &proc_res);
|
||||||
} else {
|
} else {
|
||||||
|
@ -97,7 +96,7 @@ fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
let proc_res = compile_test(config, props, testfile);
|
let proc_res = compile_test(config, props, testfile);
|
||||||
|
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec("compilation failed!".to_string(), &proc_res);
|
fatal_proc_rec("compilation failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
exec_compiled_test(config, props, testfile)
|
exec_compiled_test(config, props, testfile)
|
||||||
|
@ -108,8 +107,7 @@ fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
// The value our Makefile configures valgrind to return on failure
|
// The value our Makefile configures valgrind to return on failure
|
||||||
static VALGRIND_ERR: int = 100;
|
static VALGRIND_ERR: int = 100;
|
||||||
if proc_res.status.matches_exit_status(VALGRIND_ERR) {
|
if proc_res.status.matches_exit_status(VALGRIND_ERR) {
|
||||||
fatal_proc_rec("run-fail test isn't valgrind-clean!".to_string(),
|
fatal_proc_rec("run-fail test isn't valgrind-clean!", &proc_res);
|
||||||
&proc_res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_correct_failure_status(&proc_res);
|
check_correct_failure_status(&proc_res);
|
||||||
|
@ -121,7 +119,8 @@ fn check_correct_failure_status(proc_res: &ProcRes) {
|
||||||
static RUST_ERR: int = 101;
|
static RUST_ERR: int = 101;
|
||||||
if !proc_res.status.matches_exit_status(RUST_ERR) {
|
if !proc_res.status.matches_exit_status(RUST_ERR) {
|
||||||
fatal_proc_rec(
|
fatal_proc_rec(
|
||||||
format!("failure produced the wrong error: {}", proc_res.status),
|
format!("failure produced the wrong error: {}",
|
||||||
|
proc_res.status).as_slice(),
|
||||||
proc_res);
|
proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,19 +130,19 @@ fn run_rpass_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
let mut proc_res = compile_test(config, props, testfile);
|
let mut proc_res = compile_test(config, props, testfile);
|
||||||
|
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec("compilation failed!".to_string(), &proc_res);
|
fatal_proc_rec("compilation failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_res = exec_compiled_test(config, props, testfile);
|
proc_res = exec_compiled_test(config, props, testfile);
|
||||||
|
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec("test run failed!".to_string(), &proc_res);
|
fatal_proc_rec("test run failed!", &proc_res);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let proc_res = jit_test(config, props, testfile);
|
let proc_res = jit_test(config, props, testfile);
|
||||||
|
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec("jit failed!".to_string(), &proc_res);
|
fatal_proc_rec("jit failed!", &proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +171,8 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
"normal");
|
"normal");
|
||||||
|
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec(format!("pretty-printing failed in round {}", round),
|
fatal_proc_rec(format!("pretty-printing failed in round {}",
|
||||||
|
round).as_slice(),
|
||||||
&proc_res);
|
&proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,22 +204,20 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
let proc_res = typecheck_source(config, props, testfile, actual);
|
let proc_res = typecheck_source(config, props, testfile, actual);
|
||||||
|
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec("pretty-printed source does not typecheck".to_string(),
|
fatal_proc_rec("pretty-printed source does not typecheck", &proc_res);
|
||||||
&proc_res);
|
|
||||||
}
|
}
|
||||||
if props.no_pretty_expanded { return }
|
if props.no_pretty_expanded { return }
|
||||||
|
|
||||||
// additionally, run `--pretty expanded` and try to build it.
|
// additionally, run `--pretty expanded` and try to build it.
|
||||||
let proc_res = print_source(config, props, testfile, (*srcs.get(round)).clone(), "expanded");
|
let proc_res = print_source(config, props, testfile, (*srcs.get(round)).clone(), "expanded");
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec(format!("pretty-printing (expanded) failed"), &proc_res);
|
fatal_proc_rec("pretty-printing (expanded) failed", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
let ProcRes{ stdout: expanded_src, .. } = proc_res;
|
let ProcRes{ stdout: expanded_src, .. } = proc_res;
|
||||||
let proc_res = typecheck_source(config, props, testfile, expanded_src);
|
let proc_res = typecheck_source(config, props, testfile, expanded_src);
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec(format!("pretty-printed source (expanded) does \
|
fatal_proc_rec("pretty-printed source (expanded) does not typecheck",
|
||||||
not typecheck"),
|
|
||||||
&proc_res);
|
&proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,8 +263,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
|
|
||||||
fn compare_source(expected: &str, actual: &str) {
|
fn compare_source(expected: &str, actual: &str) {
|
||||||
if expected != actual {
|
if expected != actual {
|
||||||
error("pretty-printed source does not match expected \
|
error("pretty-printed source does not match expected source");
|
||||||
source".to_string());
|
|
||||||
println!("\n\
|
println!("\n\
|
||||||
expected:\n\
|
expected:\n\
|
||||||
------------------------------------------\n\
|
------------------------------------------\n\
|
||||||
|
@ -328,7 +325,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
// compile test file (it shoud have 'compile-flags:-g' in the header)
|
// compile test file (it shoud have 'compile-flags:-g' in the header)
|
||||||
let compiler_run_result = compile_test(config, props, testfile);
|
let compiler_run_result = compile_test(config, props, testfile);
|
||||||
if !compiler_run_result.status.success() {
|
if !compiler_run_result.status.success() {
|
||||||
fatal_proc_rec("compilation failed!".to_string(), &compiler_run_result);
|
fatal_proc_rec("compilation failed!", &compiler_run_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
let exe_file = make_exe_name(config, testfile);
|
let exe_file = make_exe_name(config, testfile);
|
||||||
|
@ -412,7 +409,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
|
|
||||||
let tool_path = match config.android_cross_path.as_str() {
|
let tool_path = match config.android_cross_path.as_str() {
|
||||||
Some(x) => x.to_string(),
|
Some(x) => x.to_string(),
|
||||||
None => fatal("cannot find android cross path".to_string())
|
None => fatal("cannot find android cross path")
|
||||||
};
|
};
|
||||||
|
|
||||||
let debugger_script = make_out_name(config, testfile, "debugger.script");
|
let debugger_script = make_out_name(config, testfile, "debugger.script");
|
||||||
|
@ -499,7 +496,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !debugger_run_result.status.success() {
|
if !debugger_run_result.status.success() {
|
||||||
fatal("gdb failed to execute".to_string());
|
fatal("gdb failed to execute");
|
||||||
}
|
}
|
||||||
|
|
||||||
check_debugger_output(&debugger_run_result, check_lines.as_slice());
|
check_debugger_output(&debugger_run_result, check_lines.as_slice());
|
||||||
|
@ -509,8 +506,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||||
use std::io::process::{Command, ProcessOutput};
|
use std::io::process::{Command, ProcessOutput};
|
||||||
|
|
||||||
if config.lldb_python_dir.is_none() {
|
if config.lldb_python_dir.is_none() {
|
||||||
fatal("Can't run LLDB test because LLDB's python path is not \
|
fatal("Can't run LLDB test because LLDB's python path is not set.");
|
||||||
set.".to_string());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut config = Config {
|
let mut config = Config {
|
||||||
|
@ -524,7 +520,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||||
// compile test file (it shoud have 'compile-flags:-g' in the header)
|
// compile test file (it shoud have 'compile-flags:-g' in the header)
|
||||||
let compile_result = compile_test(config, props, testfile);
|
let compile_result = compile_test(config, props, testfile);
|
||||||
if !compile_result.status.success() {
|
if !compile_result.status.success() {
|
||||||
fatal_proc_rec("compilation failed!".to_string(), &compile_result);
|
fatal_proc_rec("compilation failed!", &compile_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
let exe_file = make_exe_name(config, testfile);
|
let exe_file = make_exe_name(config, testfile);
|
||||||
|
@ -567,8 +563,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||||
let debugger_run_result = run_lldb(config, &exe_file, &debugger_script);
|
let debugger_run_result = run_lldb(config, &exe_file, &debugger_script);
|
||||||
|
|
||||||
if !debugger_run_result.status.success() {
|
if !debugger_run_result.status.success() {
|
||||||
fatal_proc_rec("Error while running LLDB".to_string(),
|
fatal_proc_rec("Error while running LLDB", &debugger_run_result);
|
||||||
&debugger_run_result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_debugger_output(&debugger_run_result, check_lines.as_slice());
|
check_debugger_output(&debugger_run_result, check_lines.as_slice());
|
||||||
|
@ -592,7 +587,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
fatal(format!("Failed to setup Python process for \
|
fatal(format!("Failed to setup Python process for \
|
||||||
LLDB script: {}", e))
|
LLDB script: {}", e).as_slice())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -633,18 +628,19 @@ fn parse_debugger_commands(file_path: &Path, debugger_prefix: &str)
|
||||||
|
|
||||||
header::parse_name_value_directive(
|
header::parse_name_value_directive(
|
||||||
line.as_slice(),
|
line.as_slice(),
|
||||||
command_directive.to_string()).map(|cmd| {
|
command_directive.as_slice()).map(|cmd| {
|
||||||
commands.push(cmd)
|
commands.push(cmd)
|
||||||
});
|
});
|
||||||
|
|
||||||
header::parse_name_value_directive(
|
header::parse_name_value_directive(
|
||||||
line.as_slice(),
|
line.as_slice(),
|
||||||
check_directive.to_string()).map(|cmd| {
|
check_directive.as_slice()).map(|cmd| {
|
||||||
check_lines.push(cmd)
|
check_lines.push(cmd)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
fatal(format!("Error while parsing debugger commands: {}", e))
|
fatal(format!("Error while parsing debugger commands: {}",
|
||||||
|
e).as_slice())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
counter += 1;
|
counter += 1;
|
||||||
|
@ -672,8 +668,7 @@ fn cleanup_debug_info_options(options: &Option<String>) -> Option<String> {
|
||||||
split_maybe_args(options).move_iter()
|
split_maybe_args(options).move_iter()
|
||||||
.filter(|x| !options_to_remove.contains(x))
|
.filter(|x| !options_to_remove.contains(x))
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.connect(" ")
|
.connect(" ");
|
||||||
.to_string();
|
|
||||||
Some(new_options)
|
Some(new_options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,7 +723,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
|
||||||
}
|
}
|
||||||
if i != num_check_lines {
|
if i != num_check_lines {
|
||||||
fatal_proc_rec(format!("line not found in debugger output: {}",
|
fatal_proc_rec(format!("line not found in debugger output: {}",
|
||||||
check_lines.get(i).unwrap()),
|
check_lines.get(i).unwrap()).as_slice(),
|
||||||
debugger_run_result);
|
debugger_run_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -739,11 +734,11 @@ fn check_error_patterns(props: &TestProps,
|
||||||
proc_res: &ProcRes) {
|
proc_res: &ProcRes) {
|
||||||
if props.error_patterns.is_empty() {
|
if props.error_patterns.is_empty() {
|
||||||
fatal(format!("no error pattern specified in {}",
|
fatal(format!("no error pattern specified in {}",
|
||||||
testfile.display().as_maybe_owned().as_slice()));
|
testfile.display()).as_slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
if proc_res.status.success() {
|
if proc_res.status.success() {
|
||||||
fatal("process did not return an error status".to_string());
|
fatal("process did not return an error status");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut next_err_idx = 0u;
|
let mut next_err_idx = 0u;
|
||||||
|
@ -772,21 +767,21 @@ fn check_error_patterns(props: &TestProps,
|
||||||
props.error_patterns.slice(next_err_idx, props.error_patterns.len());
|
props.error_patterns.slice(next_err_idx, props.error_patterns.len());
|
||||||
if missing_patterns.len() == 1u {
|
if missing_patterns.len() == 1u {
|
||||||
fatal_proc_rec(format!("error pattern '{}' not found!",
|
fatal_proc_rec(format!("error pattern '{}' not found!",
|
||||||
missing_patterns[0]),
|
missing_patterns[0]).as_slice(),
|
||||||
proc_res);
|
proc_res);
|
||||||
} else {
|
} else {
|
||||||
for pattern in missing_patterns.iter() {
|
for pattern in missing_patterns.iter() {
|
||||||
error(format!("error pattern '{}' not found!", *pattern));
|
error(format!("error pattern '{}' not found!",
|
||||||
|
*pattern).as_slice());
|
||||||
}
|
}
|
||||||
fatal_proc_rec("multiple error patterns not found".to_string(),
|
fatal_proc_rec("multiple error patterns not found", proc_res);
|
||||||
proc_res);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_no_compiler_crash(proc_res: &ProcRes) {
|
fn check_no_compiler_crash(proc_res: &ProcRes) {
|
||||||
for line in proc_res.stderr.as_slice().lines() {
|
for line in proc_res.stderr.as_slice().lines() {
|
||||||
if line.starts_with("error: internal compiler error:") {
|
if line.starts_with("error: internal compiler error:") {
|
||||||
fatal_proc_rec("compiler encountered internal error".to_string(),
|
fatal_proc_rec("compiler encountered internal error",
|
||||||
proc_res);
|
proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -801,7 +796,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||||
expected_errors.len(), false);
|
expected_errors.len(), false);
|
||||||
|
|
||||||
if proc_res.status.success() {
|
if proc_res.status.success() {
|
||||||
fatal("process did not return an error status".to_string());
|
fatal("process did not return an error status");
|
||||||
}
|
}
|
||||||
|
|
||||||
let prefixes = expected_errors.iter().map(|ee| {
|
let prefixes = expected_errors.iter().map(|ee| {
|
||||||
|
@ -865,7 +860,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||||
|
|
||||||
if !was_expected && is_compiler_error_or_warning(line) {
|
if !was_expected && is_compiler_error_or_warning(line) {
|
||||||
fatal_proc_rec(format!("unexpected compiler error or warning: '{}'",
|
fatal_proc_rec(format!("unexpected compiler error or warning: '{}'",
|
||||||
line),
|
line).as_slice(),
|
||||||
proc_res);
|
proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -874,7 +869,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||||
if !flag {
|
if !flag {
|
||||||
let ee = expected_errors.get(i);
|
let ee = expected_errors.get(i);
|
||||||
fatal_proc_rec(format!("expected {} on line {} not found: {}",
|
fatal_proc_rec(format!("expected {} on line {} not found: {}",
|
||||||
ee.kind, ee.line, ee.msg),
|
ee.kind, ee.line, ee.msg).as_slice(),
|
||||||
proc_res);
|
proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1059,7 +1054,7 @@ fn compose_and_run_compiler(
|
||||||
if !auxres.status.success() {
|
if !auxres.status.success() {
|
||||||
fatal_proc_rec(
|
fatal_proc_rec(
|
||||||
format!("auxiliary build of {} failed to compile: ",
|
format!("auxiliary build of {} failed to compile: ",
|
||||||
abs_ab.display()),
|
abs_ab.display()).as_slice(),
|
||||||
&auxres);
|
&auxres);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1296,11 +1291,11 @@ fn maybe_dump_to_stdout(config: &Config, out: &str, err: &str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn error(err: String) { println!("\nerror: {}", err); }
|
fn error(err: &str) { println!("\nerror: {}", err); }
|
||||||
|
|
||||||
fn fatal(err: String) -> ! { error(err); fail!(); }
|
fn fatal(err: &str) -> ! { error(err); fail!(); }
|
||||||
|
|
||||||
fn fatal_proc_rec(err: String, proc_res: &ProcRes) -> ! {
|
fn fatal_proc_rec(err: &str, proc_res: &ProcRes) -> ! {
|
||||||
print!("\n\
|
print!("\n\
|
||||||
error: {}\n\
|
error: {}\n\
|
||||||
status: {}\n\
|
status: {}\n\
|
||||||
|
@ -1573,44 +1568,44 @@ fn run_codegen_test(config: &Config, props: &TestProps,
|
||||||
testfile: &Path, mm: &mut MetricMap) {
|
testfile: &Path, mm: &mut MetricMap) {
|
||||||
|
|
||||||
if config.llvm_bin_path.is_none() {
|
if config.llvm_bin_path.is_none() {
|
||||||
fatal("missing --llvm-bin-path".to_string());
|
fatal("missing --llvm-bin-path");
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.clang_path.is_none() {
|
if config.clang_path.is_none() {
|
||||||
fatal("missing --clang-path".to_string());
|
fatal("missing --clang-path");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut proc_res = compile_test_and_save_bitcode(config, props, testfile);
|
let mut proc_res = compile_test_and_save_bitcode(config, props, testfile);
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec("compilation failed!".to_string(), &proc_res);
|
fatal_proc_rec("compilation failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_res = extract_function_from_bitcode(config, props, "test", testfile, "");
|
proc_res = extract_function_from_bitcode(config, props, "test", testfile, "");
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec("extracting 'test' function failed".to_string(),
|
fatal_proc_rec("extracting 'test' function failed",
|
||||||
&proc_res);
|
&proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_res = disassemble_extract(config, props, testfile, "");
|
proc_res = disassemble_extract(config, props, testfile, "");
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec("disassembling extract failed".to_string(), &proc_res);
|
fatal_proc_rec("disassembling extract failed", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let mut proc_res = compile_cc_with_clang_and_save_bitcode(config, props, testfile);
|
let mut proc_res = compile_cc_with_clang_and_save_bitcode(config, props, testfile);
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec("compilation failed!".to_string(), &proc_res);
|
fatal_proc_rec("compilation failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_res = extract_function_from_bitcode(config, props, "test", testfile, "clang");
|
proc_res = extract_function_from_bitcode(config, props, "test", testfile, "clang");
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec("extracting 'test' function failed".to_string(),
|
fatal_proc_rec("extracting 'test' function failed",
|
||||||
&proc_res);
|
&proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_res = disassemble_extract(config, props, testfile, "clang");
|
proc_res = disassemble_extract(config, props, testfile, "clang");
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
fatal_proc_rec("disassembling extract failed".to_string(), &proc_res);
|
fatal_proc_rec("disassembling extract failed", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
let base = output_base_name(config, testfile);
|
let base = output_base_name(config, testfile);
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub fn make_new_path(path: &str) -> String {
|
||||||
|
|
||||||
// Windows just uses PATH as the library search path, so we have to
|
// Windows just uses PATH as the library search path, so we have to
|
||||||
// maintain the current value while adding our own
|
// maintain the current value while adding our own
|
||||||
match getenv(lib_path_env_var().as_slice()) {
|
match getenv(lib_path_env_var()) {
|
||||||
Some(curr) => {
|
Some(curr) => {
|
||||||
format!("{}{}{}", path, path_div(), curr)
|
format!("{}{}{}", path, path_div(), curr)
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,10 @@ pub fn make_new_path(path: &str) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "win32")]
|
#[cfg(target_os = "win32")]
|
||||||
pub fn lib_path_env_var() -> String { "PATH".to_string() }
|
pub fn lib_path_env_var() -> &'static str { "PATH" }
|
||||||
|
|
||||||
#[cfg(target_os = "win32")]
|
#[cfg(target_os = "win32")]
|
||||||
pub fn path_div() -> String { ";".to_string() }
|
pub fn path_div() -> &'static str { ";" }
|
||||||
|
|
||||||
pub fn logv(config: &Config, s: String) {
|
pub fn logv(config: &Config, s: String) {
|
||||||
debug!("{}", s);
|
debug!("{}", s);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue