Skip to content

Silence warnings in std and extra testing #11071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/libextra/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ mod test {

#[test]
pub fn DuplexStream1() {
let (mut left, mut right) = DuplexStream::new();
let (left, right) = DuplexStream::new();

left.send(~"abc");
right.send(123);
Expand All @@ -112,10 +112,9 @@ mod test {

#[test]
pub fn basic_rendezvous_test() {
let (mut port, chan) = rendezvous();
let (port, chan) = rendezvous();

do spawn {
let mut chan = chan;
chan.send("abc");
}

Expand All @@ -126,9 +125,8 @@ mod test {
fn recv_a_lot() {
// Rendezvous streams should be able to handle any number of messages being sent
do run_in_uv_task {
let (mut port, chan) = rendezvous();
let (port, chan) = rendezvous();
do spawn {
let mut chan = chan;
1000000.times(|| { chan.send(()) })
}
1000000.times(|| { port.recv() })
Expand All @@ -137,9 +135,8 @@ mod test {

#[test]
fn send_and_fail_and_try_recv() {
let (mut port, chan) = rendezvous();
let (port, chan) = rendezvous();
do spawn {
let mut chan = chan;
chan.duplex_stream.send(()); // Can't access this field outside this module
fail!()
}
Expand All @@ -148,9 +145,8 @@ mod test {

#[test]
fn try_send_and_recv_then_fail_before_ack() {
let (port, mut chan) = rendezvous();
let (port, chan) = rendezvous();
do spawn {
let mut port = port;
port.duplex_stream.recv();
fail!()
}
Expand All @@ -160,9 +156,8 @@ mod test {
#[test]
#[should_fail]
fn send_and_recv_then_fail_before_ack() {
let (port, mut chan) = rendezvous();
let (port, chan) = rendezvous();
do spawn {
let mut port = port;
port.duplex_stream.recv();
fail!()
}
Expand Down
3 changes: 1 addition & 2 deletions src/libstd/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ mod tests {
use libc;
use ptr;
use option::{Some, None};
use vec;

#[test]
fn test_str_multistring_parsing() {
Expand Down Expand Up @@ -440,7 +439,7 @@ mod tests {
assert_eq!(*ptr::offset(buf, 0), 'f' as libc::c_char);
assert_eq!(*ptr::offset(buf, 1), 'o' as libc::c_char);
assert_eq!(*ptr::offset(buf, 2), 'o' as libc::c_char);
assert_eq!(*ptr::offset(buf, 3), 0xff);
assert_eq!(*ptr::offset(buf, 3), 0xff as i8);
assert_eq!(*ptr::offset(buf, 4), 0);
}
});
Expand Down
11 changes: 2 additions & 9 deletions src/libstd/io/native/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,22 +907,14 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
#[cfg(test)]
mod tests {
use io::native::file::{CFile, FileDesc};
use io::fs;
use io;
use libc;
use os;
use path::Path;
use rand;
use result::Ok;
use rt::rtio::RtioFileStream;

fn tmpdir() -> Path {
let ret = os::tmpdir().join(format!("rust-{}", rand::random::<u32>()));
fs::mkdir(&ret, io::UserRWX);
ret
}

#[ignore(cfg(target_os = "freebsd"))] // hmm, maybe pipes have a tiny buffer
#[test]
fn test_file_desc() {
// Run this test with some pipes so we don't have to mess around with
// opening or closing files.
Expand All @@ -949,6 +941,7 @@ mod tests {
}

#[ignore(cfg(windows))] // apparently windows doesn't like tmpfile
#[test]
fn test_cfile() {
unsafe {
let f = libc::tmpfile();
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ mod test {
#[test]
fn test_null_writer() {
let mut s = NullWriter;
let mut buf = ~[0, 0, 0];
let buf = ~[0, 0, 0];
s.write(buf);
s.flush();
}
Expand Down Expand Up @@ -248,7 +248,7 @@ mod test {

struct TestWriter;
impl Writer for TestWriter {
fn write(&mut self, buf: &[u8]) {
fn write(&mut self, _buf: &[u8]) {
unsafe { writes += 1 }
}

Expand Down
3 changes: 3 additions & 0 deletions src/libstd/local_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ mod tests {
static int_key: Key<@int> = &Key;
do task::spawn {
set(str_key, @~"string data");
set(str_key, @~"string data 2");
set(box_key, @@());
set(box_key, @@());
set(int_key, @42);
// This could cause a segfault if overwriting-destruction is done
// with the crazy polymorphic transmute rather than the provided
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,6 @@ pub mod ptr_tests {

#[test]
fn test_ptr_addition() {
use vec::raw::*;

unsafe {
let xs = ~[5, ..16];
let mut ptr = xs.as_ptr();
Expand Down
3 changes: 3 additions & 0 deletions src/libstd/rand/rand_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,14 @@ mod tests {
}
}

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

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

#[test]
fn rand_closed() {
let mut rng = task_rng();
for _ in range(0, 1_000) {
Expand Down
13 changes: 8 additions & 5 deletions src/libstd/rt/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,25 @@ pub unsafe fn init(argc: int, argv: **u8) { realargs::init(argc, argv) }
#[cfg(target_os = "freebsd")]
mod imp {
use cast;
use libc;
#[cfg(not(test))] use libc;
use option::{Option, Some, None};
use iter::Iterator;
use str;
#[cfg(not(test))] use str;
use unstable::finally::Finally;
use unstable::mutex::{Mutex, MUTEX_INIT};
use util;
use vec;
#[cfg(not(test))] use vec;

static mut global_args_ptr: uint = 0;
static mut lock: Mutex = MUTEX_INIT;

#[cfg(not(test))]
pub unsafe fn init(argc: int, argv: **u8) {
let args = load_argc_and_argv(argc, argv);
put(args);
}

#[cfg(not(test))]
pub unsafe fn cleanup() {
rtassert!(take().is_some());
lock.destroy();
Expand Down Expand Up @@ -127,6 +129,7 @@ mod imp {
}

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

#[cfg(target_os = "macos")]
#[cfg(target_os = "win32")]
#[cfg(target_os = "macos", not(test))]
#[cfg(target_os = "win32", not(test))]
mod imp {
use option::Option;

Expand Down
3 changes: 3 additions & 0 deletions src/libstd/rt/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@ pub unsafe fn record_sp_limit(limit: uint) {
/// As with the setter, this function does not have a __morestack header and can
/// therefore be called in a "we're out of stack" situation.
#[inline(always)]
// currently only called by `rust_stack_exhausted`, which doesn't
// exist in a test build.
#[cfg(not(test))]
pub unsafe fn get_sp_limit() -> uint {
return target_get_sp_limit();

Expand Down
2 changes: 2 additions & 0 deletions src/libstd/rt/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,8 @@ mod test {
}

// FIXME: #9407: xfail-test
#[ignore]
#[test]
fn dont_starve_1() {
stress_factor().times(|| {
do run_in_mt_newsched_task {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/rt/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use local_data;
use option::{Option, Some, None};
use rt::borrowck::BorrowRecord;
use rt::borrowck;
use rt::context;
use rt::context::Context;
use rt::env;
use rt::kill::Death;
Expand Down Expand Up @@ -511,6 +510,7 @@ impl Unwinder {
// irrelevant for documentation purposes.
#[cfg(not(test))] // in testing, use the original libstd's version
pub extern "C" fn rust_stack_exhausted() {
use rt::context;
use rt::in_green_task_context;
use rt::task::Task;
use rt::local::Local;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ mod tests {
use task::spawn;
use unstable::running_on_valgrind;
use io::native::file;
use io::{FileNotFound, OtherIoError, Reader, Writer, io_error};
use io::{FileNotFound, Reader, Writer, io_error};

#[test]
#[cfg(not(target_os="android"))] // FIXME(#10380)
Expand Down
1 change: 0 additions & 1 deletion src/libstd/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,6 @@ mod tests {
use option::{None, Some, Option};
use ptr;
use str::*;
use vec;
use vec::{Vector, ImmutableVector, CopyableVector};
use cmp::{TotalOrd, Less, Equal, Greater};
use send_str::{SendStrOwned, SendStrStatic};
Expand Down
8 changes: 0 additions & 8 deletions src/libstd/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,6 @@ pub fn failing() -> bool {
// !!! These tests are dangerous. If Something is buggy, they will hang, !!!
// !!! instead of exiting cleanly. This might wedge the buildbots. !!!

#[cfg(test)]
fn block_forever() { let (po, _ch) = Chan::<()>::new(); po.recv(); }

#[test]
fn test_unnamed_task() {
use rt::test::run_in_uv_task;
Expand Down Expand Up @@ -507,11 +504,6 @@ fn test_run_basic() {
po.recv();
}

#[cfg(test)]
struct Wrapper {
f: Option<Chan<()>>
}

#[test]
fn test_add_wrapper() {
let (po, ch) = Chan::new();
Expand Down
17 changes: 2 additions & 15 deletions src/libstd/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2678,7 +2678,7 @@ impl<A> Extendable<A> for ~[A] {

#[cfg(test)]
mod tests {
use option::{None, Option, Some};
use option::{None, Some};
use mem;
use vec::*;
use cmp::*;
Expand All @@ -2688,22 +2688,8 @@ mod tests {

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

fn is_three(n: &uint) -> bool { *n == 3u }

fn is_odd(n: &uint) -> bool { *n % 2u == 1u }

fn is_equal(x: &uint, y:&uint) -> bool { *x == *y }

fn square_if_odd_r(n: &uint) -> Option<uint> {
if *n % 2u == 1u { Some(*n * *n) } else { None }
}

fn square_if_odd_v(n: uint) -> Option<uint> {
if n % 2u == 1u { Some(n * n) } else { None }
}

fn add(x: uint, y: &uint) -> uint { x + *y }

#[test]
fn test_unsafe_ptrs() {
unsafe {
Expand Down Expand Up @@ -2982,6 +2968,7 @@ mod tests {
assert_eq!(g, None);
}

#[test]
fn test_swap_remove() {
let mut v = ~[1, 2, 3, 4, 5];
let mut e = v.swap_remove(0);
Expand Down