diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-09-12 09:36:51 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-09-12 09:36:51 -0700 |
| commit | 393deeb06ff8017a93b0fd26c1f6968fdff2b15b (patch) | |
| tree | 3dacb71e604095ec94a8f350f44467b7640f289d /src/test | |
| parent | edde2e0c457de6e5d17373bfa90ef319df4a1566 (diff) | |
| parent | 6ffcfba6b990d6f27243e4dd6ddfffab141e1f44 (diff) | |
| download | rust-393deeb06ff8017a93b0fd26c1f6968fdff2b15b.tar.gz rust-393deeb06ff8017a93b0fd26c1f6968fdff2b15b.zip | |
Merge branch 'unwind'
Conflicts: src/comp/middle/trans.rs src/comp/middle/trans_build.rs src/lib/run_program.rs src/test/compiletest/runtest.rs
Diffstat (limited to 'src/test')
31 files changed, 268 insertions, 32 deletions
diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 92da06f186a..aa8786f8d61 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -1,3 +1,4 @@ +// xfail-test // based on: // http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody&lang=java diff --git a/src/test/compiletest/compiletest.rs b/src/test/compiletest/compiletest.rs index 03bc0e72cc7..0961191918b 100644 --- a/src/test/compiletest/compiletest.rs +++ b/src/test/compiletest/compiletest.rs @@ -110,8 +110,9 @@ fn run_tests(config: config) { let opts = test_opts(config); let cx = {config: config, procsrv: procsrv::mk()}; let tests = make_tests(cx); - test::run_tests_console_(opts, tests.tests, tests.to_task); + let res = test::run_tests_console_(opts, tests.tests, tests.to_task); procsrv::close(cx.procsrv); + if !res { fail "Some tests failed"; } } fn test_opts(config: config) -> test::test_opts { diff --git a/src/test/compiletest/header.rs b/src/test/compiletest/header.rs index 9f896c48e74..890818d4574 100644 --- a/src/test/compiletest/header.rs +++ b/src/test/compiletest/header.rs @@ -16,10 +16,7 @@ type test_props = { compile_flags: option::t<str>, // If present, the name of a file that this test should match when // pretty-printed - pp_exact: option::t<str>, - // FIXME: no-valgrind is a temporary directive until all of run-fail - // is valgrind-clean - no_valgrind: bool + pp_exact: option::t<str> }; // Load any test directives embedded in the file @@ -27,7 +24,6 @@ fn load_props(testfile: str) -> test_props { let error_patterns = []; let compile_flags = option::none; let pp_exact = option::none; - let no_valgrind = false; for each ln: str in iter_header(testfile) { alt parse_error_pattern(ln) { option::some(ep) { error_patterns += [ep]; } @@ -41,16 +37,11 @@ fn load_props(testfile: str) -> test_props { if option::is_none(pp_exact) { pp_exact = parse_pp_exact(ln, testfile); } - - if no_valgrind == false { - no_valgrind = parse_name_directive(ln, "no-valgrind"); - } } ret { error_patterns: error_patterns, compile_flags: compile_flags, - pp_exact: pp_exact, - no_valgrind: no_valgrind + pp_exact: pp_exact }; } @@ -59,11 +50,16 @@ fn is_test_ignored(config: config, testfile: str) -> bool { for each ln: str in iter_header(testfile) { // FIXME: Can't return or break from iterator found = found || parse_name_directive(ln, "xfail-test"); + found = found || parse_name_directive(ln, xfail_target()); if (config.mode == common::mode_pretty) { found = found || parse_name_directive(ln, "xfail-pretty"); } } ret found; + + fn xfail_target() -> str { + "xfail-" + std::os::target_os() + } } iter iter_header(testfile: str) -> str { diff --git a/src/test/compiletest/procsrv.rs b/src/test/compiletest/procsrv.rs index ae98853976e..6a40aaccaf4 100644 --- a/src/test/compiletest/procsrv.rs +++ b/src/test/compiletest/procsrv.rs @@ -66,7 +66,7 @@ fn run(handle: handle, lib_path: str, prog: str, args: [str], writeclose(resp.infd, input); let output = readclose(resp.outfd); let errput = readclose(resp.errfd); - let status = os::waitpid(resp.pid); + let status = run::waitpid(resp.pid); ret {status: status, out: output, err: errput}; } diff --git a/src/test/compiletest/runtest.rs b/src/test/compiletest/runtest.rs index 8ed938094c9..46b74e799f4 100644 --- a/src/test/compiletest/runtest.rs +++ b/src/test/compiletest/runtest.rs @@ -51,19 +51,21 @@ fn run_rfail_test(cx: cx, props: test_props, testfile: str) { procres = exec_compiled_test(cx, props, testfile); - if procres.status == 0 { - fatal_procres("run-fail test didn't produce an error!", 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; + // The value our Makefile configures valgrind to return on failure + const valgrind_err: int = 100; if procres.status == valgrind_err { fatal_procres("run-fail test isn't valgrind-clean!", procres); } + // The value the rust runtime returns on failure + const rust_err: int = 101; + if procres.status != rust_err { + fatal_procres( + #fmt("run-fail test produced the wrong error code: %d", + procres.status), + procres); + } + check_error_patterns(props, testfile, procres); } @@ -251,10 +253,9 @@ fn make_exe_name(config: config, testfile: str) -> str { output_base_name(config, testfile) + os::exec_suffix() } -fn make_run_args(config: config, props: test_props, testfile: str) -> +fn make_run_args(config: config, _props: test_props, testfile: str) -> procargs { - let toolargs = - if !props.no_valgrind { + let toolargs = { // If we've got another tool to run under (valgrind), // then split apart its command let runtool = @@ -263,7 +264,7 @@ fn make_run_args(config: config, props: test_props, testfile: str) -> option::none. { option::none } }; split_maybe_args(runtool) - } else { [] }; + }; let args = toolargs + [make_exe_name(config, testfile)]; ret {prog: args[0], args: vec::slice(args, 1u, vec::len(args))}; diff --git a/src/test/run-fail/explicit-fail-msg.rs b/src/test/run-fail/explicit-fail-msg.rs index b45e443759c..527a103e342 100644 --- a/src/test/run-fail/explicit-fail-msg.rs +++ b/src/test/run-fail/explicit-fail-msg.rs @@ -1,3 +1,2 @@ // error-pattern:wooooo -// no-valgrind fn main() { let a = 1; if 1 == 1 { a = 2; } fail "woooo" + "o"; } diff --git a/src/test/run-fail/fmt-fail.rs b/src/test/run-fail/fmt-fail.rs index 90256271fd2..5ca0ab74147 100644 --- a/src/test/run-fail/fmt-fail.rs +++ b/src/test/run-fail/fmt-fail.rs @@ -1,5 +1,4 @@ // error-pattern:meh -// no-valgrind use std; fn main() { let str_var: str = "meh"; fail #fmt["%s", str_var]; } diff --git a/src/test/run-fail/linked-failure.rs b/src/test/run-fail/linked-failure.rs index 033a3bc9ec2..24cfff6edb5 100644 --- a/src/test/run-fail/linked-failure.rs +++ b/src/test/run-fail/linked-failure.rs @@ -1,8 +1,7 @@ // -*- rust -*- // error-pattern:1 == 2 -// no-valgrind - +// xfail-test use std; import std::task; import std::comm::port; diff --git a/src/test/run-fail/unwind-assert.rs b/src/test/run-fail/unwind-assert.rs new file mode 100644 index 00000000000..e7aeedcf505 --- /dev/null +++ b/src/test/run-fail/unwind-assert.rs @@ -0,0 +1,6 @@ +// error-pattern:fail + +fn main() { + let a = @0; + assert false; +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-box.rs b/src/test/run-fail/unwind-box.rs new file mode 100644 index 00000000000..19906bda0ae --- /dev/null +++ b/src/test/run-fail/unwind-box.rs @@ -0,0 +1,10 @@ +// error-pattern:fail + +fn failfn() { + fail; +} + +fn main() { + @0; + failfn(); +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-check.rs b/src/test/run-fail/unwind-check.rs new file mode 100644 index 00000000000..e01cc969cea --- /dev/null +++ b/src/test/run-fail/unwind-check.rs @@ -0,0 +1,8 @@ +// error-pattern:fail + +pure fn p(a: @int) -> bool { false } + +fn main() { + let a = @0; + check p(a); +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-closure.rs b/src/test/run-fail/unwind-closure.rs new file mode 100644 index 00000000000..216ae054947 --- /dev/null +++ b/src/test/run-fail/unwind-closure.rs @@ -0,0 +1,10 @@ +// error-pattern:fail + +fn f(a: @int) { + fail; +} + +fn main() { + let g = bind f(@0); + g(); +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-fail.rs b/src/test/run-fail/unwind-fail.rs new file mode 100644 index 00000000000..2d4f138e715 --- /dev/null +++ b/src/test/run-fail/unwind-fail.rs @@ -0,0 +1,6 @@ +// error-pattern:fail + +fn main() { + @0; + fail; +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-initializer-indirect.rs b/src/test/run-fail/unwind-initializer-indirect.rs new file mode 100644 index 00000000000..726dc3d9040 --- /dev/null +++ b/src/test/run-fail/unwind-initializer-indirect.rs @@ -0,0 +1,7 @@ +// error-pattern:fail + +fn f() -> @int { fail; } + +fn main() { + let a: @int = f(); +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-initializer.rs b/src/test/run-fail/unwind-initializer.rs new file mode 100644 index 00000000000..b3dc0d3eaeb --- /dev/null +++ b/src/test/run-fail/unwind-initializer.rs @@ -0,0 +1,7 @@ +// error-pattern:fail + +fn main() { + let a: @int = { + fail; + }; +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-iter.rs b/src/test/run-fail/unwind-iter.rs new file mode 100644 index 00000000000..fa64b0ad78c --- /dev/null +++ b/src/test/run-fail/unwind-iter.rs @@ -0,0 +1,12 @@ +// error-pattern:fail + +iter x() -> int { + fail; + put 0; +} + +fn main() { + let a = @0; + for each x in x() { + } +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-iter2.rs b/src/test/run-fail/unwind-iter2.rs new file mode 100644 index 00000000000..a924bb13616 --- /dev/null +++ b/src/test/run-fail/unwind-iter2.rs @@ -0,0 +1,12 @@ +// error-pattern:fail + +iter x() -> int { + let a = @0; + put 1; +} + +fn main() { + for each x in x() { + fail; + } +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs new file mode 100644 index 00000000000..6980cc16bd1 --- /dev/null +++ b/src/test/run-fail/unwind-lambda.rs @@ -0,0 +1,16 @@ +// error-pattern:fail + +fn main() { + let cheese = "roquefort"; + let carrots = @"crunchy"; + + fn (tasties: @str, macerate: block(str)) { + macerate(*tasties); + } (carrots, { |food| + let mush = food + cheese; + lambda() { + let chew = mush + cheese; + fail "so yummy" + } (); + }); +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs new file mode 100644 index 00000000000..15d433ae363 --- /dev/null +++ b/src/test/run-fail/unwind-misc-1.rs @@ -0,0 +1,28 @@ +// error-pattern:fail + +use std; +import std::map; +import std::uint; + +fn main() { + let count = @mutable 0u; + let hash = bind fn (_s: [@str], count: @mutable uint) -> uint { + *count += 1u; + if *count == 10u { + fail; + } else { + ret *count; + } + } (_, count); + + fn eq(s: [@str], t: [@str]) -> bool { + ret s == t; + } + + let map = map::mk_hashmap(hash, eq); + let arr = []; + for each i in uint::range(0u, 10u) { + arr += [@"key stuff"]; + map.insert(arr, arr + [@"value stuff"]); + } +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-nested.rs b/src/test/run-fail/unwind-nested.rs new file mode 100644 index 00000000000..48e3063c6dd --- /dev/null +++ b/src/test/run-fail/unwind-nested.rs @@ -0,0 +1,11 @@ +// error-pattern:fail + +fn main() { + let a = @0; + { + let b = @0; + { + fail; + } + } +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-resource-fail.rs b/src/test/run-fail/unwind-resource-fail.rs new file mode 100644 index 00000000000..4ab8dc95085 --- /dev/null +++ b/src/test/run-fail/unwind-resource-fail.rs @@ -0,0 +1,12 @@ +// error-pattern:fail +// xfail-test + +resource r(i: int) { + // What happens when destructors throw? + fail; +} + +fn main() { + @0; + let r <- r(0); +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-stacked.rs b/src/test/run-fail/unwind-stacked.rs new file mode 100644 index 00000000000..bf5258cee7d --- /dev/null +++ b/src/test/run-fail/unwind-stacked.rs @@ -0,0 +1,16 @@ +// error-pattern:fail + +fn f() { + let a = @0; + fail; +} + +fn g() { + let b = @0; + f(); +} + +fn main() { + let a = @0; + g(); +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-uninitialized.rs b/src/test/run-fail/unwind-uninitialized.rs new file mode 100644 index 00000000000..35269b38714 --- /dev/null +++ b/src/test/run-fail/unwind-uninitialized.rs @@ -0,0 +1,10 @@ +// error-pattern:fail + +fn f() { + fail; +} + +fn main() { + f(); + let a = @0; +} \ No newline at end of file diff --git a/src/test/run-fail/vec-overrun.rs b/src/test/run-fail/vec-overrun.rs index 54329ca63b5..7a429e08cae 100644 --- a/src/test/run-fail/vec-overrun.rs +++ b/src/test/run-fail/vec-overrun.rs @@ -1,7 +1,6 @@ // -*- rust -*- // error-pattern:bounds check -// no-valgrind fn main() { let v: [int] = [10]; let x: int = 0; diff --git a/src/test/run-fail/vec-underrun.rs b/src/test/run-fail/vec-underrun.rs index 87c8295840e..9caf82d1ae0 100644 --- a/src/test/run-fail/vec-underrun.rs +++ b/src/test/run-fail/vec-underrun.rs @@ -1,7 +1,6 @@ // -*- rust -*- // error-pattern:bounds check -// no-valgrind fn main() { let v: [int] = [10, 20]; let x: int = 0; diff --git a/src/test/run-pass/native-llvm.rs b/src/test/run-pass/native-llvm.rs new file mode 100644 index 00000000000..450f052bc62 --- /dev/null +++ b/src/test/run-pass/native-llvm.rs @@ -0,0 +1,10 @@ +// xfail-test + +native "llvm" mod llvm { + fn thesqrt(n: float) -> float = "sqrt.f64"; +} + +fn main() { + let s = llvm::thesqrt(4.0); + assert 1.9 < s && s < 2.1; +} \ No newline at end of file diff --git a/src/test/run-pass/task-comm-15.rs b/src/test/run-pass/task-comm-15.rs index 2b89d8fde38..56cf41b50c3 100644 --- a/src/test/run-pass/task-comm-15.rs +++ b/src/test/run-pass/task-comm-15.rs @@ -1,3 +1,4 @@ +// xfail-win32 use std; import std::comm; import std::task; diff --git a/src/test/run-pass/unwind-box.rs b/src/test/run-pass/unwind-box.rs new file mode 100644 index 00000000000..0c4f1e4616c --- /dev/null +++ b/src/test/run-pass/unwind-box.rs @@ -0,0 +1,14 @@ +// xfail-win32 +use std; +import std::task; + +fn f() { + task::unsupervise(); + let a = @0; + fail; +} + +fn main() { + let g = f; + task::spawn(g); +} \ No newline at end of file diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs new file mode 100644 index 00000000000..e8cf0bab44f --- /dev/null +++ b/src/test/run-pass/unwind-resource.rs @@ -0,0 +1,21 @@ +// xfail-win32 +use std; +import std::task; +import std::comm; + +resource complainer(c: comm::chan<bool>) { + comm::send(c, true); +} + +fn f(-c: comm::chan<bool>) { + task::unsupervise(); + let c <- complainer(c); + fail; +} + +fn main() { + let p = comm::port(); + let c = comm::chan(p); + task::spawn(bind f(c)); + assert comm::recv(p); +} \ No newline at end of file diff --git a/src/test/run-pass/unwind-resource2.rs b/src/test/run-pass/unwind-resource2.rs new file mode 100644 index 00000000000..1d7a46151fc --- /dev/null +++ b/src/test/run-pass/unwind-resource2.rs @@ -0,0 +1,18 @@ +// xfail-win32 +use std; +import std::task; +import std::comm; + +resource complainer(c: @int) { +} + +fn f() { + task::unsupervise(); + let c <- complainer(@0); + fail; +} + +fn main() { + let g = f; + task::spawn(g); +} \ No newline at end of file diff --git a/src/test/stdtest/run.rs b/src/test/stdtest/run.rs index 218889c766b..e5c36d37041 100644 --- a/src/test/stdtest/run.rs +++ b/src/test/stdtest/run.rs @@ -65,3 +65,10 @@ fn test_pipes() { ret buf; } } + +#[test] +fn waitpid() { + let pid = run::spawn_process("false", [], 0, 0, 0); + let status = run::waitpid(pid); + assert status == 1; +} |
