Skip to content

Commit fa2bb97

Browse files
committed
auto merge of #10204 : alexcrichton/rust/better-names, r=brson
Tests now have the same name as the test that they're running (to allow for easier diagnosing of failure sources), and the main task is now specially named `<main>` instead of `<unnamed>`. Closes #10195 Closes #10073
2 parents 7cff3c7 + e2a68b6 commit fa2bb97

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

src/libextra/test.rs

+4
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,10 @@ pub fn run_test(force_ignore: bool,
869869
do task::spawn {
870870
let mut task = task::task();
871871
task.unlinked();
872+
task.name(match desc.name {
873+
DynTestName(ref name) => SendStrOwned(name.clone()),
874+
StaticTestName(name) => SendStrStatic(name),
875+
});
872876
let result_future = task.future_result();
873877
task.spawn(testfn_cell.take());
874878

src/libstd/rt/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ use rt::sched::{Scheduler, Shutdown};
6868
use rt::sleeper_list::SleeperList;
6969
use rt::task::UnwindResult;
7070
use rt::task::{Task, SchedTask, GreenTask, Sched};
71+
use send_str::SendStrStatic;
7172
use unstable::atomics::{AtomicInt, AtomicBool, SeqCst};
7273
use unstable::sync::UnsafeArc;
7374
use vec::{OwnedVector, MutableVector, ImmutableVector};
@@ -373,6 +374,7 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
373374
// run the main task in one of our threads.
374375

375376
let mut main_task = ~Task::new_root(&mut scheds[0].stack_pool, None, main.take());
377+
main_task.name = Some(SendStrStatic("<main>"));
376378
main_task.death.on_exit = Some(on_exit.take());
377379
let main_task_cell = Cell::new(main_task);
378380

@@ -410,6 +412,7 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
410412
let home = Sched(main_sched.make_handle());
411413
let mut main_task = ~Task::new_root_homed(&mut main_sched.stack_pool, None,
412414
home, main.take());
415+
main_task.name = Some(SendStrStatic("<main>"));
413416
main_task.death.on_exit = Some(on_exit.take());
414417
rtdebug!("bootstrapping main_task");
415418

src/test/run-fail/main-fail.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:task '<main>' failed at
12+
13+
fn main() {
14+
fail!()
15+
}

src/test/run-fail/test-fail.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:task 'test_foo' failed at
12+
// compile-flags: --test
13+
14+
#[test]
15+
fn test_foo() {
16+
fail!()
17+
}
18+

0 commit comments

Comments
 (0)