From adcd67272e6ebcca65028fe1c8bf20390e827e07 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 10 Apr 2015 11:12:43 -0700 Subject: [PATCH] test: Fix fallout in run-pass tests --- src/test/run-pass-valgrind/cleanup-stdin.rs | 5 +- src/test/run-pass/backtrace.rs | 32 +-- src/test/run-pass/capturing-logging.rs | 46 ---- src/test/run-pass/closure-reform.rs | 6 +- src/test/run-pass/core-run-destroy.rs | 62 ++--- src/test/run-pass/deriving-global.rs | 7 +- src/test/run-pass/deriving-rand.rs | 43 ---- src/test/run-pass/drop-flag-sanity-check.rs | 4 +- .../run-pass/drop-flag-skip-sanity-check.rs | 2 +- src/test/run-pass/issue-10626.rs | 6 +- src/test/run-pass/issue-12684.rs | 26 --- src/test/run-pass/issue-12699.rs | 9 +- src/test/run-pass/issue-14901.rs | 6 +- src/test/run-pass/issue-15149.rs | 13 +- src/test/run-pass/issue-18619.rs | 19 -- src/test/run-pass/issue-2904.rs | 8 +- src/test/run-pass/issue-3424.rs | 17 +- src/test/run-pass/issue-4446.rs | 5 +- src/test/run-pass/issue-5988.rs | 5 +- src/test/run-pass/issue-8398.rs | 8 +- src/test/run-pass/issue-9396.rs | 7 +- src/test/run-pass/logging-separate-lines.rs | 6 +- ...thod-mut-self-modifies-mut-slice-lvalue.rs | 3 +- .../out-of-stack-new-thread-no-split.rs | 6 +- src/test/run-pass/out-of-stack-no-split.rs | 18 +- src/test/run-pass/out-of-stack.rs | 8 +- src/test/run-pass/process-remove-from-env.rs | 6 +- src/test/run-pass/running-with-no-runtime.rs | 37 ++- src/test/run-pass/segfault-no-out-of-stack.rs | 6 +- src/test/run-pass/signal-exit-status.rs | 12 +- src/test/run-pass/tcp-accept-stress.rs | 88 -------- src/test/run-pass/tcp-connect-timeouts.rs | 76 ------- src/test/run-pass/tempfile.rs | 213 ------------------ src/test/run-pass/ufcs-polymorphic-paths.rs | 16 +- src/test/run-pass/vector-sort-panic-safe.rs | 25 +- .../run-pass/wait-forked-but-failed-child.rs | 8 +- 36 files changed, 143 insertions(+), 721 deletions(-) delete mode 100644 src/test/run-pass/capturing-logging.rs delete mode 100644 src/test/run-pass/deriving-rand.rs delete mode 100644 src/test/run-pass/issue-12684.rs delete mode 100644 src/test/run-pass/issue-18619.rs delete mode 100644 src/test/run-pass/tcp-accept-stress.rs delete mode 100644 src/test/run-pass/tcp-connect-timeouts.rs delete mode 100644 src/test/run-pass/tempfile.rs diff --git a/src/test/run-pass-valgrind/cleanup-stdin.rs b/src/test/run-pass-valgrind/cleanup-stdin.rs index 301c4b91781..dcdce50c1e9 100644 --- a/src/test/run-pass-valgrind/cleanup-stdin.rs +++ b/src/test/run-pass-valgrind/cleanup-stdin.rs @@ -8,9 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(old_io, io)] - fn main() { - let _ = std::old_io::stdin(); let _ = std::io::stdin(); + let _ = std::io::stdout(); + let _ = std::io::stderr(); } diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs index 14d8bce061f..f4b62eb2e7c 100644 --- a/src/test/run-pass/backtrace.rs +++ b/src/test/run-pass/backtrace.rs @@ -11,11 +11,8 @@ // no-pretty-expanded FIXME #15189 // ignore-windows FIXME #13259 -#![feature(unboxed_closures)] -#![feature(unsafe_destructor, old_io, collections)] - use std::env; -use std::old_io::process::Command; +use std::process::{Command, Stdio}; use std::str; use std::ops::{Drop, FnMut, FnOnce}; @@ -40,44 +37,49 @@ fn double() { panic!("once"); } -fn runtest(me: &str) { - let mut template = Command::new(me); - template.env("IS_TEST", "1"); +fn template(me: &str) -> Command { + let mut m = Command::new(me); + m.env("IS_TEST", "1") + .stdout(Stdio::piped()) + .stderr(Stdio::piped()); + return m; +} +fn runtest(me: &str) { // Make sure that the stack trace is printed - let p = template.clone().arg("fail").env("RUST_BACKTRACE", "1").spawn().unwrap(); + let p = template(me).arg("fail").env("RUST_BACKTRACE", "1").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); - let s = str::from_utf8(&out.error).unwrap(); + let s = str::from_utf8(&out.stderr).unwrap(); assert!(s.contains("stack backtrace") && s.contains("foo::h"), "bad output: {}", s); // Make sure the stack trace is *not* printed // (Remove RUST_BACKTRACE from our own environment, in case developer // is running `make check` with it on.) - let p = template.clone().arg("fail").env_remove("RUST_BACKTRACE").spawn().unwrap(); + let p = template(me).arg("fail").env_remove("RUST_BACKTRACE").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); - let s = str::from_utf8(&out.error).unwrap(); + let s = str::from_utf8(&out.stderr).unwrap(); assert!(!s.contains("stack backtrace") && !s.contains("foo::h"), "bad output2: {}", s); // Make sure a stack trace is printed - let p = template.clone().arg("double-fail").spawn().unwrap(); + let p = template(me).arg("double-fail").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); - let s = str::from_utf8(&out.error).unwrap(); + let s = str::from_utf8(&out.stderr).unwrap(); // loosened the following from double::h to double:: due to // spurious failures on mac, 32bit, optimized assert!(s.contains("stack backtrace") && s.contains("double::"), "bad output3: {}", s); // Make sure a stack trace isn't printed too many times - let p = template.clone().arg("double-fail") + let p = template(me).arg("double-fail") .env("RUST_BACKTRACE", "1").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); - let s = str::from_utf8(&out.error).unwrap(); + let s = str::from_utf8(&out.stderr).unwrap(); let mut i = 0; for _ in 0..2 { i += s[i + 10..].find("stack backtrace").unwrap() + 10; diff --git a/src/test/run-pass/capturing-logging.rs b/src/test/run-pass/capturing-logging.rs deleted file mode 100644 index 6c58194f857..00000000000 --- a/src/test/run-pass/capturing-logging.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_LOG=info - - -#![allow(unknown_features)] -#![feature(box_syntax, old_io, rustc_private, std_misc)] - -#[macro_use] -extern crate log; - -use log::{set_logger, Logger, LogRecord}; -use std::sync::mpsc::channel; -use std::fmt; -use std::old_io::{ChanReader, ChanWriter, Reader, Writer}; -use std::thread; - -struct MyWriter(ChanWriter); - -impl Logger for MyWriter { - fn log(&mut self, record: &LogRecord) { - let MyWriter(ref mut inner) = *self; - write!(inner, "{}", record.args); - } -} - -fn main() { - let (tx, rx) = channel(); - let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); - let _t = thread::scoped(move|| { - set_logger(box MyWriter(w) as Box); - debug!("debug"); - info!("info"); - }); - let s = r.read_to_string().unwrap(); - assert!(s.contains("info")); - assert!(!s.contains("debug")); -} diff --git a/src/test/run-pass/closure-reform.rs b/src/test/run-pass/closure-reform.rs index fefab45714f..50f05c050b1 100644 --- a/src/test/run-pass/closure-reform.rs +++ b/src/test/run-pass/closure-reform.rs @@ -14,7 +14,6 @@ #![feature(unboxed_closures, old_io)] use std::mem; -use std::old_io::stdio::println; fn call_it(f: F) where F : FnOnce(String) -> String @@ -62,7 +61,8 @@ pub fn main() { // External functions - call_bare(println); + fn foo(s: &str) {} + call_bare(foo); - call_bare_again(println); + call_bare_again(foo); } diff --git a/src/test/run-pass/core-run-destroy.rs b/src/test/run-pass/core-run-destroy.rs index 03bf3851257..622084a86a6 100644 --- a/src/test/run-pass/core-run-destroy.rs +++ b/src/test/run-pass/core-run-destroy.rs @@ -16,34 +16,34 @@ // instead of in std. #![reexport_test_harness_main = "test_main"] -#![feature(old_io, libc, std_misc)] +#![feature(libc, std_misc)] extern crate libc; -use std::old_io::{Process, Command, timer}; -use std::time::Duration; +use std::process::{self, Command, Child, Output}; use std::str; use std::sync::mpsc::channel; use std::thread; +use std::time::Duration; -macro_rules! succeed { ($e:expr) => ( - match $e { Ok(..) => {}, Err(e) => panic!("panic: {}", e) } -) } +macro_rules! t { + ($e:expr) => (match $e { Ok(e) => e, Err(e) => panic!("error: {}", e) }) +} fn test_destroy_once() { let mut p = sleeper(); - match p.signal_exit() { + match p.kill() { Ok(()) => {} Err(e) => panic!("error: {}", e), } } #[cfg(unix)] -pub fn sleeper() -> Process { +pub fn sleeper() -> Child { Command::new("sleep").arg("1000").spawn().unwrap() } #[cfg(windows)] -pub fn sleeper() -> Process { +pub fn sleeper() -> Child { // There's a `timeout` command on windows, but it doesn't like having // its output piped, so instead just ping ourselves a few times with // gaps in between so we're sure this process is alive for awhile @@ -52,16 +52,12 @@ pub fn sleeper() -> Process { fn test_destroy_twice() { let mut p = sleeper(); - succeed!(p.signal_exit()); // this shouldn't crash... - let _ = p.signal_exit(); // ...and nor should this (and nor should the destructor) + t!(p.kill()); // this shouldn't crash... + let _ = p.kill(); // ...and nor should this (and nor should the destructor) } -pub fn test_destroy_actually_kills(force: bool) { - use std::old_io::process::{Command, ProcessOutput, ExitStatus, ExitSignal}; - use std::old_io::timer; - use libc; - use std::str; - +#[test] +fn test_destroy_actually_kills() { #[cfg(all(unix,not(target_os="android")))] static BLOCK_COMMAND: &'static str = "cat"; @@ -74,34 +70,16 @@ pub fn test_destroy_actually_kills(force: bool) { // this process will stay alive indefinitely trying to read from stdin let mut p = Command::new(BLOCK_COMMAND).spawn().unwrap(); - assert!(p.signal(0).is_ok()); - - if force { - p.signal_kill().unwrap(); - } else { - p.signal_exit().unwrap(); - } + p.kill().unwrap(); // Don't let this test time out, this should be quick - let (tx, rx1) = channel(); - let mut t = timer::Timer::new().unwrap(); - let rx2 = t.oneshot(Duration::milliseconds(1000)); + let (tx, rx) = channel(); thread::spawn(move|| { - select! { - _ = rx2.recv() => unsafe { libc::exit(1) }, - _ = rx1.recv() => {} + thread::sleep_ms(1000); + if rx.try_recv().is_err() { + process::exit(1); } }); - match p.wait().unwrap() { - ExitStatus(..) => panic!("expected a signal"), - ExitSignal(..) => tx.send(()).unwrap(), - } -} - -fn test_unforced_destroy_actually_kills() { - test_destroy_actually_kills(false); -} - -fn test_forced_destroy_actually_kills() { - test_destroy_actually_kills(true); + assert!(p.wait().unwrap().code().is_none()); + tx.send(()); } diff --git a/src/test/run-pass/deriving-global.rs b/src/test/run-pass/deriving-global.rs index 105d421b404..10e8ddc41f3 100644 --- a/src/test/run-pass/deriving-global.rs +++ b/src/test/run-pass/deriving-global.rs @@ -11,7 +11,6 @@ #![feature(rand, rustc_private)] extern crate serialize; -extern crate rand; mod submod { // if any of these are implemented without global calls for any @@ -20,21 +19,21 @@ mod submod { #[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, - Debug, Rand, + Debug, Encodable, Decodable)] enum A { A1(usize), A2(isize) } #[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, - Debug, Rand, + Debug, Encodable, Decodable)] struct B { x: usize, y: isize } #[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, - Debug, Rand, + Debug, Encodable, Decodable)] struct C(usize, isize); diff --git a/src/test/run-pass/deriving-rand.rs b/src/test/run-pass/deriving-rand.rs deleted file mode 100644 index bc11b55d310..00000000000 --- a/src/test/run-pass/deriving-rand.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#![feature(rand)] - -use std::rand; - -#[derive(Rand)] -struct A; - -#[derive(Rand)] -struct B(isize, isize); - -#[derive(Rand)] -struct C { - x: f64, - y: (u8, u8) -} - -#[derive(Rand)] -enum D { - D0, - D1(usize), - D2 { x: (), y: () } -} - -pub fn main() { - // check there's no segfaults - for _ in 0..20 { - rand::random::(); - rand::random::(); - rand::random::(); - rand::random::(); - } -} diff --git a/src/test/run-pass/drop-flag-sanity-check.rs b/src/test/run-pass/drop-flag-sanity-check.rs index 02f6cc70fd5..f9e1b651a49 100644 --- a/src/test/run-pass/drop-flag-sanity-check.rs +++ b/src/test/run-pass/drop-flag-sanity-check.rs @@ -17,10 +17,8 @@ // // See also drop-flag-skip-sanity-check.rs. -#![feature(old_io)] - use std::env; -use std::old_io::process::{Command, ExitSignal, ExitStatus}; +use std::process::Command; fn main() { let args: Vec = env::args().collect(); diff --git a/src/test/run-pass/drop-flag-skip-sanity-check.rs b/src/test/run-pass/drop-flag-skip-sanity-check.rs index 7066b4017af..32297360a80 100644 --- a/src/test/run-pass/drop-flag-skip-sanity-check.rs +++ b/src/test/run-pass/drop-flag-skip-sanity-check.rs @@ -20,7 +20,7 @@ #![feature(old_io)] use std::env; -use std::old_io::process::{Command, ExitSignal, ExitStatus}; +use std::process::Command; fn main() { let args: Vec = env::args().collect(); diff --git a/src/test/run-pass/issue-10626.rs b/src/test/run-pass/issue-10626.rs index 2c0811b69e0..0d8f2225485 100644 --- a/src/test/run-pass/issue-10626.rs +++ b/src/test/run-pass/issue-10626.rs @@ -15,7 +15,7 @@ #![feature(old_io)] use std::env; -use std::old_io::process; +use std::process::{Command, Stdio}; pub fn main () { let args: Vec = env::args().collect(); @@ -29,7 +29,7 @@ pub fn main () { return; } - let mut p = process::Command::new(&args[0]); - p.arg("child").stdout(process::Ignored).stderr(process::Ignored); + let mut p = Command::new(&args[0]); + p.arg("child").stdout(Stdio::null()).stderr(Stdio::null()); println!("{:?}", p.spawn().unwrap().wait()); } diff --git a/src/test/run-pass/issue-12684.rs b/src/test/run-pass/issue-12684.rs deleted file mode 100644 index 2b899155164..00000000000 --- a/src/test/run-pass/issue-12684.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// pretty-expanded FIXME #23616 - -#![feature(old_io, std_misc)] - -use std::time::Duration; -use std::thread; - -fn main() { - thread::spawn(move|| customtask()).join().ok().unwrap(); -} - -fn customtask() { - let mut timer = std::old_io::timer::Timer::new().unwrap(); - let periodic = timer.periodic(Duration::milliseconds(10)); - periodic.recv(); -} diff --git a/src/test/run-pass/issue-12699.rs b/src/test/run-pass/issue-12699.rs index ac5a9b728b9..1e9f30bb766 100644 --- a/src/test/run-pass/issue-12699.rs +++ b/src/test/run-pass/issue-12699.rs @@ -8,13 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 - -#![feature(old_io, std_misc)] - -use std::old_io::timer; -use std::time::Duration; +use std::thread; fn main() { - timer::sleep(Duration::milliseconds(250)); + thread::sleep_ms(250); } diff --git a/src/test/run-pass/issue-14901.rs b/src/test/run-pass/issue-14901.rs index 7e7886e3a6e..56683678469 100644 --- a/src/test/run-pass/issue-14901.rs +++ b/src/test/run-pass/issue-14901.rs @@ -8,11 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 - -#![feature(old_io)] - -use std::old_io::Reader; +pub trait Reader {} enum Wrapper<'a> { WrapReader(&'a (Reader + 'a)) diff --git a/src/test/run-pass/issue-15149.rs b/src/test/run-pass/issue-15149.rs index f6ffd03c81a..500235b74f6 100644 --- a/src/test/run-pass/issue-15149.rs +++ b/src/test/run-pass/issue-15149.rs @@ -10,14 +10,15 @@ // no-prefer-dynamic +#![feature(rustc_private)] -#![feature(fs, process, env, path, rand)] +extern crate rustc_back; use std::env; use std::fs; use std::process; -use std::rand::random; use std::str; +use rustc_back::tempdir::TempDir; fn main() { // If we're the child, make sure we were invoked correctly @@ -27,7 +28,8 @@ fn main() { // checking that it ends_with the executable name. This // is needed because of Windows, which has a different behavior. // See #15149 for more info. - return assert!(args[0].ends_with(&format!("mytest{}", env::consts::EXE_SUFFIX))); + return assert!(args[0].ends_with(&format!("mytest{}", + env::consts::EXE_SUFFIX))); } test(); @@ -38,9 +40,8 @@ fn test() { let my_path = env::current_exe().unwrap(); let my_dir = my_path.parent().unwrap(); - let random_u32: u32 = random(); - let child_dir = my_dir.join(&format!("issue-15149-child-{}", random_u32)); - fs::create_dir(&child_dir).unwrap(); + let child_dir = TempDir::new_in(&my_dir, "issue-15140-child").unwrap(); + let child_dir = child_dir.path(); let child_path = child_dir.join(&format!("mytest{}", env::consts::EXE_SUFFIX)); diff --git a/src/test/run-pass/issue-18619.rs b/src/test/run-pass/issue-18619.rs deleted file mode 100644 index a256e619216..00000000000 --- a/src/test/run-pass/issue-18619.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// pretty-expanded FIXME #23616 - -#![feature(old_io)] - -use std::old_io::FileType; - -pub fn main() { - let _ = FileType::RegularFile.clone(); -} diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index b05baa24b7a..2c45d664d89 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -11,10 +11,8 @@ // Map representation -#![feature(old_io)] - -use std::old_io; use std::fmt; +use std::io::prelude::*; use square::{bot, wall, rock, lambda, closed_lift, open_lift, earth, empty}; enum square { @@ -60,9 +58,9 @@ fn square_from_char(c: char) -> square { } } -fn read_board_grid(mut input: rdr) +fn read_board_grid(mut input: rdr) -> Vec> { - let mut input: &mut old_io::Reader = &mut input; + let mut input: &mut Read = &mut input; let mut grid = Vec::new(); let mut line = [0; 10]; input.read(&mut line); diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs index 29d963bb704..74e58f31e23 100644 --- a/src/test/run-pass/issue-3424.rs +++ b/src/test/run-pass/issue-3424.rs @@ -10,24 +10,17 @@ // rustc --test ignores2.rs && ./ignores2 -#![allow(unknown_features)] -#![feature(unboxed_closures, old_path, std_misc)] +pub struct Path; -use std::old_path::Path; -use std::old_path; -use std::result; -use std::thunk::Thunk; - -type rsrc_loader = Box (result::Result) + 'static>; +type rsrc_loader = Box Result>; fn tester() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - let mut loader: rsrc_loader = Box::new(move|_path| { - result::Result::Ok("more blah".to_string()) + let mut loader: rsrc_loader = Box::new(move |_path| { + Ok("more blah".to_string()) }); - let path = old_path::Path::new("blah"); + let path = Path; assert!(loader(&path).is_ok()); } diff --git a/src/test/run-pass/issue-4446.rs b/src/test/run-pass/issue-4446.rs index 9f8d93461a2..4660f21cdb2 100644 --- a/src/test/run-pass/issue-4446.rs +++ b/src/test/run-pass/issue-4446.rs @@ -10,9 +10,6 @@ // pretty-expanded FIXME #23616 -#![feature(old_io)] - -use std::old_io::println; use std::sync::mpsc::channel; use std::thread; @@ -22,6 +19,6 @@ pub fn main() { tx.send("hello, world").unwrap(); thread::spawn(move|| { - println(rx.recv().unwrap()); + println!("{}", rx.recv().unwrap()); }).join().ok().unwrap(); } diff --git a/src/test/run-pass/issue-5988.rs b/src/test/run-pass/issue-5988.rs index 8ec88d55721..2cf0089c6bb 100644 --- a/src/test/run-pass/issue-5988.rs +++ b/src/test/run-pass/issue-5988.rs @@ -10,9 +10,6 @@ // pretty-expanded FIXME #23616 -#![feature(old_io)] - -use std::old_io; trait B { fn f(&self); } @@ -23,7 +20,7 @@ trait T : B { struct A; impl B for U { - fn f(&self) { old_io::println("Hey, I'm a T!"); } + fn f(&self) { } } impl T for A { diff --git a/src/test/run-pass/issue-8398.rs b/src/test/run-pass/issue-8398.rs index 8eb10a199ea..5c2c03f9857 100644 --- a/src/test/run-pass/issue-8398.rs +++ b/src/test/run-pass/issue-8398.rs @@ -10,11 +10,11 @@ // pretty-expanded FIXME #23616 -#![feature(old_io, io)] +pub trait Writer { + fn write(&mut self, b: &[u8]) -> Result<(), ()>; +} -use std::old_io; - -fn foo(a: &mut old_io::Writer) { +fn foo(a: &mut Writer) { a.write(&[]).unwrap(); } diff --git a/src/test/run-pass/issue-9396.rs b/src/test/run-pass/issue-9396.rs index bfaf060e43c..34b2911cf86 100644 --- a/src/test/run-pass/issue-9396.rs +++ b/src/test/run-pass/issue-9396.rs @@ -10,18 +10,13 @@ // pretty-expanded FIXME #23616 -#![feature(old_io, std_misc)] - use std::sync::mpsc::{TryRecvError, channel}; -use std::old_io::timer::Timer; use std::thread; -use std::time::Duration; pub fn main() { let (tx, rx) = channel(); let _t = thread::scoped(move||{ - let mut timer = Timer::new().unwrap(); - timer.sleep(Duration::milliseconds(10)); + thread::sleep_ms(10); tx.send(()).unwrap(); }); loop { diff --git a/src/test/run-pass/logging-separate-lines.rs b/src/test/run-pass/logging-separate-lines.rs index b27080b65b7..29cfe91eba5 100644 --- a/src/test/run-pass/logging-separate-lines.rs +++ b/src/test/run-pass/logging-separate-lines.rs @@ -17,7 +17,7 @@ #[macro_use] extern crate log; -use std::old_io::Command; +use std::process::Command; use std::env; use std::str; @@ -31,9 +31,9 @@ fn main() { let p = Command::new(&args[0]) .arg("child") - .spawn().unwrap().wait_with_output().unwrap(); + .output().unwrap(); assert!(p.status.success()); - let mut lines = str::from_utf8(&p.error).unwrap().lines(); + let mut lines = str::from_utf8(&p.stderr).unwrap().lines(); assert!(lines.next().unwrap().contains("foo")); assert!(lines.next().unwrap().contains("bar")); } diff --git a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs index 25e0b272fd2..1611a2c0722 100644 --- a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs +++ b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs @@ -17,7 +17,8 @@ use std::mem; use std::slice; -use std::old_io::IoResult; + +pub type IoResult = Result; trait MyWriter { fn my_write(&mut self, buf: &[u8]) -> IoResult<()>; diff --git a/src/test/run-pass/out-of-stack-new-thread-no-split.rs b/src/test/run-pass/out-of-stack-new-thread-no-split.rs index f08ed6e7f9c..d321d9142ca 100644 --- a/src/test/run-pass/out-of-stack-new-thread-no-split.rs +++ b/src/test/run-pass/out-of-stack-new-thread-no-split.rs @@ -14,9 +14,9 @@ //ignore-dragonfly //ignore-bitrig -#![feature(asm, old_io, std_misc)] +#![feature(asm)] -use std::old_io::process::Command; +use std::process::Command; use std::env; use std::thread; @@ -41,7 +41,7 @@ fn main() { } else { let recurse = Command::new(&args[0]).arg("recurse").output().unwrap(); assert!(!recurse.status.success()); - let error = String::from_utf8_lossy(&recurse.error); + let error = String::from_utf8_lossy(&recurse.stderr); println!("wut"); println!("`{}`", error); assert!(error.contains("has overflowed its stack")); diff --git a/src/test/run-pass/out-of-stack-no-split.rs b/src/test/run-pass/out-of-stack-no-split.rs index 8887e1937c6..da7342d251e 100644 --- a/src/test/run-pass/out-of-stack-no-split.rs +++ b/src/test/run-pass/out-of-stack-no-split.rs @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//ignore-android -//ignore-linux -//ignore-freebsd -//ignore-ios -//ignore-dragonfly -//ignore-bitrig +// ignore-android +// ignore-linux +// ignore-freebsd +// ignore-ios +// ignore-dragonfly +// ignore-bitrig -#![feature(asm, old_io)] +#![feature(asm)] -use std::old_io::process::Command; +use std::process::Command; use std::env; // lifted from the test module @@ -41,7 +41,7 @@ fn main() { } else { let recurse = Command::new(&args[0]).arg("recurse").output().unwrap(); assert!(!recurse.status.success()); - let error = String::from_utf8_lossy(&recurse.error); + let error = String::from_utf8_lossy(&recurse.stderr); assert!(error.contains("has overflowed its stack")); } } diff --git a/src/test/run-pass/out-of-stack.rs b/src/test/run-pass/out-of-stack.rs index 47f83eab4c1..d90b88cbfd5 100644 --- a/src/test/run-pass/out-of-stack.rs +++ b/src/test/run-pass/out-of-stack.rs @@ -10,9 +10,9 @@ // ignore-android: FIXME (#20004) -#![feature(asm, old_io)] +#![feature(asm)] -use std::old_io::process::Command; +use std::process::Command; use std::env; // lifted from the test module @@ -42,12 +42,12 @@ fn main() { } else { let silent = Command::new(&args[0]).arg("silent").output().unwrap(); assert!(!silent.status.success()); - let error = String::from_utf8_lossy(&silent.error); + let error = String::from_utf8_lossy(&silent.stderr); assert!(error.contains("has overflowed its stack")); let loud = Command::new(&args[0]).arg("loud").output().unwrap(); assert!(!loud.status.success()); - let error = String::from_utf8_lossy(&silent.error); + let error = String::from_utf8_lossy(&silent.stderr); assert!(error.contains("has overflowed its stack")); } } diff --git a/src/test/run-pass/process-remove-from-env.rs b/src/test/run-pass/process-remove-from-env.rs index c6adda60679..3096fe4a266 100644 --- a/src/test/run-pass/process-remove-from-env.rs +++ b/src/test/run-pass/process-remove-from-env.rs @@ -9,9 +9,7 @@ // except according to those terms. -#![feature(old_io)] - -use std::old_io::Command; +use std::process::Command; use std::env; #[cfg(all(unix, not(target_os="android")))] @@ -49,7 +47,7 @@ fn main() { let prog = cmd.spawn().unwrap(); let result = prog.wait_with_output().unwrap(); - let output = String::from_utf8_lossy(&result.output); + let output = String::from_utf8_lossy(&result.stdout); assert!(!output.contains("RUN_TEST_NEW_ENV"), "found RUN_TEST_NEW_ENV inside of:\n\n{}", output); diff --git a/src/test/run-pass/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index abad08c7ac6..31d97305e0b 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -11,7 +11,7 @@ #![feature(start, os, std_misc, old_io)] use std::ffi::CStr; -use std::old_io::process::{Command, ProcessOutput}; +use std::process::{Command, Output}; use std::os; use std::rt::unwind::try; use std::rt; @@ -23,12 +23,12 @@ use std::thunk::Thunk; fn start(argc: isize, argv: *const *const u8) -> isize { if argc > 1 { unsafe { - match **argv.offset(1) { - 1 => {} - 2 => println!("foo"), - 3 => assert!(try(|| {}).is_ok()), - 4 => assert!(try(|| panic!()).is_err()), - 5 => assert!(Command::new("test").spawn().is_err()), + match **argv.offset(1) as char { + '1' => {} + '2' => println!("foo"), + '3' => assert!(try(|| {}).is_ok()), + '4' => assert!(try(|| panic!()).is_err()), + '5' => assert!(Command::new("test").spawn().is_err()), _ => panic!() } } @@ -41,25 +41,20 @@ fn start(argc: isize, argv: *const *const u8) -> isize { CStr::from_ptr(ptr).to_bytes().to_vec() }).collect::>() }; - let me = &*args[0]; + let me = String::from_utf8(args[0].to_vec()).unwrap(); - let x: &[u8] = &[1]; - pass(Command::new(me).arg(x).output().unwrap()); - let x: &[u8] = &[2]; - pass(Command::new(me).arg(x).output().unwrap()); - let x: &[u8] = &[3]; - pass(Command::new(me).arg(x).output().unwrap()); - let x: &[u8] = &[4]; - pass(Command::new(me).arg(x).output().unwrap()); - let x: &[u8] = &[5]; - pass(Command::new(me).arg(x).output().unwrap()); + pass(Command::new(&me).arg("1").output().unwrap()); + pass(Command::new(&me).arg("2").output().unwrap()); + pass(Command::new(&me).arg("3").output().unwrap()); + pass(Command::new(&me).arg("4").output().unwrap()); + pass(Command::new(&me).arg("5").output().unwrap()); 0 } -fn pass(output: ProcessOutput) { +fn pass(output: Output) { if !output.status.success() { - println!("{:?}", str::from_utf8(&output.output)); - println!("{:?}", str::from_utf8(&output.error)); + println!("{:?}", str::from_utf8(&output.stdout)); + println!("{:?}", str::from_utf8(&output.stderr)); } } diff --git a/src/test/run-pass/segfault-no-out-of-stack.rs b/src/test/run-pass/segfault-no-out-of-stack.rs index 385c5326c97..dd33c330cfd 100644 --- a/src/test/run-pass/segfault-no-out-of-stack.rs +++ b/src/test/run-pass/segfault-no-out-of-stack.rs @@ -9,9 +9,7 @@ // except according to those terms. -#![feature(old_io)] - -use std::old_io::process::Command; +use std::process::Command; use std::env; fn main() { @@ -21,7 +19,7 @@ fn main() { } else { let segfault = Command::new(&args[0]).arg("segfault").output().unwrap(); assert!(!segfault.status.success()); - let error = String::from_utf8_lossy(&segfault.error); + let error = String::from_utf8_lossy(&segfault.stderr); assert!(!error.contains("has overflowed its stack")); } } diff --git a/src/test/run-pass/signal-exit-status.rs b/src/test/run-pass/signal-exit-status.rs index bfc4aee7757..51b369092f0 100644 --- a/src/test/run-pass/signal-exit-status.rs +++ b/src/test/run-pass/signal-exit-status.rs @@ -10,11 +10,8 @@ // ignore-windows -#![feature(old_io)] -#![feature(os)] - use std::env; -use std::old_io::process::{Command, ExitSignal, ExitStatus}; +use std::process::Command; pub fn main() { let args: Vec = env::args().collect(); @@ -23,11 +20,6 @@ pub fn main() { unsafe { *(0 as *mut isize) = 0; } } else { let status = Command::new(&args[0]).arg("signal").status().unwrap(); - // Windows does not have signal, so we get exit status 0xC0000028 (STATUS_BAD_STACK). - match status { - ExitSignal(_) if cfg!(unix) => {}, - ExitStatus(0xC0000028) if cfg!(windows) => {}, - _ => panic!("invalid termination (was not signalled): {}", status) - } + assert!(status.code().is_none()); } } diff --git a/src/test/run-pass/tcp-accept-stress.rs b/src/test/run-pass/tcp-accept-stress.rs deleted file mode 100644 index 00467e56334..00000000000 --- a/src/test/run-pass/tcp-accept-stress.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-macos osx really doesn't like cycling through large numbers of -// sockets as calls to connect() will start returning EADDRNOTAVAIL -// quite quickly and it takes a few seconds for the sockets to get -// recycled. - -#![feature(old_io, io, std_misc)] - -use std::old_io::{TcpListener, Listener, Acceptor, EndOfFile, TcpStream}; -use std::sync::Arc; -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::mpsc::channel; -use std::thread; - -static N: usize = 8; -static M: usize = 20; - -fn main() { - test(); -} - -fn test() { - let mut l = TcpListener::bind("127.0.0.1:0").unwrap(); - let addr = l.socket_name().unwrap(); - let mut a = l.listen().unwrap(); - let cnt = Arc::new(AtomicUsize::new(0)); - - let (srv_tx, srv_rx) = channel(); - let (cli_tx, cli_rx) = channel(); - let _t = (0..N).map(|_| { - let a = a.clone(); - let cnt = cnt.clone(); - let srv_tx = srv_tx.clone(); - thread::scoped(move|| { - let mut a = a; - loop { - match a.accept() { - Ok(..) => { - if cnt.fetch_add(1, Ordering::SeqCst) == N * M - 1 { - break - } - } - Err(ref e) if e.kind == EndOfFile => break, - Err(e) => panic!("{}", e), - } - } - srv_tx.send(()); - }) - }).collect::>(); - - let _t = (0..N).map(|_| { - let cli_tx = cli_tx.clone(); - thread::scoped(move|| { - for _ in 0..M { - let _s = TcpStream::connect(addr).unwrap(); - } - cli_tx.send(()); - }) - }).collect::>(); - drop((cli_tx, srv_tx)); - - // wait for senders - if cli_rx.iter().take(N).count() != N { - a.close_accept().unwrap(); - panic!("clients panicked"); - } - - // wait for one acceptor to die - let _ = srv_rx.recv(); - - // Notify other receivers should die - a.close_accept().unwrap(); - - // wait for receivers - assert_eq!(srv_rx.iter().take(N - 1).count(), N - 1); - - // Everything should have been accepted. - assert_eq!(cnt.load(Ordering::SeqCst), N * M); -} diff --git a/src/test/run-pass/tcp-connect-timeouts.rs b/src/test/run-pass/tcp-connect-timeouts.rs deleted file mode 100644 index 64f07a60b35..00000000000 --- a/src/test/run-pass/tcp-connect-timeouts.rs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-pretty -// compile-flags:--test -// exec-env:RUST_TEST_THREADS=1 - -// Tests for the connect_timeout() function on a TcpStream. This runs with only -// one test task to ensure that errors are timeouts, not file descriptor -// exhaustion. - -#![reexport_test_harness_main = "test_main"] - -#![allow(unused_imports)] -#![feature(old_io, std_misc, io)] - -use std::old_io::*; -use std::old_io::test::*; -use std::old_io; -use std::time::Duration; -use std::sync::mpsc::channel; -use std::thread; - -#[cfg_attr(target_os = "freebsd", ignore)] -fn eventual_timeout() { - let addr = next_test_ip4(); - - let (tx1, rx1) = channel(); - let (_tx2, rx2) = channel::<()>(); - let _t = thread::scoped(move|| { - let _l = TcpListener::bind(addr).unwrap().listen(); - tx1.send(()).unwrap(); - let _ = rx2.recv(); - }); - rx1.recv().unwrap(); - - let mut v = Vec::new(); - for _ in 0_usize..10000 { - match TcpStream::connect_timeout(addr, Duration::milliseconds(100)) { - Ok(e) => v.push(e), - Err(ref e) if e.kind == old_io::TimedOut => return, - Err(e) => panic!("other error: {}", e), - } - } - panic!("never timed out!"); -} - -fn timeout_success() { - let addr = next_test_ip4(); - let _l = TcpListener::bind(addr).unwrap().listen(); - - assert!(TcpStream::connect_timeout(addr, Duration::milliseconds(1000)).is_ok()); -} - -fn timeout_error() { - let addr = next_test_ip4(); - - assert!(TcpStream::connect_timeout(addr, Duration::milliseconds(1000)).is_err()); -} - -fn connect_timeout_zero() { - let addr = next_test_ip4(); - assert!(TcpStream::connect_timeout(addr, Duration::milliseconds(0)).is_err()); -} - -fn connect_timeout_negative() { - let addr = next_test_ip4(); - assert!(TcpStream::connect_timeout(addr, Duration::milliseconds(-1)).is_err()); -} diff --git a/src/test/run-pass/tempfile.rs b/src/test/run-pass/tempfile.rs deleted file mode 100644 index 49fac24d0b3..00000000000 --- a/src/test/run-pass/tempfile.rs +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-windows TempDir may cause IoError on windows: #10463 - -// These tests are here to exercise the functionality of the `tempfile` module. -// One might expect these tests to be located in that module, but sadly they -// cannot. The tests need to invoke `os::change_dir` which cannot be done in the -// normal test infrastructure. If the tests change the current working -// directory, then *all* tests which require relative paths suddenly break b/c -// they're in a different location than before. Hence, these tests are all run -// serially here. - -#![feature(old_io, old_path, os, old_fs)] - -use std::old_path::{Path, GenericPath}; -use std::old_io::fs::PathExtensions; -use std::old_io::{fs, TempDir}; -use std::old_io; -use std::env; -use std::sync::mpsc::channel; -use std::thread; - -fn test_tempdir() { - let path = { - let p = TempDir::new_in(&Path::new("."), "foobar").unwrap(); - let p = p.path(); - assert!(p.as_str().unwrap().contains("foobar")); - p.clone() - }; - assert!(!path.exists()); -} - -fn test_rm_tempdir() { - let (tx, rx) = channel(); - let f = move|| -> () { - let tmp = TempDir::new("test_rm_tempdir").unwrap(); - tx.send(tmp.path().clone()).unwrap(); - panic!("panic to unwind past `tmp`"); - }; - thread::spawn(f).join(); - let path = rx.recv().unwrap(); - assert!(!path.exists()); - - let tmp = TempDir::new("test_rm_tempdir").unwrap(); - let path = tmp.path().clone(); - let f = move|| -> () { - let _tmp = tmp; - panic!("panic to unwind past `tmp`"); - }; - thread::spawn(f).join(); - assert!(!path.exists()); - - let path; - { - let f = move || { - TempDir::new("test_rm_tempdir").unwrap() - }; - // FIXME(#16640) `: TempDir` annotation shouldn't be necessary - let tmp: TempDir = thread::scoped(f).join(); - path = tmp.path().clone(); - assert!(path.exists()); - } - assert!(!path.exists()); - - let path; - { - let tmp = TempDir::new("test_rm_tempdir").unwrap(); - path = tmp.into_inner(); - } - assert!(path.exists()); - fs::rmdir_recursive(&path); - assert!(!path.exists()); -} - -fn test_rm_tempdir_close() { - let (tx, rx) = channel(); - let f = move|| -> () { - let tmp = TempDir::new("test_rm_tempdir").unwrap(); - tx.send(tmp.path().clone()).unwrap(); - tmp.close(); - panic!("panic when unwinding past `tmp`"); - }; - thread::spawn(f).join(); - let path = rx.recv().unwrap(); - assert!(!path.exists()); - - let tmp = TempDir::new("test_rm_tempdir").unwrap(); - let path = tmp.path().clone(); - let f = move|| -> () { - let tmp = tmp; - tmp.close(); - panic!("panic when unwinding past `tmp`"); - }; - thread::spawn(f).join(); - assert!(!path.exists()); - - let path; - { - let f = move || { - TempDir::new("test_rm_tempdir").unwrap() - }; - // FIXME(#16640) `: TempDir` annotation shouldn't be necessary - let tmp: TempDir = thread::scoped(f).join(); - path = tmp.path().clone(); - assert!(path.exists()); - tmp.close(); - } - assert!(!path.exists()); - - let path; - { - let tmp = TempDir::new("test_rm_tempdir").unwrap(); - path = tmp.into_inner(); - } - assert!(path.exists()); - fs::rmdir_recursive(&path); - assert!(!path.exists()); -} - -// Ideally these would be in std::os but then core would need -// to depend on std -fn recursive_mkdir_rel() { - let path = Path::new("frob"); - let cwd = Path::new(env::current_dir().unwrap().to_str().unwrap()); - println!("recursive_mkdir_rel: Making: {} in cwd {} [{}]", path.display(), - cwd.display(), path.exists()); - fs::mkdir_recursive(&path, old_io::USER_RWX); - assert!(path.is_dir()); - fs::mkdir_recursive(&path, old_io::USER_RWX); - assert!(path.is_dir()); -} - -fn recursive_mkdir_dot() { - let dot = Path::new("."); - fs::mkdir_recursive(&dot, old_io::USER_RWX); - let dotdot = Path::new(".."); - fs::mkdir_recursive(&dotdot, old_io::USER_RWX); -} - -fn recursive_mkdir_rel_2() { - let path = Path::new("./frob/baz"); - let cwd = Path::new(env::current_dir().unwrap().to_str().unwrap()); - println!("recursive_mkdir_rel_2: Making: {} in cwd {} [{}]", path.display(), - cwd.display(), path.exists()); - fs::mkdir_recursive(&path, old_io::USER_RWX); - assert!(path.is_dir()); - assert!(path.dir_path().is_dir()); - let path2 = Path::new("quux/blat"); - println!("recursive_mkdir_rel_2: Making: {} in cwd {}", path2.display(), - cwd.display()); - fs::mkdir_recursive(&path2, old_io::USER_RWX); - assert!(path2.is_dir()); - assert!(path2.dir_path().is_dir()); -} - -// Ideally this would be in core, but needs TempFile -pub fn test_rmdir_recursive_ok() { - let rwx = old_io::USER_RWX; - - let tmpdir = TempDir::new("test").ok().expect("test_rmdir_recursive_ok: \ - couldn't create temp dir"); - let tmpdir = tmpdir.path(); - let root = tmpdir.join("foo"); - - println!("making {}", root.display()); - fs::mkdir(&root, rwx); - fs::mkdir(&root.join("foo"), rwx); - fs::mkdir(&root.join("foo").join("bar"), rwx); - fs::mkdir(&root.join("foo").join("bar").join("blat"), rwx); - fs::rmdir_recursive(&root); - assert!(!root.exists()); - assert!(!root.join("bar").exists()); - assert!(!root.join("bar").join("blat").exists()); -} - -pub fn dont_double_panic() { - let r: Result<(), _> = thread::spawn(move|| { - let tmpdir = TempDir::new("test").unwrap(); - // Remove the temporary directory so that TempDir sees - // an error on drop - fs::rmdir(tmpdir.path()); - // Panic. If TempDir panics *again* due to the rmdir - // error then the process will abort. - panic!(); - }).join(); - assert!(r.is_err()); -} - -fn in_tmpdir(f: F) where F: FnOnce() { - let tmpdir = TempDir::new("test").ok().expect("can't make tmpdir"); - assert!(env::set_current_dir(tmpdir.path().as_str().unwrap()).is_ok()); - - f(); -} - -pub fn main() { - in_tmpdir(test_tempdir); - in_tmpdir(test_rm_tempdir); - in_tmpdir(test_rm_tempdir_close); - in_tmpdir(recursive_mkdir_rel); - in_tmpdir(recursive_mkdir_dot); - in_tmpdir(recursive_mkdir_rel_2); - in_tmpdir(test_rmdir_recursive_ok); - in_tmpdir(dont_double_panic); -} diff --git a/src/test/run-pass/ufcs-polymorphic-paths.rs b/src/test/run-pass/ufcs-polymorphic-paths.rs index db3581976bb..eec852ae181 100644 --- a/src/test/run-pass/ufcs-polymorphic-paths.rs +++ b/src/test/run-pass/ufcs-polymorphic-paths.rs @@ -17,11 +17,19 @@ use std::default::Default; use std::iter::FromIterator; use std::ops::Add; use std::option::IntoIter as OptionIter; -use std::rand::Rand; -use std::rand::XorShiftRng as DummyRng; -// FIXME the glob std::prelude::*; import of Vec is missing non-static inherent methods. +// FIXME the glob std::prelude::*; import of Vec is missing non-static inherent +// methods. use std::vec::Vec; +pub struct XorShiftRng; +use XorShiftRng as DummyRng; +impl Rng for XorShiftRng {} +pub trait Rng {} +pub trait Rand: Default + Sized { + fn rand(rng: &mut R) -> Self { Default::default() } +} +impl Rand for i32 { } + #[derive(PartialEq, Eq)] struct Newt(T); @@ -29,7 +37,7 @@ fn id(x: T) -> T { x } fn eq(a: T, b: T) -> bool { a == b } fn u8_as_i8(x: u8) -> i8 { x as i8 } fn odd(x: usize) -> bool { x % 2 == 1 } -fn dummy_rng() -> DummyRng { DummyRng::new_unseeded() } +fn dummy_rng() -> DummyRng { XorShiftRng } trait Size: Sized { fn size() -> usize { std::mem::size_of::() } diff --git a/src/test/run-pass/vector-sort-panic-safe.rs b/src/test/run-pass/vector-sort-panic-safe.rs index acb29d284b9..a51274199b6 100644 --- a/src/test/run-pass/vector-sort-panic-safe.rs +++ b/src/test/run-pass/vector-sort-panic-safe.rs @@ -12,7 +12,7 @@ #![feature(rand, core)] use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; -use std::rand::{thread_rng, Rng, Rand}; +use std::__rand::{thread_rng, Rng}; use std::thread; const REPEATS: usize = 5; @@ -36,18 +36,7 @@ static drop_counts: [AtomicUsize; MAX_LEN] = static creation_count: AtomicUsize = ATOMIC_USIZE_INIT; #[derive(Clone, PartialEq, PartialOrd, Eq, Ord)] -struct DropCounter { x: usize, creation_id: usize } - -impl Rand for DropCounter { - fn rand(rng: &mut R) -> DropCounter { - // (we're not using this concurrently, so Relaxed is fine.) - let num = creation_count.fetch_add(1, Ordering::Relaxed); - DropCounter { - x: rng.gen(), - creation_id: num - } - } -} +struct DropCounter { x: u32, creation_id: usize } impl Drop for DropCounter { fn drop(&mut self) { @@ -64,9 +53,13 @@ pub fn main() { // IDs start from 0. creation_count.store(0, Ordering::Relaxed); - let main = thread_rng().gen_iter::() - .take(len) - .collect::>(); + let mut rng = thread_rng(); + let main = (0..len).map(|_| { + DropCounter { + x: rng.next_u32(), + creation_id: creation_count.fetch_add(1, Ordering::Relaxed), + } + }).collect::>(); // work out the total number of comparisons required to sort // this array... diff --git a/src/test/run-pass/wait-forked-but-failed-child.rs b/src/test/run-pass/wait-forked-but-failed-child.rs index 998360f08ba..1d0004bafa3 100644 --- a/src/test/run-pass/wait-forked-but-failed-child.rs +++ b/src/test/run-pass/wait-forked-but-failed-child.rs @@ -9,11 +9,11 @@ // except according to those terms. -#![feature(libc, old_io)] +#![feature(libc)] extern crate libc; -use std::old_io::process::Command; +use std::process::Command; use libc::funcs::posix88::unistd; @@ -38,7 +38,7 @@ fn find_zombies() { // http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html let ps_cmd_output = Command::new("ps").args(&["-A", "-o", "pid,ppid,args"]).output().unwrap(); - let ps_output = String::from_utf8_lossy(&ps_cmd_output.output); + let ps_output = String::from_utf8_lossy(&ps_cmd_output.stdout); for (line_no, line) in ps_output.split('\n').enumerate() { if 0 < line_no && 0 < line.len() && @@ -59,7 +59,7 @@ fn main() { let too_long = format!("/NoSuchCommand{:0300}", 0u8); let _failures = (0..100).map(|_| { - let cmd = Command::new(&too_long); + let mut cmd = Command::new(&too_long); let failed = cmd.spawn(); assert!(failed.is_err(), "Make sure the command fails to spawn(): {:?}", cmd); failed