File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ mod context;
49
49
mod thread;
50
50
pub mod env;
51
51
52
+ /// Tools for testing the runtime
53
+ #[ cfg( test) ]
54
+ pub mod test;
55
+
52
56
#[ cfg( stage0) ]
53
57
pub fn start ( main : * u8 , _argc : int , _argv : * c_char , _crate_map : * u8 ) -> int {
54
58
use self :: sched:: { Scheduler , Task } ;
Original file line number Diff line number Diff line change
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
+ // For setting up tests of the new scheduler
12
+ pub fn run_in_newsched_task ( f : ~fn ( ) ) {
13
+ use cell:: Cell ;
14
+ use unstable:: run_in_bare_thread;
15
+ use super :: sched:: Task ;
16
+ use super :: uvio:: UvEventLoop ;
17
+
18
+ let f = Cell ( Cell ( f) ) ;
19
+
20
+ do run_in_bare_thread {
21
+ let mut sched = ~UvEventLoop : : new_scheduler ( ) ;
22
+ let f = f. take ( ) ;
23
+ let task = ~do Task :: new ( & mut sched. stack_pool ) {
24
+ ( f. take ( ) ) ( ) ;
25
+ } ;
26
+ sched. task_queue . push_back ( task) ;
27
+ sched. run ( ) ;
28
+ }
29
+ }
Original file line number Diff line number Diff line change @@ -1229,7 +1229,7 @@ fn test_spawn_thread_on_demand() {
1229
1229
1230
1230
#[ test]
1231
1231
fn test_simple_newsched_spawn ( ) {
1232
- use rt:: run_in_newsched_task;
1232
+ use rt:: test :: run_in_newsched_task;
1233
1233
1234
1234
do run_in_newsched_task {
1235
1235
spawn( ||( ) )
You can’t perform that action at this time.
0 commit comments