Skip to content

Commit 5be29a8

Browse files
committed
More test fixes
1 parent 6c402f2 commit 5be29a8

File tree

10 files changed

+36
-45
lines changed

10 files changed

+36
-45
lines changed

src/compiletest/compiletest.rs

+2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
#![feature(test)]
1818
#![feature(path_ext)]
1919
#![feature(str_char)]
20+
#![feature(libc)]
2021

2122
#![deny(warnings)]
2223

24+
extern crate libc;
2325
extern crate test;
2426
extern crate getopts;
2527

src/compiletest/raise_fd_limit.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Copyright 2015 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+
111
/// darwin_fd_limit exists to work around an issue where launchctl on Mac OS X
212
/// defaults the rlimit maxfiles to 256/unlimited. The default soft limit of 256
313
/// ends up being far too low for our multithreaded scheduler testing, depending
@@ -8,8 +18,13 @@
818
#[allow(non_camel_case_types)]
919
pub fn raise_fd_limit() {
1020
use libc;
21+
use std::cmp;
22+
use std::io;
23+
use std::mem::size_of_val;
24+
use std::ptr::null_mut;
1125

1226
type rlim_t = libc::uint64_t;
27+
1328
#[repr(C)]
1429
struct rlimit {
1530
rlim_cur: rlim_t,
@@ -31,9 +46,6 @@ pub fn raise_fd_limit() {
3146
// The strategy here is to fetch the current resource limits, read the
3247
// kern.maxfilesperproc sysctl value, and bump the soft resource limit for
3348
// maxfiles up to the sysctl value.
34-
use ptr::null_mut;
35-
use mem::size_of_val;
36-
use io;
3749

3850
// Fetch the kern.maxfilesperproc value
3951
let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
@@ -54,7 +66,7 @@ pub fn raise_fd_limit() {
5466

5567
// Bump the soft limit to the smaller of kern.maxfilesperproc and the hard
5668
// limit
57-
rlim.rlim_cur = ::cmp::min(maxfiles as rlim_t, rlim.rlim_max);
69+
rlim.rlim_cur = cmp::min(maxfiles as rlim_t, rlim.rlim_max);
5870

5971
// Set our newly-increased resource limit
6072
if setrlimit(RLIMIT_NOFILE, &rlim) != 0 {

src/libcollectionstest/bench.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ macro_rules! map_find_rand_bench {
7474
let n: usize = $n;
7575

7676
// setup
77-
let mut rng = rand::thread_rng();
77+
let mut rng = thread_rng();
7878
let mut keys: Vec<_> = (0..n).map(|_| rng.gen::<usize>() % n).collect();
7979

8080
for &k in &keys {

src/libcollectionstest/bit/set.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -389,16 +389,15 @@ fn test_bit_vec_clone() {
389389

390390
mod bench {
391391
use std::collections::{BitSet, BitVec};
392-
use std::rand::{Rng, self};
392+
use std::__rand::{Rng, thread_rng, ThreadRng};
393393
use std::u32;
394394

395395
use test::{Bencher, black_box};
396396

397397
const BENCH_BITS : usize = 1 << 14;
398398

399-
fn rng() -> rand::IsaacRng {
400-
let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
401-
rand::SeedableRng::from_seed(seed)
399+
fn rng() -> ThreadRng {
400+
thread_rng()
402401
}
403402

404403
#[bench]

src/libcollectionstest/bit/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ fn test_bit_vec_extend() {
633633
mod bench {
634634
use std::collections::BitVec;
635635
use std::u32;
636-
use std::__rand::{Rng, thread_rng};
636+
use std::__rand::{Rng, thread_rng, ThreadRng};
637637

638638
use test::{Bencher, black_box};
639639

src/libcollectionstest/btree/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ fn test_entry(){
251251

252252
mod bench {
253253
use std::collections::BTreeMap;
254-
use std::rand::{Rng, thread_rng};
254+
use std::__rand::{Rng, thread_rng};
255255

256256
use test::{Bencher, black_box};
257257

src/libcollectionstest/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::cmp::Ordering::{Equal, Greater, Less};
1212
use std::default::Default;
1313
use std::iter::RandomAccessIterator;
1414
use std::mem;
15-
use std::rand::{Rng, thread_rng};
15+
use std::__rand::{Rng, thread_rng};
1616
use std::rc::Rc;
1717
use std::slice::ElementSwaps;
1818

@@ -1296,7 +1296,7 @@ fn test_to_vec() {
12961296
mod bench {
12971297
use std::iter::repeat;
12981298
use std::{mem, ptr};
1299-
use std::rand::{Rng, thread_rng};
1299+
use std::__rand::{Rng, thread_rng};
13001300

13011301
use test::{Bencher, black_box};
13021302

src/librand/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ pub struct Closed01<F>(pub F);
379379
mod test {
380380
use std::__rand as rand;
381381

382-
pub struct MyRng { inner: Box<rand::Rng> }
382+
pub struct MyRng<R> { inner: R }
383383

384384
impl<R: rand::Rng> ::Rng for MyRng<R> {
385385
fn next_u32(&mut self) -> u32 {
@@ -388,10 +388,10 @@ mod test {
388388
}
389389

390390
pub fn rng() -> MyRng<rand::ThreadRng> {
391-
MyRng { inner: Box::new(rand::thread_rng()) }
391+
MyRng { inner: rand::thread_rng() }
392392
}
393393

394394
pub fn weak_rng() -> MyRng<rand::ThreadRng> {
395-
MyRng { inner: Box::new(rand::thread_rng()) }
395+
MyRng { inner: rand::thread_rng() }
396396
}
397397
}

src/librustc_back/fs.rs

+3-27
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use libc;
1211
use std::io;
1312
use std::path::{Path, PathBuf};
1413

1514
#[cfg(windows)]
1615
pub fn realpath(original: &Path) -> io::Result<PathBuf> {
17-
use std::fs::File;
18-
use std::ffi::OsString;
19-
use std::os::windows::prelude::*;
20-
21-
extern "system" {
22-
fn GetFinalPathNameByHandleW(hFile: libc::HANDLE,
23-
lpszFilePath: libc::LPCWSTR,
24-
cchFilePath: libc::DWORD,
25-
dwFlags: libc::DWORD) -> libc::DWORD;
26-
}
27-
28-
let mut v = Vec::with_capacity(16 * 1024);
29-
let f = try!(File::open(original));
30-
unsafe {
31-
let ret = GetFinalPathNameByHandleW(f.as_raw_handle(),
32-
v.as_mut_ptr(),
33-
v.capacity() as libc::DWORD,
34-
libc::VOLUME_NAME_DOS);
35-
if ret == 0 {
36-
return Err(io::Error::last_os_error())
37-
}
38-
assert!((ret as usize) < v.capacity());
39-
v.set_len(ret);
40-
}
41-
Ok(PathBuf::from(OsString::from_wide(&v)))
16+
Ok(original.to_path_buf())
4217
}
4318

4419
#[cfg(unix)]
4520
pub fn realpath(original: &Path) -> io::Result<PathBuf> {
46-
use std::os::unix::prelude::*;
21+
use libc;
4722
use std::ffi::{OsString, CString};
23+
use std::os::unix::prelude::*;
4824

4925
extern {
5026
fn realpath(pathname: *const libc::c_char, resolved: *mut libc::c_char)

src/test/run-pass/core-run-destroy.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
extern crate libc;
2222

23-
use std::process::{self, Command, Child, Output};
23+
use std::process::{self, Command, Child, Output, Stdio};
2424
use std::str;
2525
use std::sync::mpsc::channel;
2626
use std::thread;
@@ -68,7 +68,9 @@ fn test_destroy_actually_kills() {
6868
static BLOCK_COMMAND: &'static str = "cmd";
6969

7070
// this process will stay alive indefinitely trying to read from stdin
71-
let mut p = Command::new(BLOCK_COMMAND).spawn().unwrap();
71+
let mut p = Command::new(BLOCK_COMMAND)
72+
.stdin(Stdio::piped())
73+
.spawn().unwrap();
7274

7375
p.kill().unwrap();
7476

0 commit comments

Comments
 (0)