Skip to content

Commit 009d898

Browse files
committed
De-realstd os::args
With the test runner using ::std::os::args(), and std::std::os now being a re-export of realstd::os, there's no more need for realstd stuff mucking up rt::args. Remove the one test of os::args(), as it's not very useful and it won't work anymore now that rt::args doesn't use realstd.
1 parent 69070ac commit 009d898

File tree

2 files changed

+8
-48
lines changed

2 files changed

+8
-48
lines changed

src/libstd/os.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -918,17 +918,10 @@ extern "system" {
918918
///
919919
/// The arguments are interpreted as utf-8, with invalid bytes replaced with \uFFFD.
920920
/// See `str::from_utf8_lossy` for details.
921-
#[cfg(not(test))]
922921
pub fn args() -> Vec<String> {
923922
real_args()
924923
}
925924

926-
#[cfg(test)]
927-
#[allow(missing_doc)]
928-
pub fn args() -> ::realstd::vec::Vec<::realstd::string::String> {
929-
::realstd::os::args()
930-
}
931-
932925
/// Returns the arguments which this program was started with (normally passed
933926
/// via the command line) as byte vectors.
934927
pub fn args_as_bytes() -> Vec<Vec<u8>> {
@@ -1507,7 +1500,7 @@ mod tests {
15071500
use prelude::*;
15081501
use c_str::ToCStr;
15091502
use option;
1510-
use os::{env, getcwd, getenv, make_absolute, args};
1503+
use os::{env, getcwd, getenv, make_absolute};
15111504
use os::{setenv, unsetenv};
15121505
use os;
15131506
use rand::Rng;
@@ -1518,12 +1511,6 @@ mod tests {
15181511
debug!("{}", os::last_os_error());
15191512
}
15201513

1521-
#[test]
1522-
pub fn test_args() {
1523-
let a = args();
1524-
assert!(a.len() >= 1);
1525-
}
1526-
15271514
fn make_rand_name() -> String {
15281515
let mut rng = rand::task_rng();
15291516
let n = format_strbuf!("TEST{}", rng.gen_ascii_str(10u).as_slice());

src/libstd/rt/args.rs

+7-34
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,23 @@
2222
2323
use option::Option;
2424
use vec::Vec;
25-
#[cfg(test)] use option::{Some, None};
26-
#[cfg(test)] use realstd;
27-
#[cfg(test)] use realargs = realstd::rt::args;
2825

2926
/// One-time global initialization.
30-
#[cfg(not(test))]
3127
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) }
3428

3529
/// 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() }
3831

3932
/// 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() }
4734

4835
/// Give the global arguments to global storage.
4936
///
5037
/// 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) }
5739

5840
/// 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() }
6642

6743
#[cfg(target_os = "linux")]
6844
#[cfg(target_os = "android")]
@@ -75,18 +51,16 @@ mod imp {
7551
use unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
7652
use mem;
7753
use vec::Vec;
78-
#[cfg(not(test))] use ptr::RawPtr;
54+
use ptr::RawPtr;
7955

8056
static mut global_args_ptr: uint = 0;
8157
static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
8258

83-
#[cfg(not(test))]
8459
pub unsafe fn init(argc: int, argv: **u8) {
8560
let args = load_argc_and_argv(argc, argv);
8661
put(args);
8762
}
8863

89-
#[cfg(not(test))]
9064
pub unsafe fn cleanup() {
9165
rtassert!(take().is_some());
9266
lock.destroy();
@@ -127,7 +101,6 @@ mod imp {
127101
}
128102

129103
// Copied from `os`.
130-
#[cfg(not(test))]
131104
unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> Vec<Vec<u8>> {
132105
use c_str::CString;
133106
use ptr::RawPtr;
@@ -173,8 +146,8 @@ mod imp {
173146
}
174147
}
175148

176-
#[cfg(target_os = "macos", not(test))]
177-
#[cfg(target_os = "win32", not(test))]
149+
#[cfg(target_os = "macos")]
150+
#[cfg(target_os = "win32")]
178151
mod imp {
179152
use option::Option;
180153
use vec::Vec;

0 commit comments

Comments
 (0)