about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-04-14 12:18:37 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-04-14 13:50:03 -0700
commit30425bfe54318049e07d97602742b7ee6c745b3a (patch)
treea4d6d17d9db493c0ba7e6e9a563a4f48bf26fd47
parentb9d9a376ea8843f46ccf9f043dbffa5ac2d1c073 (diff)
downloadrust-30425bfe54318049e07d97602742b7ee6c745b3a.tar.gz
rust-30425bfe54318049e07d97602742b7ee6c745b3a.zip
Test fixes and rebase conflicts
-rw-r--r--src/librustc/middle/stability.rs3
-rw-r--r--src/libstd/path.rs2
-rw-r--r--src/libsyntax/print/pprust.rs2
-rw-r--r--src/test/run-pass/tcp-accept-stress.rs91
-rw-r--r--src/test/run-pass/tcp-connect-timeouts.rs77
-rw-r--r--src/test/run-pass/tempfile.rs213
6 files changed, 4 insertions, 384 deletions
diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs
index 39a8c45b4d7..e7c25d82150 100644
--- a/src/librustc/middle/stability.rs
+++ b/src/librustc/middle/stability.rs
@@ -96,7 +96,8 @@ impl<'a> Annotator<'a> {
                 if tag == "unstable" || tag == "stable" || tag == "deprecated" {
                     attr::mark_used(attr);
                     self.sess.span_warn(attr.span(),
-                                        "stability attributes are deprecated and will soon become errors");
+                                        "stability attributes are deprecated \
+                                         and will soon become errors");
                 }
             }
             f(self);
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index 4247dc1b6d8..b7160df6c92 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -1570,7 +1570,7 @@ impl Path {
     /// # Examples
     ///
     /// ```
-    /// use std::path::Path;
+    /// use std::path::{Path, PathBuf};
     ///
     /// let path = Path::new("/tmp/foo.rs");
     ///
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index cb743eff36c..3f883fb1172 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -352,7 +352,7 @@ pub fn stmt_to_string(stmt: &ast::Stmt) -> String {
     $to_string(|s| s.print_stmt(stmt))
 }
 
-pub fn attr_to_string(attr: &ast::Attr) -> String {
+pub fn attr_to_string(attr: &ast::Attribute) -> String {
     $to_string(|s| s.print_attribute(attr))
 }
 
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 3347287748e..00000000000
--- a/src/test/run-pass/tcp-accept-stress.rs
+++ /dev/null
@@ -1,91 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 ts1 = (0..N).map(|_| {
-        let a = a.clone();
-        let cnt = cnt.clone();
-        let srv_tx = srv_tx.clone();
-        thread::spawn(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::<Vec<_>>();
-
-    let ts2 = (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::<Vec<_>>();
-    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);
-
-    for t in ts1 { t.join() }
-    for t in ts2 { t.join() }
-}
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 c31400a832c..00000000000
--- a/src/test/run-pass/tcp-connect-timeouts.rs
+++ /dev/null
@@ -1,77 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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::spawn(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!");
-    t.join();
-}
-
-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 3f99c338c0e..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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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::spawn(f).join().unwrap();
-        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::spawn(f).join().unwrap();
-        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: 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);
-}