Add a huge hack to allow the test runner to continue if a single task leaks

This is just until unwinding works. Adds a flag to the runtime to turn
the memory leak checks on task destruction into warnings instead of fatal
errors. I am so sorry.

Issue #428
This commit is contained in:
Brian Anderson
2011-07-19 23:33:37 -07:00
parent 3fb33008ce
commit a467e8e4e6
5 changed files with 39 additions and 1 deletions

View File

@@ -227,12 +227,26 @@ fn run_test(&test_desc test) -> test_result {
}
}
native "rust" mod rustrt {
fn hack_allow_leaks();
}
// We need to run our tests in another task in order to trap test failures.
// But, at least currently, functions can't be used as spawn arguments so
// we've got to treat our test functions as unsafe pointers.
fn run_test_fn_in_task(&fn() f) -> bool {
fn run_task(*mutable fn() fptr) {
// If this task fails we don't want that failure to propagate to the
// test runner or else we couldn't keep running tests
task::unsupervise();
// FIXME (236): Hack supreme - unwinding doesn't work yet so if this
// task fails memory will not be freed correctly. This turns off the
// sanity checks in the runtime's memory region for the task, so that
// the test runner can continue.
rustrt::hack_allow_leaks();
// Run the test
(*fptr)()
}
auto fptr = ptr::addr_of(f);