22
22
23
23
use option:: Option ;
24
24
use vec:: Vec ;
25
- #[ cfg( test) ] use option:: { Some , None } ;
26
- #[ cfg( test) ] use realstd;
27
- #[ cfg( test) ] use realargs = realstd:: rt:: args;
28
25
29
26
/// One-time global initialization.
30
- #[ cfg( not( test) ) ]
31
27
pub unsafe fn init ( argc : int , argv : * * u8 ) { imp:: init ( argc, argv) }
32
- #[ cfg( test) ]
33
- pub unsafe fn init ( argc : int , argv : * * u8 ) { realargs:: init ( argc, argv) }
34
28
35
29
/// One-time global cleanup.
36
- #[ cfg( not( test) ) ] pub unsafe fn cleanup ( ) { imp:: cleanup ( ) }
37
- #[ cfg( test) ] pub unsafe fn cleanup ( ) { realargs:: cleanup ( ) }
30
+ pub unsafe fn cleanup ( ) { imp:: cleanup ( ) }
38
31
39
32
/// Take the global arguments from global storage.
40
- #[ cfg( not( test) ) ] pub fn take ( ) -> Option < Vec < Vec < u8 > > > { imp:: take ( ) }
41
- #[ cfg( test) ] pub fn take ( ) -> Option < Vec < Vec < u8 > > > {
42
- match realargs:: take ( ) {
43
- realstd:: option:: Some ( v) => Some ( unsafe { :: mem:: transmute ( v) } ) ,
44
- realstd:: option:: None => None ,
45
- }
46
- }
33
+ pub fn take ( ) -> Option < Vec < Vec < u8 > > > { imp:: take ( ) }
47
34
48
35
/// Give the global arguments to global storage.
49
36
///
50
37
/// It is an error if the arguments already exist.
51
- #[ cfg( not( test) ) ] pub fn put ( args : Vec < Vec < u8 > > ) { imp:: put ( args) }
52
- #[ cfg( test) ] pub fn put ( args : Vec < Vec < u8 > > ) {
53
- realargs:: put ( unsafe {
54
- :: mem:: transmute ( args)
55
- } )
56
- }
38
+ pub fn put ( args : Vec < Vec < u8 > > ) { imp:: put ( args) }
57
39
58
40
/// Make a clone of the global arguments.
59
- #[ cfg( not( test) ) ] pub fn clone ( ) -> Option < Vec < Vec < u8 > > > { imp:: clone ( ) }
60
- #[ cfg( test) ] pub fn clone ( ) -> Option < Vec < Vec < u8 > > > {
61
- match realargs:: clone ( ) {
62
- realstd:: option:: Some ( v) => Some ( unsafe { :: mem:: transmute ( v) } ) ,
63
- realstd:: option:: None => None ,
64
- }
65
- }
41
+ pub fn clone ( ) -> Option < Vec < Vec < u8 > > > { imp:: clone ( ) }
66
42
67
43
#[ cfg( target_os = "linux" ) ]
68
44
#[ cfg( target_os = "android" ) ]
@@ -75,18 +51,16 @@ mod imp {
75
51
use unstable:: mutex:: { StaticNativeMutex , NATIVE_MUTEX_INIT } ;
76
52
use mem;
77
53
use vec:: Vec ;
78
- # [ cfg ( not ( test ) ) ] use ptr:: RawPtr ;
54
+ use ptr:: RawPtr ;
79
55
80
56
static mut global_args_ptr: uint = 0 ;
81
57
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT ;
82
58
83
- #[ cfg( not( test) ) ]
84
59
pub unsafe fn init ( argc : int , argv : * * u8 ) {
85
60
let args = load_argc_and_argv ( argc, argv) ;
86
61
put ( args) ;
87
62
}
88
63
89
- #[ cfg( not( test) ) ]
90
64
pub unsafe fn cleanup ( ) {
91
65
rtassert ! ( take( ) . is_some( ) ) ;
92
66
lock. destroy ( ) ;
@@ -127,7 +101,6 @@ mod imp {
127
101
}
128
102
129
103
// Copied from `os`.
130
- #[ cfg( not( test) ) ]
131
104
unsafe fn load_argc_and_argv ( argc : int , argv : * * u8 ) -> Vec < Vec < u8 > > {
132
105
use c_str:: CString ;
133
106
use ptr:: RawPtr ;
@@ -173,8 +146,8 @@ mod imp {
173
146
}
174
147
}
175
148
176
- #[ cfg( target_os = "macos" , not ( test ) ) ]
177
- #[ cfg( target_os = "win32" , not ( test ) ) ]
149
+ #[ cfg( target_os = "macos" ) ]
150
+ #[ cfg( target_os = "win32" ) ]
178
151
mod imp {
179
152
use option:: Option ;
180
153
use vec:: Vec ;
0 commit comments