Error if we should be able to Valgrind but can't

This commit is contained in:
Nick Cameron 2014-10-09 12:11:37 +13:00
parent 1285d4f467
commit 80ff1d1a10
7 changed files with 50 additions and 22 deletions

View file

@ -76,6 +76,10 @@ pub struct Config {
// The valgrind path
pub valgrind_path: Option<String>,
// Whether to fail if we can't run run-pass-valgrind tests under valgrind
// (or, alternatively, to silently run them like regular run-pass tests).
pub force_valgrind: bool,
// The directory containing the tests to run
pub src_base: Path,

View file

@ -39,6 +39,11 @@ pub mod errors;
pub fn main() {
let args = os::args();
let config = parse_config(args);
if config.valgrind_path.is_none() && config.force_valgrind {
fail!("Can't find Valgrind to run Valgrind tests");
}
log_config(&config);
run_tests(&config);
}
@ -50,7 +55,8 @@ pub fn parse_config(args: Vec<String> ) -> Config {
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
optopt("", "clang-path", "path to executable for codegen tests", "PATH"),
optopt("", "valgrind-path", "path to valgrind executable for valgrind tests", "PROGRAM"),
optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM"),
optflag("", "force-valgrind", "fail if Valgrind tests cannot be run under Valgrind"),
optopt("", "llvm-bin-path", "path to directory holding llvm binaries", "DIR"),
reqopt("", "src-base", "directory to scan for test files", "PATH"),
reqopt("", "build-base", "directory to deposit test outputs", "PATH"),
@ -127,6 +133,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
rustc_path: opt_path(matches, "rustc-path"),
clang_path: matches.opt_str("clang-path").map(|s| Path::new(s)),
valgrind_path: matches.opt_str("valgrind-path"),
force_valgrind: matches.opt_present("force-valgrind"),
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::new(s)),
src_base: opt_path(matches, "src-base"),
build_base: opt_path(matches, "build-base"),
@ -164,7 +171,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
!opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
lldb_python_dir: matches.opt_str("lldb-python-dir"),
test_shard: test::opt_shard(matches.opt_str("test-shard")),
verbose: matches.opt_present("verbose")
verbose: matches.opt_present("verbose"),
}
}

View file

@ -166,6 +166,7 @@ fn run_rpass_test(config: &Config, props: &TestProps, testfile: &Path) {
fn run_valgrind_test(config: &Config, props: &TestProps, testfile: &Path) {
if config.valgrind_path.is_none() {
assert!(!config.force_valgrind);
return run_rpass_test(config, props, testfile);
}
@ -175,7 +176,6 @@ fn run_valgrind_test(config: &Config, props: &TestProps, testfile: &Path) {
fatal_proc_rec("compilation failed!", &proc_res);
}
println!("running valgrind");
let mut new_config = config.clone();
new_config.runtool = new_config.valgrind_path.clone();
proc_res = exec_compiled_test(&new_config, props, testfile);