提交 40ae704f 编写于 作者: B Brian Anderson

Begin valgrinding run-fail tests

Introduce a temporary no-valgrind directive for the few that aren't clean
上级 0cd607bc
...@@ -185,11 +185,11 @@ CFAIL_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \ ...@@ -185,11 +185,11 @@ CFAIL_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
--build-base test/compile-fail/ \ --build-base test/compile-fail/ \
--mode compile-fail \ --mode compile-fail \
# FIXME (236): run-fail should run under valgrind once unwinding works
RFAIL_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \ RFAIL_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
--src-base $$(S)src/test/run-fail/ \ --src-base $$(S)src/test/run-fail/ \
--build-base test/run-fail/ \ --build-base test/run-fail/ \
--mode run-fail \ --mode run-fail \
$$(CTEST_RUNTOOL) \
RPASS_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \ RPASS_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
--src-base $(S)src/test/run-pass/ \ --src-base $(S)src/test/run-pass/ \
......
...@@ -16,7 +16,10 @@ ...@@ -16,7 +16,10 @@
compile_flags: option::t[str], compile_flags: option::t[str],
// If present, the name of a file that this test should match when // If present, the name of a file that this test should match when
// pretty-printed // pretty-printed
pp_exact: option::t[str] pp_exact: option::t[str],
// FIXME: no-valgrind is a temporary directive until all of run-fail
// is valgrind-clean
no_valgrind: bool
}; };
// Load any test directives embedded in the file // Load any test directives embedded in the file
...@@ -24,6 +27,7 @@ fn load_props(testfile: &str) -> test_props { ...@@ -24,6 +27,7 @@ fn load_props(testfile: &str) -> test_props {
let error_patterns = ~[]; let error_patterns = ~[];
let compile_flags = option::none; let compile_flags = option::none;
let pp_exact = option::none; let pp_exact = option::none;
let no_valgrind = false;
for each ln: str in iter_header(testfile) { for each ln: str in iter_header(testfile) {
alt parse_error_pattern(ln) { alt parse_error_pattern(ln) {
option::some(ep) { error_patterns += ~[ep]; } option::some(ep) { error_patterns += ~[ep]; }
...@@ -37,11 +41,16 @@ fn load_props(testfile: &str) -> test_props { ...@@ -37,11 +41,16 @@ fn load_props(testfile: &str) -> test_props {
if option::is_none(pp_exact) { if option::is_none(pp_exact) {
pp_exact = parse_pp_exact(ln, testfile); pp_exact = parse_pp_exact(ln, testfile);
} }
if no_valgrind == false {
no_valgrind = parse_name_directive(ln, "no-valgrind");
}
} }
ret { ret {
error_patterns: error_patterns, error_patterns: error_patterns,
compile_flags: compile_flags, compile_flags: compile_flags,
pp_exact: pp_exact pp_exact: pp_exact,
no_valgrind: no_valgrind
}; };
} }
......
...@@ -53,13 +53,22 @@ fn run_rfail_test(cx: &cx, props: &test_props, testfile: &str) { ...@@ -53,13 +53,22 @@ fn run_rfail_test(cx: &cx, props: &test_props, testfile: &str) {
if procres.status != 0 { if procres.status != 0 {
fatal_procres("compilation failed!", procres); } fatal_procres("compilation failed!", procres); }
procres = exec_compiled_test(cx, testfile); procres = exec_compiled_test(cx, props, testfile);
if procres.status == 0 { if procres.status == 0 {
fatal_procres("run-fail test didn't produce an error!", fatal_procres("run-fail test didn't produce an error!",
procres); procres);
} }
// This is the value valgrind returns on failure
// FIXME: Why is this value neither the value we pass to
// valgrind as --error-exitcode (1), nor the value we see as the
// exit code on the command-line (137)?
const valgrind_err: int = 9;
if procres.status == valgrind_err {
fatal_procres("run-fail test isn't valgrind-clean!", procres);
}
check_error_patterns(props, testfile, procres); check_error_patterns(props, testfile, procres);
} }
...@@ -69,7 +78,7 @@ fn run_rpass_test(cx: &cx, props: &test_props, testfile: &str) { ...@@ -69,7 +78,7 @@ fn run_rpass_test(cx: &cx, props: &test_props, testfile: &str) {
if procres.status != 0 { if procres.status != 0 {
fatal_procres("compilation failed!", procres); } fatal_procres("compilation failed!", procres); }
procres = exec_compiled_test(cx, testfile); procres = exec_compiled_test(cx, props, testfile);
if procres.status != 0 { fatal_procres("test run failed!", procres); } if procres.status != 0 { fatal_procres("test run failed!", procres); }
...@@ -219,8 +228,9 @@ fn compile_test(cx: &cx, props: &test_props, testfile: &str) -> procres { ...@@ -219,8 +228,9 @@ fn compile_test(cx: &cx, props: &test_props, testfile: &str) -> procres {
cx.config.compile_lib_path, option::none) cx.config.compile_lib_path, option::none)
} }
fn exec_compiled_test(cx: &cx, testfile: &str) -> procres { fn exec_compiled_test(cx: &cx, props: &test_props,
compose_and_run(cx, testfile, make_run_args, testfile: &str) -> procres {
compose_and_run(cx, testfile, bind make_run_args(_, props, _),
cx.config.run_lib_path, option::none) cx.config.run_lib_path, option::none)
} }
...@@ -248,12 +258,17 @@ fn make_exe_name(config: &config, testfile: &str) -> str { ...@@ -248,12 +258,17 @@ fn make_exe_name(config: &config, testfile: &str) -> str {
output_base_name(config, testfile) + os::exec_suffix() output_base_name(config, testfile) + os::exec_suffix()
} }
fn make_run_args(config: &config, testfile: &str) -> procargs { fn make_run_args(config: &config,
// If we've got another tool to run under (valgrind), props: &test_props, testfile: &str) -> procargs {
// then split apart its command let toolargs = if !props.no_valgrind {
let args = // If we've got another tool to run under (valgrind),
// then split apart its command
split_maybe_args(config.runtool) split_maybe_args(config.runtool)
+ [make_exe_name(config, testfile)]; } else {
[]
};
let args = toolargs + [make_exe_name(config, testfile)];
ret {prog: args.(0), args: vec::slice(args, 1u, vec::len(args))}; ret {prog: args.(0), args: vec::slice(args, 1u, vec::len(args))};
} }
......
// error-pattern:wooooo // error-pattern:wooooo
// no-valgrind
fn main() { let a = 1; if 1 == 1 { a = 2; } fail "woooo" + "o"; } fn main() { let a = 1; if 1 == 1 { a = 2; } fail "woooo" + "o"; }
\ No newline at end of file
// error-pattern:meh // error-pattern:meh
// no-valgrind
use std; use std;
import std::str; import std::str;
......
// -*- rust -*- // -*- rust -*-
// error-pattern:1 == 2 // error-pattern:1 == 2
// no-valgrind
fn child() { assert (1 == 2); } fn child() { assert (1 == 2); }
......
// -*- rust -*- // -*- rust -*-
// error-pattern:bounds check // error-pattern:bounds check
// no-valgrind
fn main() { fn main() {
let v: vec[int] = [10]; let v: vec[int] = [10];
let x: int = 0; let x: int = 0;
......
// -*- rust -*- // -*- rust -*-
// error-pattern:bounds check // error-pattern:bounds check
// no-valgrind
fn main() { fn main() {
let v: vec[int] = [10, 20]; let v: vec[int] = [10, 20];
let x: int = 0; let x: int = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册