Skip to content

Commit 415e55a

Browse files
committed
auto merge of #11071 : huonw/rust/quiet-test, r=cmr
2 parents 5c24bfa + f13d57f commit 415e55a

File tree

15 files changed

+34
-57
lines changed

15 files changed

+34
-57
lines changed

src/libextra/comm.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ mod test {
101101

102102
#[test]
103103
pub fn DuplexStream1() {
104-
let (mut left, mut right) = DuplexStream::new();
104+
let (left, right) = DuplexStream::new();
105105

106106
left.send(~"abc");
107107
right.send(123);
@@ -112,10 +112,9 @@ mod test {
112112
113113
#[test]
114114
pub fn basic_rendezvous_test() {
115-
let (mut port, chan) = rendezvous();
115+
let (port, chan) = rendezvous();
116116
117117
do spawn {
118-
let mut chan = chan;
119118
chan.send("abc");
120119
}
121120
@@ -126,9 +125,8 @@ mod test {
126125
fn recv_a_lot() {
127126
// Rendezvous streams should be able to handle any number of messages being sent
128127
do run_in_uv_task {
129-
let (mut port, chan) = rendezvous();
128+
let (port, chan) = rendezvous();
130129
do spawn {
131-
let mut chan = chan;
132130
1000000.times(|| { chan.send(()) })
133131
}
134132
1000000.times(|| { port.recv() })
@@ -137,9 +135,8 @@ mod test {
137135

138136
#[test]
139137
fn send_and_fail_and_try_recv() {
140-
let (mut port, chan) = rendezvous();
138+
let (port, chan) = rendezvous();
141139
do spawn {
142-
let mut chan = chan;
143140
chan.duplex_stream.send(()); // Can't access this field outside this module
144141
fail!()
145142
}
@@ -148,9 +145,8 @@ mod test {
148145

149146
#[test]
150147
fn try_send_and_recv_then_fail_before_ack() {
151-
let (port, mut chan) = rendezvous();
148+
let (port, chan) = rendezvous();
152149
do spawn {
153-
let mut port = port;
154150
port.duplex_stream.recv();
155151
fail!()
156152
}
@@ -160,9 +156,8 @@ mod test {
160156
#[test]
161157
#[should_fail]
162158
fn send_and_recv_then_fail_before_ack() {
163-
let (port, mut chan) = rendezvous();
159+
let (port, chan) = rendezvous();
164160
do spawn {
165-
let mut port = port;
166161
port.duplex_stream.recv();
167162
fail!()
168163
}

src/libstd/c_str.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ mod tests {
377377
use libc;
378378
use ptr;
379379
use option::{Some, None};
380-
use vec;
381380

382381
#[test]
383382
fn test_str_multistring_parsing() {
@@ -440,7 +439,7 @@ mod tests {
440439
assert_eq!(*ptr::offset(buf, 0), 'f' as libc::c_char);
441440
assert_eq!(*ptr::offset(buf, 1), 'o' as libc::c_char);
442441
assert_eq!(*ptr::offset(buf, 2), 'o' as libc::c_char);
443-
assert_eq!(*ptr::offset(buf, 3), 0xff);
442+
assert_eq!(*ptr::offset(buf, 3), 0xff as i8);
444443
assert_eq!(*ptr::offset(buf, 4), 0);
445444
}
446445
});

src/libstd/io/native/file.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -907,22 +907,14 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
907907
#[cfg(test)]
908908
mod tests {
909909
use io::native::file::{CFile, FileDesc};
910-
use io::fs;
911910
use io;
912911
use libc;
913912
use os;
914-
use path::Path;
915-
use rand;
916913
use result::Ok;
917914
use rt::rtio::RtioFileStream;
918915

919-
fn tmpdir() -> Path {
920-
let ret = os::tmpdir().join(format!("rust-{}", rand::random::<u32>()));
921-
fs::mkdir(&ret, io::UserRWX);
922-
ret
923-
}
924-
925916
#[ignore(cfg(target_os = "freebsd"))] // hmm, maybe pipes have a tiny buffer
917+
#[test]
926918
fn test_file_desc() {
927919
// Run this test with some pipes so we don't have to mess around with
928920
// opening or closing files.
@@ -949,6 +941,7 @@ mod tests {
949941
}
950942

951943
#[ignore(cfg(windows))] // apparently windows doesn't like tmpfile
944+
#[test]
952945
fn test_cfile() {
953946
unsafe {
954947
let f = libc::tmpfile();

src/libstd/io/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ mod test {
220220
#[test]
221221
fn test_null_writer() {
222222
let mut s = NullWriter;
223-
let mut buf = ~[0, 0, 0];
223+
let buf = ~[0, 0, 0];
224224
s.write(buf);
225225
s.flush();
226226
}
@@ -248,7 +248,7 @@ mod test {
248248

249249
struct TestWriter;
250250
impl Writer for TestWriter {
251-
fn write(&mut self, buf: &[u8]) {
251+
fn write(&mut self, _buf: &[u8]) {
252252
unsafe { writes += 1 }
253253
}
254254

src/libstd/local_data.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ mod tests {
438438
static int_key: Key<@int> = &Key;
439439
do task::spawn {
440440
set(str_key, @~"string data");
441+
set(str_key, @~"string data 2");
442+
set(box_key, @@());
443+
set(box_key, @@());
441444
set(int_key, @42);
442445
// This could cause a segfault if overwriting-destruction is done
443446
// with the crazy polymorphic transmute rather than the provided

src/libstd/ptr.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,6 @@ pub mod ptr_tests {
557557

558558
#[test]
559559
fn test_ptr_addition() {
560-
use vec::raw::*;
561-
562560
unsafe {
563561
let xs = ~[5, ..16];
564562
let mut ptr = xs.as_ptr();

src/libstd/rand/rand_impls.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,14 @@ mod tests {
240240
}
241241
}
242242

243+
#[test]
243244
fn floating_point_edge_cases() {
244245
// the test for exact equality is correct here.
245246
assert!(ConstantRng(0xffff_ffff).gen::<f32>() != 1.0)
246247
assert!(ConstantRng(0xffff_ffff_ffff_ffff).gen::<f64>() != 1.0)
247248
}
248249

250+
#[test]
249251
fn rand_open() {
250252
// this is unlikely to catch an incorrect implementation that
251253
// generates exactly 0 or 1, but it keeps it sane.
@@ -260,6 +262,7 @@ mod tests {
260262
}
261263
}
262264

265+
#[test]
263266
fn rand_closed() {
264267
let mut rng = task_rng();
265268
for _ in range(0, 1_000) {

src/libstd/rt/args.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,25 @@ pub unsafe fn init(argc: int, argv: **u8) { realargs::init(argc, argv) }
6464
#[cfg(target_os = "freebsd")]
6565
mod imp {
6666
use cast;
67-
use libc;
67+
#[cfg(not(test))] use libc;
6868
use option::{Option, Some, None};
6969
use iter::Iterator;
70-
use str;
70+
#[cfg(not(test))] use str;
7171
use unstable::finally::Finally;
7272
use unstable::mutex::{Mutex, MUTEX_INIT};
7373
use util;
74-
use vec;
74+
#[cfg(not(test))] use vec;
7575

7676
static mut global_args_ptr: uint = 0;
7777
static mut lock: Mutex = MUTEX_INIT;
7878

79+
#[cfg(not(test))]
7980
pub unsafe fn init(argc: int, argv: **u8) {
8081
let args = load_argc_and_argv(argc, argv);
8182
put(args);
8283
}
8384

85+
#[cfg(not(test))]
8486
pub unsafe fn cleanup() {
8587
rtassert!(take().is_some());
8688
lock.destroy();
@@ -127,6 +129,7 @@ mod imp {
127129
}
128130

129131
// Copied from `os`.
132+
#[cfg(not(test))]
130133
unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] {
131134
vec::from_fn(argc as uint, |i| {
132135
str::raw::from_c_str(*(argv as **libc::c_char).offset(i as int))
@@ -163,8 +166,8 @@ mod imp {
163166
}
164167
}
165168

166-
#[cfg(target_os = "macos")]
167-
#[cfg(target_os = "win32")]
169+
#[cfg(target_os = "macos", not(test))]
170+
#[cfg(target_os = "win32", not(test))]
168171
mod imp {
169172
use option::Option;
170173

src/libstd/rt/context.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ pub unsafe fn record_sp_limit(limit: uint) {
395395
/// As with the setter, this function does not have a __morestack header and can
396396
/// therefore be called in a "we're out of stack" situation.
397397
#[inline(always)]
398+
// currently only called by `rust_stack_exhausted`, which doesn't
399+
// exist in a test build.
400+
#[cfg(not(test))]
398401
pub unsafe fn get_sp_limit() -> uint {
399402
return target_get_sp_limit();
400403

src/libstd/rt/sched.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,8 @@ mod test {
13411341
}
13421342

13431343
// FIXME: #9407: xfail-test
1344+
#[ignore]
1345+
#[test]
13441346
fn dont_starve_1() {
13451347
stress_factor().times(|| {
13461348
do run_in_mt_newsched_task {

src/libstd/rt/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use local_data;
2626
use option::{Option, Some, None};
2727
use rt::borrowck::BorrowRecord;
2828
use rt::borrowck;
29-
use rt::context;
3029
use rt::context::Context;
3130
use rt::env;
3231
use rt::kill::Death;
@@ -511,6 +510,7 @@ impl Unwinder {
511510
// irrelevant for documentation purposes.
512511
#[cfg(not(test))] // in testing, use the original libstd's version
513512
pub extern "C" fn rust_stack_exhausted() {
513+
use rt::context;
514514
use rt::in_green_task_context;
515515
use rt::task::Task;
516516
use rt::local::Local;

src/libstd/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ mod tests {
339339
use task::spawn;
340340
use unstable::running_on_valgrind;
341341
use io::native::file;
342-
use io::{FileNotFound, OtherIoError, Reader, Writer, io_error};
342+
use io::{FileNotFound, Reader, Writer, io_error};
343343

344344
#[test]
345345
#[cfg(not(target_os="android"))] // FIXME(#10380)

src/libstd/str.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2734,7 +2734,6 @@ mod tests {
27342734
use option::{None, Some, Option};
27352735
use ptr;
27362736
use str::*;
2737-
use vec;
27382737
use vec::{Vector, ImmutableVector, CopyableVector};
27392738
use cmp::{TotalOrd, Less, Equal, Greater};
27402739
use send_str::{SendStrOwned, SendStrStatic};

src/libstd/task/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,6 @@ pub fn failing() -> bool {
437437
// !!! These tests are dangerous. If Something is buggy, they will hang, !!!
438438
// !!! instead of exiting cleanly. This might wedge the buildbots. !!!
439439

440-
#[cfg(test)]
441-
fn block_forever() { let (po, _ch) = Chan::<()>::new(); po.recv(); }
442-
443440
#[test]
444441
fn test_unnamed_task() {
445442
use rt::test::run_in_uv_task;
@@ -507,11 +504,6 @@ fn test_run_basic() {
507504
po.recv();
508505
}
509506

510-
#[cfg(test)]
511-
struct Wrapper {
512-
f: Option<Chan<()>>
513-
}
514-
515507
#[test]
516508
fn test_add_wrapper() {
517509
let (po, ch) = Chan::new();

src/libstd/vec.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,7 +2687,7 @@ impl<A> Extendable<A> for ~[A] {
26872687

26882688
#[cfg(test)]
26892689
mod tests {
2690-
use option::{None, Option, Some};
2690+
use option::{None, Some};
26912691
use mem;
26922692
use vec::*;
26932693
use cmp::*;
@@ -2697,22 +2697,8 @@ mod tests {
26972697

26982698
fn square_ref(n: &uint) -> uint { square(*n) }
26992699

2700-
fn is_three(n: &uint) -> bool { *n == 3u }
2701-
27022700
fn is_odd(n: &uint) -> bool { *n % 2u == 1u }
27032701

2704-
fn is_equal(x: &uint, y:&uint) -> bool { *x == *y }
2705-
2706-
fn square_if_odd_r(n: &uint) -> Option<uint> {
2707-
if *n % 2u == 1u { Some(*n * *n) } else { None }
2708-
}
2709-
2710-
fn square_if_odd_v(n: uint) -> Option<uint> {
2711-
if n % 2u == 1u { Some(n * n) } else { None }
2712-
}
2713-
2714-
fn add(x: uint, y: &uint) -> uint { x + *y }
2715-
27162702
#[test]
27172703
fn test_unsafe_ptrs() {
27182704
unsafe {
@@ -2991,6 +2977,7 @@ mod tests {
29912977
assert_eq!(g, None);
29922978
}
29932979

2980+
#[test]
29942981
fn test_swap_remove() {
29952982
let mut v = ~[1, 2, 3, 4, 5];
29962983
let mut e = v.swap_remove(0);

0 commit comments

Comments
 (0)