diff --git a/Cargo.lock b/Cargo.lock index fc044abef..1a92674f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,26 +4,27 @@ version = "0.1.0" dependencies = [ "advapi32-sys 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "docopt 0.6.47 (registry+https://github.com/rust-lang/crates.io-index)", + "docopt 0.6.51 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "git2-curl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "glob 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)", - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "registry 0.1.0", - "rustc-serialize 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "tar 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -46,9 +47,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -56,7 +57,7 @@ name = "curl-sys" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -64,12 +65,12 @@ dependencies = [ [[package]] name = "docopt" -version = "0.6.47" +version = "0.6.51" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -78,7 +79,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -86,7 +87,7 @@ name = "flate2" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -97,13 +98,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "git2" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -112,20 +113,20 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "glob" -version = "0.2.3" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hamcrest" version = "0.1.0" -source = "git+https://github.com/carllerche/hamcrest-rust.git#c90897390602ef1ad29de8988cc8b0ed23b540cd" +source = "git+https://github.com/carllerche/hamcrest-rust.git#27a3368a915aabdee09c9f2c515127689715c1d9" [[package]] name = "kernel32-sys" @@ -137,16 +138,16 @@ dependencies = [ [[package]] name = "libc" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libssh2-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libssh2-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -162,10 +163,10 @@ dependencies = [ [[package]] name = "libssh2-sys" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -195,7 +196,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -204,7 +205,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libressl-pnacl-sys 2.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -224,13 +225,13 @@ name = "rand" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -238,12 +239,12 @@ name = "registry" version = "0.1.0" dependencies = [ "curl 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-serialize" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -253,7 +254,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "tar" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -266,11 +267,10 @@ dependencies = [ [[package]] name = "term" -version = "0.1.13" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -281,11 +281,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "time" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -293,16 +293,16 @@ name = "toml" version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-serialize 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "url" -version = "0.2.23" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -310,6 +310,6 @@ name = "winapi" version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index 8e9ae24f8..f88b90f9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,16 +24,16 @@ env_logger = "0.2.2" docopt = "0.6.45" url = "0.2.23" rustc-serialize = "0.3.1" -term = "0.1.13" +term = "0.2" regex = "0.1.18" threadpool = "0.1.1" libc = "0.1.2" registry = { path = "src/registry" } [target.i686-pc-windows-gnu] -dependencies = { winapi = "0.1", advapi32-sys = "*" } +dependencies = { winapi = "0.1", advapi32-sys = "*", kernel32-sys = "*" } [target.x86_64-pc-windows-gnu] -dependencies = { winapi = "0.1", advapi32-sys = "*" } +dependencies = { winapi = "0.1", advapi32-sys = "*", kernel32-sys = "*" } [dev-dependencies] tempdir = "0.3" diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index e87288d1d..0ad3a53c2 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -1,4 +1,4 @@ -#![feature(core, io, path, std_misc, exit_status)] +#![feature(core, io, std_misc, exit_status)] extern crate "git2-curl" as git2_curl; extern crate "rustc-serialize" as rustc_serialize; diff --git a/src/bin/verify_project.rs b/src/bin/verify_project.rs index 43056c13d..dcef2c479 100644 --- a/src/bin/verify_project.rs +++ b/src/bin/verify_project.rs @@ -31,7 +31,7 @@ pub fn execute(args: Flags, config: &Config) -> CliResult> { let mut contents = String::new(); let file = File::open(&args.flag_manifest_path); match file.and_then(|mut f| f.read_to_string(&mut contents)) { - Ok(()) => {}, + Ok(_) => {}, Err(e) => return fail("invalid", &format!("error reading file: {}", e)) }; match toml::Parser::new(&contents).parse() { diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index 775e73e77..ad28ae63d 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -1,5 +1,6 @@ use std::fmt; -use std::old_io::{IoResult, stderr}; +use std::io::prelude::*; +use std::io; use term::Attr; use term::color::{Color, BLACK, RED, GREEN, YELLOW}; @@ -15,7 +16,7 @@ pub struct ShellConfig { } enum AdequateTerminal { - NoColor(Box), + NoColor(Box), Colored(Box + Send>) } @@ -31,7 +32,7 @@ pub struct MultiShell { } struct UghWhyIsThisNecessary { - inner: Box, + inner: Box, } impl MultiShell { @@ -47,35 +48,35 @@ impl MultiShell { &mut self.err } - pub fn say(&mut self, message: T, color: Color) -> IoResult<()> { + pub fn say(&mut self, message: T, color: Color) -> io::Result<()> { self.out().say(message, color) } - pub fn status(&mut self, status: T, message: U) -> IoResult<()> + pub fn status(&mut self, status: T, message: U) -> io::Result<()> where T: fmt::Display, U: fmt::Display { self.out().say_status(status, message, GREEN) } - pub fn verbose(&mut self, mut callback: F) -> IoResult<()> - where F: FnMut(&mut MultiShell) -> IoResult<()> + pub fn verbose(&mut self, mut callback: F) -> io::Result<()> + where F: FnMut(&mut MultiShell) -> io::Result<()> { if self.verbose { return callback(self) } Ok(()) } - pub fn concise(&mut self, mut callback: F) -> IoResult<()> - where F: FnMut(&mut MultiShell) -> IoResult<()> + pub fn concise(&mut self, mut callback: F) -> io::Result<()> + where F: FnMut(&mut MultiShell) -> io::Result<()> { if !self.verbose { return callback(self) } Ok(()) } - pub fn error(&mut self, message: T) -> IoResult<()> { + pub fn error(&mut self, message: T) -> io::Result<()> { self.err().say(message, RED) } - pub fn warn(&mut self, message: T) -> IoResult<()> { + pub fn warn(&mut self, message: T) -> io::Result<()> { self.err().say(message, YELLOW) } @@ -89,7 +90,7 @@ impl MultiShell { } impl Shell { - pub fn create(out: Box, config: ShellConfig) -> Shell { + pub fn create(out: Box, config: ShellConfig) -> Shell { let out = UghWhyIsThisNecessary { inner: out }; if config.tty && config.color { let term = TerminfoTerminal::new(out); @@ -97,58 +98,58 @@ impl Shell { terminal: Colored(Box::new(t)), config: config }).unwrap_or_else(|| { - Shell { terminal: NoColor(Box::new(stderr())), config: config } + Shell { terminal: NoColor(Box::new(io::stderr())), config: config } }) } else { Shell { terminal: NoColor(out.inner), config: config } } } - pub fn verbose(&mut self, mut callback: F) -> IoResult<()> - where F: FnMut(&mut Shell) -> IoResult<()> + pub fn verbose(&mut self, mut callback: F) -> io::Result<()> + where F: FnMut(&mut Shell) -> io::Result<()> { if self.config.verbose { return callback(self) } Ok(()) } - pub fn concise(&mut self, mut callback: F) -> IoResult<()> - where F: FnMut(&mut Shell) -> IoResult<()> + pub fn concise(&mut self, mut callback: F) -> io::Result<()> + where F: FnMut(&mut Shell) -> io::Result<()> { if !self.config.verbose { return callback(self) } Ok(()) } - pub fn say(&mut self, message: T, color: Color) -> IoResult<()> { + pub fn say(&mut self, message: T, color: Color) -> io::Result<()> { try!(self.reset()); if color != BLACK { try!(self.fg(color)); } - try!(self.write_line(&message.to_string())); + try!(write!(self, "{}\n", message.to_string())); try!(self.reset()); try!(self.flush()); Ok(()) } pub fn say_status(&mut self, status: T, message: U, color: Color) - -> IoResult<()> + -> io::Result<()> where T: fmt::Display, U: fmt::Display { try!(self.reset()); if color != BLACK { try!(self.fg(color)); } if self.supports_attr(Attr::Bold) { try!(self.attr(Attr::Bold)); } - try!(self.write_str(&format!("{:>12}", status))); + try!(write!(self, "{:>12}", status.to_string())); try!(self.reset()); - try!(self.write_line(&format!(" {}", message))); + try!(write!(self, " {}\n", message)); try!(self.flush()); Ok(()) } - fn fg(&mut self, color: color::Color) -> IoResult { + fn fg(&mut self, color: color::Color) -> io::Result { match self.terminal { Colored(ref mut c) => c.fg(color), NoColor(_) => Ok(false) } } - fn attr(&mut self, attr: Attr) -> IoResult { + fn attr(&mut self, attr: Attr) -> io::Result { match self.terminal { Colored(ref mut c) => c.attr(attr), NoColor(_) => Ok(false) @@ -162,7 +163,7 @@ impl Shell { } } - fn reset(&mut self) -> IoResult<()> { + fn reset(&mut self) -> io::Result<()> { match self.terminal { Colored(ref mut c) => c.reset().map(|_| ()), NoColor(_) => Ok(()) @@ -170,15 +171,15 @@ impl Shell { } } -impl Writer for Shell { - fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { +impl Write for Shell { + fn write(&mut self, buf: &[u8]) -> io::Result { match self.terminal { - Colored(ref mut c) => c.write_all(buf), - NoColor(ref mut n) => n.write_all(buf) + Colored(ref mut c) => c.write(buf), + NoColor(ref mut n) => n.write(buf) } } - fn flush(&mut self) -> IoResult<()> { + fn flush(&mut self) -> io::Result<()> { match self.terminal { Colored(ref mut c) => c.flush(), NoColor(ref mut n) => n.flush() @@ -186,8 +187,11 @@ impl Writer for Shell { } } -impl Writer for UghWhyIsThisNecessary { - fn write_all(&mut self, bytes: &[u8]) -> IoResult<()> { - self.inner.write_all(bytes) +impl Write for UghWhyIsThisNecessary { + fn write(&mut self, bytes: &[u8]) -> io::Result { + self.inner.write(bytes) + } + fn flush(&mut self) -> io::Result<()> { + self.inner.flush() } } diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index 9eb6bbd93..fe9e33171 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -3,7 +3,7 @@ use std::collections::hash_map::{HashMap, Values, IterMut}; use std::fmt::{self, Formatter}; use std::hash; use std::mem; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::sync::Arc; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; @@ -198,7 +198,7 @@ impl SourceId { match self.inner.kind { Kind::Git(..) => Box::new(GitSource::new(self, config)) as Box, Kind::Path => { - let path = match self.inner.url.to_file_path::() { + let path = match self.inner.url.to_file_path() { Ok(p) => p, Err(()) => panic!("path sources cannot be remote"), }; diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 348cec6d0..cf35f1f49 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -1,6 +1,6 @@ #![deny(unused)] -#![feature(hash, os, std_misc, core)] -#![feature(io, path, str_words, old_io, exit_status, fs_time)] +#![feature(hash, os, std_misc, core, path_relative_from)] +#![feature(io, str_words, exit_status, fs_time)] #![cfg_attr(test, deny(warnings))] #[cfg(test)] extern crate hamcrest; @@ -25,8 +25,8 @@ extern crate registry; use std::env; use std::error::Error; -use std::old_io::stdio::{stdout_raw, stderr_raw}; -use std::old_io::{self, stdout, stderr}; +use std::io::prelude::*; +use std::io; use rustc_serialize::{Decodable, Encodable}; use rustc_serialize::json::{self, Json}; use docopt::Docopt; @@ -119,21 +119,39 @@ pub fn process_executed(result: CliResult>, shell: &mut MultiShell) } pub fn shell(verbose: bool) -> MultiShell { - let tty = stderr_raw().isatty(); - let stderr = Box::new(stderr()) as Box; + let tty = isatty(libc::STDERR_FILENO); + let stderr = Box::new(io::stderr()); let config = ShellConfig { color: true, verbose: verbose, tty: tty }; let err = Shell::create(stderr, config); - let tty = stdout_raw().isatty(); - let stdout = Box::new(stdout()) as Box; + let tty = isatty(libc::STDOUT_FILENO); + let stdout = Box::new(io::stdout()); let config = ShellConfig { color: true, verbose: verbose, tty: tty }; let out = Shell::create(stdout, config); - MultiShell::new(out, err, verbose) -} + return MultiShell::new(out, err, verbose); + #[cfg(unix)] + fn isatty(fd: libc::c_int) -> bool { + unsafe { libc::isatty(fd) != 0 } + } + #[cfg(windows)] + fn isatty(fd: libc::c_int) -> bool { + extern crate "kernel32-sys" as kernel32; + extern crate winapi; + unsafe { + let handle = kernel32::GetStdHandle(if fd == libc::STDOUT_FILENO { + winapi::winbase::STD_OUTPUT_HANDLE + } else { + winapi::winbase::STD_ERROR_HANDLE + }); + let mut out = 0; + kernel32::GetConsoleMode(handle, &mut out) != 0 + } + } +} // `output` print variant error strings to either stderr or stdout. // For fatal errors, print to stderr; @@ -216,8 +234,9 @@ fn flags_from_args<'a, T>(usage: &str, args: &[String], } fn json_from_stdin() -> CliResult { - let mut reader = old_io::stdin(); - let input = try!(reader.read_to_string().map_err(|_| { + let mut reader = io::stdin(); + let mut input = String::new(); + try!(reader.read_to_string(&mut input).map_err(|_| { CliError::new("Standard in did not exist or was not UTF-8", 1) })); diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index f9fd404a0..63de500f1 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -25,7 +25,6 @@ use std::collections::HashMap; use std::default::Default; use std::num::ToPrimitive; -use std::os; use std::path::{Path, PathBuf}; use std::sync::Arc; @@ -205,7 +204,9 @@ fn scrape_build_config(config: &Config, } None => None, }; - let jobs = jobs.or(cfg_jobs).unwrap_or(os::num_cpus() as u32); + #[allow(deprecated)] + fn num_cpus() -> u32 { ::std::os::num_cpus() as u32 } + let jobs = jobs.or(cfg_jobs).unwrap_or(num_cpus()); let mut base = ops::BuildConfig { jobs: jobs, requested_target: target.clone(), diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index efb7d99e4..1194d1159 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -141,7 +141,7 @@ fn it_works() { fn discover_author() -> CargoResult<(String, Option)> { let git_config = GitConfig::open_default().ok(); let git_config = git_config.as_ref(); - let name = git_config.and_then(|g| g.get_str("user.name").ok()) + let name = git_config.and_then(|g| g.get_string("user.name").ok()) .map(|s| s.to_string()) .or_else(|| env::var("USER").ok()) // unix .or_else(|| env::var("USERNAME").ok()); // windows @@ -153,7 +153,7 @@ fn discover_author() -> CargoResult<(String, Option)> { user, please set ${}", username_var))) } }; - let email = git_config.and_then(|g| g.get_str("user.email").ok()); + let email = git_config.and_then(|g| g.get_string("user.email").ok()); let name = name.trim().to_string(); let email = email.map(|s| s.trim().to_string()); diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index a49d500de..b1b463750 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -1,7 +1,6 @@ use std::fmt; use std::path::{Path, PathBuf}; use std::fs; -use std::io::prelude::*; use rustc_serialize::{Encodable, Encoder}; use url::Url; @@ -286,7 +285,7 @@ impl<'a> GitCheckout<'a> { fn reset(&self) -> CargoResult<()> { info!("reset {} to {}", self.repo.path().display(), self.revision); let object = try!(self.repo.find_object(self.revision.0, None)); - try!(self.repo.reset(&object, git2::ResetType::Hard, None, None, None)); + try!(self.repo.reset(&object, git2::ResetType::Hard, None)); Ok(()) } @@ -338,7 +337,7 @@ impl<'a> GitCheckout<'a> { })); let obj = try!(repo.find_object(head, None)); - try!(repo.reset(&obj, git2::ResetType::Hard, None, None, None)); + try!(repo.reset(&obj, git2::ResetType::Hard, None)); try!(update_submodules(&repo)); } Ok(()) @@ -371,11 +370,16 @@ fn with_authentication(url: &str, cfg: &git2::Config, mut f: F) cred_helper.config(cfg); let mut cred_error = false; let ret = f(&mut |url, username, allowed| { - let creds = if allowed.contains(git2::SSH_KEY) { + let creds = if allowed.contains(git2::SSH_KEY) || + allowed.contains(git2::USERNAME) { let user = username.map(|s| s.to_string()) .or_else(|| cred_helper.username.clone()) .unwrap_or("git".to_string()); - git2::Cred::ssh_key_from_agent(&user) + if allowed.contains(git2::USERNAME) { + git2::Cred::username(&user) + } else { + git2::Cred::ssh_key_from_agent(&user) + } } else if allowed.contains(git2::USER_PASS_PLAINTEXT) { git2::Cred::credential_helper(cfg, url, username) } else if allowed.contains(git2::DEFAULT) { @@ -405,7 +409,7 @@ pub fn fetch(repo: &git2::Repository, url: &str, let mut remote = try!(repo.remote_anonymous(&url, Some(refspec))); try!(remote.add_fetch("refs/tags/*:refs/tags/*")); remote.set_callbacks(&mut cb); - try!(remote.fetch(&["refs/tags/*:refs/tags/*", refspec], None, None)); + try!(remote.fetch(&["refs/tags/*:refs/tags/*", refspec], None)); Ok(()) }) } diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 6e56f9941..49c750416 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -9,7 +9,7 @@ use git2; use core::{Package, PackageId, Summary, SourceId, Source, Dependency, Registry}; use ops; -use util::{self, CargoResult, internal, internal_error, human, ChainError, Config}; +use util::{CargoResult, internal, internal_error, human, ChainError, Config}; pub struct PathSource<'a, 'b: 'a> { id: SourceId, @@ -138,10 +138,6 @@ impl<'a, 'b> PathSource<'a, 'b> { None => return Err(internal_error("Can't list files on a bare repository.", "")), }; - // Right now there is a bug such that "/a/b".relative_from("/a/") - // returns `None` so here we chop of the trailing slash if there is one. - // It is unclear to me whether this is actually a bug with paths or not. - let root = util::lose_the_slash(&root); let pkg_path = pkg.root(); let mut ret = Vec::new(); diff --git a/src/cargo/sources/registry.rs b/src/cargo/sources/registry.rs index 3159aa9c0..cf5db84ea 100644 --- a/src/cargo/sources/registry.rs +++ b/src/cargo/sources/registry.rs @@ -456,7 +456,7 @@ impl<'a, 'b> RegistrySource<'a, 'b> { let oid = try!(repo.refname_to_id(reference)); trace!("[{}] updating to rev {}", self.source_id, oid); let object = try!(repo.find_object(oid, None)); - try!(repo.reset(&object, git2::ResetType::Hard, None, None, None)); + try!(repo.reset(&object, git2::ResetType::Hard, None)); self.updated = true; self.cache.clear(); Ok(()) diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 45ccc20df..a58bfb7b7 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -2,7 +2,6 @@ use std::error::{FromError, Error}; use std::ffi; use std::fmt; use std::io; -use std::old_io::IoError; use std::process::{Output, ExitStatus}; use std::str; @@ -255,7 +254,6 @@ macro_rules! from_error { from_error! { semver::ReqParseError, - IoError, io::Error, ProcessError, git2::Error, @@ -273,7 +271,6 @@ impl FromError> for Box { } impl CargoError for semver::ReqParseError {} -impl CargoError for IoError {} impl CargoError for io::Error {} impl CargoError for git2::Error {} impl CargoError for json::DecoderError {} diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs index 14f16393f..6334b0ddb 100644 --- a/src/cargo/util/mod.rs +++ b/src/cargo/util/mod.rs @@ -5,7 +5,7 @@ pub use self::errors::{CliError, ProcessError}; pub use self::errors::{process_error, internal_error, internal, human}; pub use self::errors::{Human, caused_human}; pub use self::paths::{join_paths, path2bytes, bytes2path, dylib_path}; -pub use self::paths::{normalize_path, lose_the_slash}; +pub use self::paths::normalize_path; pub use self::lev_distance::{lev_distance}; pub use self::hex::{to_hex, short_hash}; pub use self::dependency_queue::{DependencyQueue, Fresh, Dirty, Freshness}; diff --git a/src/cargo/util/paths.rs b/src/cargo/util/paths.rs index 9f736f381..a13d534c5 100644 --- a/src/cargo/util/paths.rs +++ b/src/cargo/util/paths.rs @@ -26,8 +26,9 @@ pub fn dylib_path() -> Vec { } pub fn normalize_path(path: &Path) -> PathBuf { - let mut components = path.components(); - let mut ret = if let Some(c @ Component::Prefix { .. }) = components.peek() { + let mut components = path.components().peekable(); + let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek() + .cloned() { components.next(); PathBuf::new(c.as_os_str()) } else { @@ -36,8 +37,7 @@ pub fn normalize_path(path: &Path) -> PathBuf { for component in components { match component { - Component::Prefix { .. } => unreachable!(), - Component::Empty => { ret.push(""); } + Component::Prefix(..) => unreachable!(), Component::RootDir => { ret.push(component.as_os_str()); } Component::CurDir => {} Component::ParentDir => { ret.pop(); } @@ -47,15 +47,6 @@ pub fn normalize_path(path: &Path) -> PathBuf { return ret; } -/// Chop off the trailing slash of a path -pub fn lose_the_slash(path: &Path) -> &Path { - let mut components = path.components(); - match components.next_back() { - Some(Component::CurDir) => components.as_path(), - _ => path, - } -} - #[cfg(unix)] pub fn path2bytes(path: &Path) -> CargoResult<&[u8]> { use std::os::unix::prelude::*; diff --git a/src/cargo/util/sha256.rs b/src/cargo/util/sha256.rs index 40d7518bf..f00818773 100644 --- a/src/cargo/util/sha256.rs +++ b/src/cargo/util/sha256.rs @@ -72,7 +72,7 @@ mod imp { mod imp { extern crate winapi; extern crate "advapi32-sys" as advapi32; - use std::os; + use std::io; use std::ptr; use self::winapi::{DWORD, HCRYPTPROV, HCRYPTHASH}; @@ -82,7 +82,7 @@ mod imp { macro_rules! call{ ($e:expr) => ({ if $e == 0 { - panic!("failed {}: {}", stringify!($e), os::last_os_error()) + panic!("failed {}: {}", stringify!($e), io::Error::last_os_error()) } }) } diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 35e130418..603adcb65 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -2,7 +2,6 @@ use std::collections::HashMap; use std::default::Default; use std::fmt; use std::fs; -use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::slice; use std::str; diff --git a/src/registry/lib.rs b/src/registry/lib.rs index 93b94b66c..5bb06b25b 100644 --- a/src/registry/lib.rs +++ b/src/registry/lib.rs @@ -1,5 +1,3 @@ -#![feature(io, path)] - extern crate curl; extern crate "rustc-serialize" as rustc_serialize; diff --git a/src/rustversion.txt b/src/rustversion.txt index d9ca78f0e..cadd5e2ca 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2015-03-11 +2015-03-14 diff --git a/tests/test_cargo_build_auth.rs b/tests/test_cargo_build_auth.rs index eaa495f3e..da306c1a5 100644 --- a/tests/test_cargo_build_auth.rs +++ b/tests/test_cargo_build_auth.rs @@ -39,7 +39,7 @@ test!(http_auth_offered { assert_eq!(req, vec![ "GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1", "Accept: */*", - "User-Agent: git/1.0 (libgit2 0.21.0)", + "User-Agent: git/1.0 (libgit2 0.22.0)", ].into_iter().map(|s| s.to_string()).collect()); drop(s); @@ -54,7 +54,7 @@ test!(http_auth_offered { "GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1", "Authorization: Basic Zm9vOmJhcg==", "Accept: */*", - "User-Agent: git/1.0 (libgit2 0.21.0)", + "User-Agent: git/1.0 (libgit2 0.22.0)", ].into_iter().map(|s| s.to_string()).collect()); }); diff --git a/tests/test_cargo_build_lib.rs b/tests/test_cargo_build_lib.rs index ec20d6e53..97320184a 100644 --- a/tests/test_cargo_build_lib.rs +++ b/tests/test_cargo_build_lib.rs @@ -1,4 +1,4 @@ -use std::old_path; +use std::path::MAIN_SEPARATOR as SEP; use support::{basic_bin_manifest, execs, project, ProjectBuilder}; use support::{COMPILING, RUNNING}; use hamcrest::{assert_that}; @@ -17,7 +17,7 @@ fn verbose_output_for_lib(p: &ProjectBuilder) -> String { -L dependency={dir}{sep}target{sep}debug \ -L dependency={dir}{sep}target{sep}debug{sep}deps` ", - running = RUNNING, compiling = COMPILING, sep = old_path::SEP, + running = RUNNING, compiling = COMPILING, sep = SEP, dir = p.root().display(), url = p.url(), name = "foo", version = "0.0.1") } diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index 253f81812..b3fc84c1a 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -1573,10 +1573,9 @@ test!(compile_then_delete { assert_that(p.cargo_process("run"), execs().with_status(0)); assert_that(&p.bin("foo"), existing_file()); if cfg!(windows) { - // HACKHACK: On windows unlinking immediately after running often fails, so sleep - use std::old_io::timer::sleep; + // On windows unlinking immediately after running often fails, so sleep use std::time::duration::Duration; - sleep(Duration::milliseconds(100)); + ::sleep(Duration::milliseconds(100)); } fs::remove_file(&p.bin("foo")).unwrap(); assert_that(p.cargo("run"), diff --git a/tests/test_cargo_compile_git_deps.rs b/tests/test_cargo_compile_git_deps.rs index df4aeff81..cae0dcadd 100644 --- a/tests/test_cargo_compile_git_deps.rs +++ b/tests/test_cargo_compile_git_deps.rs @@ -1,6 +1,5 @@ use std::fs::{self, File}; use std::io::prelude::*; -use std::old_io::timer; use std::path::Path; use std::time::Duration; use git2; @@ -56,7 +55,7 @@ fn add_submodule<'a>(repo: &'a git2::Repository, url: &str, let subrepo = s.open().unwrap(); let mut origin = subrepo.find_remote("origin").unwrap(); origin.add_fetch("refs/heads/*:refs/heads/*").unwrap(); - origin.fetch(&[], None, None).unwrap(); + origin.fetch(&[], None).unwrap(); origin.save().unwrap(); subrepo.checkout_head(None).unwrap(); s.add_finalize().unwrap(); @@ -163,7 +162,7 @@ test!(cargo_compile_git_dep_branch { let repo = git2::Repository::open(&git_project.root()).unwrap(); let head = repo.head().unwrap().target().unwrap(); let head = repo.find_commit(head).unwrap(); - repo.branch("branchy", &head, true, None, None).unwrap(); + repo.branch("branchy", &head, true).unwrap(); let project = project .file("Cargo.toml", &format!(r#" @@ -699,7 +698,7 @@ test!(update_with_shared_deps { add(&repo); commit(&repo); - timer::sleep(Duration::milliseconds(1000)); + ::sleep(Duration::milliseconds(1000)); // By default, not transitive updates println!("dep1 update"); @@ -891,7 +890,7 @@ test!(stale_cached_version { add(&repo); commit(&repo); - timer::sleep(Duration::milliseconds(1000)); + ::sleep(Duration::milliseconds(1000)); let rev = repo.revparse_single("HEAD").unwrap().id(); @@ -987,17 +986,17 @@ test!(dep_with_changed_submodule { let mut origin = subrepo.find_remote("origin").unwrap(); origin.set_url(git_project3.url().to_string().as_slice()).unwrap(); origin.add_fetch("refs/heads/*:refs/heads/*").unwrap();; - origin.fetch(&[], None, None).unwrap(); + origin.fetch(&[], None).unwrap(); origin.save().unwrap(); let id = subrepo.refname_to_id("refs/remotes/origin/master").unwrap(); let obj = subrepo.find_object(id, None).unwrap(); - subrepo.reset(&obj, git2::ResetType::Hard, None, None, None).unwrap(); + subrepo.reset(&obj, git2::ResetType::Hard, None).unwrap(); } sub.add_to_index(true).unwrap(); add(&repo); commit(&repo); - timer::sleep(Duration::milliseconds(1000)); + ::sleep(Duration::milliseconds(1000)); // Update the dependency and carry on! println!("update"); assert_that(project.cargo("update").arg("-v"), @@ -1095,7 +1094,7 @@ test!(git_build_cmd_freshness { }).unwrap(); foo.root().move_into_the_past().unwrap(); - timer::sleep(Duration::milliseconds(1000)); + ::sleep(Duration::milliseconds(1000)); assert_that(foo.cargo("build"), execs().with_status(0) diff --git a/tests/test_cargo_compile_path_deps.rs b/tests/test_cargo_compile_path_deps.rs index b2dfb2ab2..d4e19c306 100644 --- a/tests/test_cargo_compile_path_deps.rs +++ b/tests/test_cargo_compile_path_deps.rs @@ -1,6 +1,5 @@ use std::fs::{self, File}; use std::io::prelude::*; -use std::old_io::timer; use std::time::Duration; use support::{project, execs, main_file}; @@ -353,7 +352,7 @@ test!(deep_dependencies_trigger_rebuild { // // We base recompilation off mtime, so sleep for at least a second to ensure // that this write will change the mtime. - timer::sleep(Duration::seconds(1)); + ::sleep(Duration::seconds(1)); File::create(&p.root().join("baz/src/baz.rs")).unwrap().write_all(br#" pub fn baz() { println!("hello!"); } "#).unwrap(); @@ -366,7 +365,7 @@ test!(deep_dependencies_trigger_rebuild { COMPILING, p.url()))); // Make sure an update to bar doesn't trigger baz - timer::sleep(Duration::seconds(1)); + ::sleep(Duration::seconds(1)); File::create(&p.root().join("bar/src/bar.rs")).unwrap().write_all(br#" extern crate baz; pub fn bar() { println!("hello!"); baz::baz(); } diff --git a/tests/test_cargo_profiles.rs b/tests/test_cargo_profiles.rs index 1940fe567..e42e7f19e 100644 --- a/tests/test_cargo_profiles.rs +++ b/tests/test_cargo_profiles.rs @@ -1,5 +1,5 @@ use std::env; -use std::old_path; +use std::path::MAIN_SEPARATOR as SEP; use support::{project, execs}; use support::{COMPILING, RUNNING}; @@ -38,7 +38,7 @@ test!(profile_overrides { -L dependency={dir}{sep}target{sep}debug \ -L dependency={dir}{sep}target{sep}debug{sep}deps` ", -running = RUNNING, compiling = COMPILING, sep = old_path::SEP, +running = RUNNING, compiling = COMPILING, sep = SEP, dir = p.root().display(), url = p.url(), ))); @@ -109,7 +109,7 @@ test!(top_level_overrides_deps { compiling = COMPILING, dir = p.root().display(), url = p.url(), - sep = old_path::SEP, + sep = SEP, prefix = env::consts::DLL_PREFIX, suffix = env::consts::DLL_SUFFIX).as_slice())); }); diff --git a/tests/test_cargo_run.rs b/tests/test_cargo_run.rs index 7311b4af2..15d61e906 100644 --- a/tests/test_cargo_run.rs +++ b/tests/test_cargo_run.rs @@ -1,4 +1,4 @@ -use std::old_path; +use std::path::MAIN_SEPARATOR as SEP; use support::{project, execs, path2url}; use support::{COMPILING, RUNNING}; @@ -28,7 +28,7 @@ hello compiling = COMPILING, running = RUNNING, dir = path2url(p.root()), - sep = old_path::SEP).as_slice())); + sep = SEP).as_slice())); assert_that(&p.bin("foo"), existing_file()); }); @@ -129,7 +129,7 @@ hello a.rs compiling = COMPILING, running = RUNNING, dir = path2url(p.root()), - sep = old_path::SEP).as_slice())); + sep = SEP).as_slice())); assert_that(p.cargo("run").arg("--bin").arg("b"), execs().with_status(0).with_stdout(format!("\ @@ -137,7 +137,7 @@ hello a.rs hello b.rs ", running = RUNNING, - sep = old_path::SEP).as_slice())); + sep = SEP).as_slice())); }); test!(run_example { @@ -165,7 +165,7 @@ example compiling = COMPILING, running = RUNNING, dir = path2url(p.root()), - sep = old_path::SEP).as_slice())); + sep = SEP).as_slice())); }); test!(either_name_or_example { @@ -217,7 +217,7 @@ hello main.rs compiling = COMPILING, running = RUNNING, dir = path2url(p.root()), - sep = old_path::SEP).as_slice())); + sep = SEP).as_slice())); }); test!(example_with_release_flag { @@ -292,7 +292,7 @@ fast2 running = RUNNING, dir = p.root().display(), url = path2url(p.root()), - sep = old_path::SEP).as_slice())); + sep = SEP).as_slice())); assert_that(p.cargo("run").arg("-v").arg("--example").arg("a"), execs().with_status(0).with_stdout(format!("\ @@ -321,7 +321,7 @@ slow2 running = RUNNING, dir = p.root().display(), url = path2url(p.root()), - sep = old_path::SEP).as_slice())); + sep = SEP).as_slice())); }); test!(run_dylib_dep { @@ -375,7 +375,7 @@ test!(release_works { compiling = COMPILING, running = RUNNING, dir = path2url(p.root()), - sep = old_path::SEP).as_slice())); + sep = SEP).as_slice())); assert_that(&p.release_bin("foo"), existing_file()); }); diff --git a/tests/test_shell.rs b/tests/test_shell.rs index 559f672cb..a325165e8 100644 --- a/tests/test_shell.rs +++ b/tests/test_shell.rs @@ -1,5 +1,6 @@ -use std::old_io::{MemWriter, IoResult, ChanReader, ChanWriter}; -use std::sync::mpsc::channel; +use std::io::prelude::*; +use std::io; +use std::sync::{Arc, Mutex}; use term::{Terminal, TerminfoTerminal, color}; use hamcrest::{assert_that}; @@ -10,56 +11,60 @@ use support::{Tap, shell_writes}; fn setup() { } -fn pair() -> (ChanWriter, ChanReader) { - let (tx, rx) = channel(); - (ChanWriter::new(tx), ChanReader::new(rx)) +struct Sink(Arc>>); + +impl Write for Sink { + fn write(&mut self, data: &[u8]) -> io::Result { + Write::write(&mut *self.0.lock().unwrap(), data) + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } } test!(non_tty { let config = ShellConfig { color: true, verbose: true, tty: false }; - let (tx, mut rx) = pair(); + let a = Arc::new(Mutex::new(Vec::new())); - Shell::create(Box::new(tx), config).tap(|shell| { + Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| { shell.say("Hey Alex", color::RED).unwrap(); }); - let buf = rx.read_to_end().unwrap(); - assert_that(buf.as_slice(), shell_writes("Hey Alex\n")); + let buf = a.lock().unwrap().clone(); + assert_that(&buf[..], shell_writes("Hey Alex\n")); }); test!(color_explicitly_disabled { let config = ShellConfig { color: false, verbose: true, tty: true }; - let (tx, mut rx) = pair(); + let a = Arc::new(Mutex::new(Vec::new())); - Shell::create(Box::new(tx), config).tap(|shell| { + Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| { shell.say("Hey Alex", color::RED).unwrap(); }); - let buf = rx.read_to_end().unwrap(); - assert_that(buf.as_slice(), shell_writes("Hey Alex\n")); + let buf = a.lock().unwrap().clone(); + assert_that(&buf[..], shell_writes("Hey Alex\n")); }); test!(colored_shell { - let term = TerminfoTerminal::new(MemWriter::new()); + let term = TerminfoTerminal::new(Vec::new()); if term.is_none() { return } let config = ShellConfig { color: true, verbose: true, tty: true }; - let (tx, mut rx) = pair(); + let a = Arc::new(Mutex::new(Vec::new())); - Shell::create(Box::new(tx), config).tap(|shell| { + Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| { shell.say("Hey Alex", color::RED).unwrap(); }); - let buf = rx.read_to_end().unwrap(); - assert_that(buf.as_slice(), + let buf = a.lock().unwrap().clone(); + assert_that(&buf[..], shell_writes(colored_output("Hey Alex\n", color::RED).unwrap())); }); -fn colored_output(string: S, color: color::Color) -> IoResult { - let mut term = TerminfoTerminal::new(MemWriter::new()).unwrap(); +fn colored_output(string: &str, color: color::Color) -> io::Result { + let mut term = TerminfoTerminal::new(Vec::new()).unwrap(); try!(term.reset()); try!(term.fg(color)); - try!(term.write_str(string.as_slice())); + try!(write!(&mut term, "{}", string)); try!(term.reset()); try!(term.flush()); - Ok(String::from_utf8_lossy(term.get_ref().get_ref()).to_string()) + Ok(String::from_utf8_lossy(term.get_ref()).to_string()) } diff --git a/tests/tests.rs b/tests/tests.rs index 356690d86..f5c790ba4 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,5 +1,5 @@ -#![feature(core, io, old_io, old_path)] -#![feature(std_misc, io, path, fs, net, path_ext, fs_time, fs_walk)] +#![feature(core, io, old_io)] +#![feature(std_misc, io, fs, net, path_ext, fs_time, fs_walk)] extern crate "rustc-serialize" as serialize; extern crate cargo; @@ -53,3 +53,8 @@ mod test_cargo_search; mod test_cargo_test; mod test_cargo_version; mod test_shell; + +#[allow(deprecated)] +fn sleep(dur: std::time::Duration) { + std::old_io::timer::sleep(dur) +}