Skip to content

Commit ad598eb

Browse files
committed
Use the new task join methods in the test runner. Closes #826
It should report failures properly again
1 parent 15f9f1a commit ad598eb

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

src/lib/test.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export parse_opts;
2424
export test_to_task;
2525
export default_test_to_task;
2626
export configure_test_task;
27+
export joinable;
2728

2829
native "rust" mod rustrt {
2930
fn hack_allow_leaks();
@@ -90,11 +91,13 @@ fn parse_opts(args: &[str]) : vec::is_not_empty(args) -> opt_res {
9091

9192
tag test_result { tr_ok; tr_failed; tr_ignored; }
9293

94+
type joinable = (task_id, comm::port<task::task_notification>);
95+
9396
// To get isolation and concurrency tests have to be run in their own tasks.
9497
// In cases where test functions and closures it is not ok to just dump them
9598
// into a task and run them, so this transformation gives the caller a chance
9699
// to create the test task.
97-
type test_to_task = fn(&fn()) -> task_id ;
100+
type test_to_task = fn(&fn()) -> joinable;
98101

99102
// A simple console test runner
100103
fn run_tests_console(opts: &test_opts, tests: &[test_desc]) -> bool {
@@ -312,8 +315,8 @@ fn run_test(test: &test_desc, to_task: &test_to_task) -> test_future {
312315
let test_task = to_task(test.fn);
313316
ret {test: test,
314317
wait:
315-
bind fn (test_task: task_id) -> test_result {
316-
alt task::join_id(test_task) {
318+
bind fn (test_task: joinable)-> test_result {
319+
alt task::join(test_task) {
317320
task::tr_success. { tr_ok }
318321
task::tr_failure. { tr_failed }
319322
}
@@ -326,12 +329,12 @@ fn run_test(test: &test_desc, to_task: &test_to_task) -> test_future {
326329

327330
// We need to run our tests in another task in order to trap test failures.
328331
// This function only works with functions that don't contain closures.
329-
fn default_test_to_task(f: &fn()) -> task_id {
332+
fn default_test_to_task(f: &fn()) -> joinable {
330333
fn run_task(f: fn()) {
331334
configure_test_task();
332335
f();
333336
}
334-
ret task::spawn(bind run_task(f));
337+
ret task::spawn_joinable(bind run_task(f));
335338
}
336339

337340
// Call from within a test task to make sure it's set up correctly

src/test/compiletest/compiletest.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn test_opts(config: &config) -> test::test_opts {
121121
}
122122

123123
type tests_and_conv_fn =
124-
{tests: [test::test_desc], to_task: fn(&fn() ) -> task_id };
124+
{tests: [test::test_desc], to_task: fn(&fn() ) -> test::joinable };
125125

126126
fn make_tests(cx: &cx) -> tests_and_conv_fn {
127127
log #fmt("making tests from %s", cx.config.src_base);
@@ -207,18 +207,26 @@ break up the config record and pass everything individually to the spawned
207207
function.
208208
*/
209209

210-
fn closure_to_task(cx: cx, configport: _port<[u8]>, testfn: &fn() ) -> task_id
210+
fn closure_to_task(cx: cx, configport: _port<[u8]>, testfn: &fn() )
211+
-> test::joinable
211212
{
212213
testfn();
213214
let testfile = configport.recv();
214-
ret task::_spawn(bind run_test_task(cx.config.compile_lib_path,
215-
cx.config.run_lib_path, cx.config.rustc_path,
216-
cx.config.src_base, cx.config.build_base,
217-
cx.config.stage_id, mode_str(cx.config.mode),
218-
cx.config.run_ignored, opt_str(cx.config.filter),
219-
opt_str(cx.config.runtool),
220-
opt_str(cx.config.rustcflags), cx.config.verbose,
221-
cx.procsrv.chan, testfile));
215+
let testthunk = bind run_test_task(cx.config.compile_lib_path,
216+
cx.config.run_lib_path,
217+
cx.config.rustc_path,
218+
cx.config.src_base,
219+
cx.config.build_base,
220+
cx.config.stage_id,
221+
mode_str(cx.config.mode),
222+
cx.config.run_ignored,
223+
opt_str(cx.config.filter),
224+
opt_str(cx.config.runtool),
225+
opt_str(cx.config.rustcflags),
226+
cx.config.verbose,
227+
cx.procsrv.chan,
228+
testfile);
229+
ret task::spawn_joinable(testthunk);
222230
}
223231

224232
fn run_test_task(compile_lib_path: str, run_lib_path: str, rustc_path: str,

0 commit comments

Comments
 (0)