rpass: Remove io_error usage

This commit is contained in:
Alex Crichton 2014-01-30 11:56:51 -08:00
parent 6132f7f666
commit 29e7247fd8
7 changed files with 27 additions and 23 deletions

View File

@ -43,5 +43,5 @@ fn main() {
debug!("debug");
info!("info");
});
assert_eq!(r.read_to_str(), ~"info\n");
assert_eq!(r.read_to_str().unwrap(), ~"info\n");
}

View File

@ -27,8 +27,7 @@ fn test_destroy_once() {
#[cfg(target_os="android")]
static PROG: &'static str = "ls"; // android don't have echo binary
let mut p = run::Process::new(PROG, [], run::ProcessOptions::new())
.expect(format!("failed to exec `{}`", PROG));
let mut p = run::Process::new(PROG, [], run::ProcessOptions::new()).unwrap();
p.destroy(); // this shouldn't crash (and nor should the destructor)
}
@ -39,12 +38,12 @@ fn test_destroy_twice() {
#[cfg(target_os="android")]
static PROG: &'static str = "ls"; // android don't have echo binary
let mut p = run::Process::new(PROG, [], run::ProcessOptions::new())
.expect(format!("failed to exec `{}`", PROG));
let mut p = match run::Process::new(PROG, [], run::ProcessOptions::new()) {
Ok(p) => p,
Err(e) => fail!("wut: {}", e),
};
p.destroy(); // this shouldnt crash...
io::io_error::cond.trap(|_| {}).inside(|| {
p.destroy(); // ...and nor should this (and nor should the destructor)
})
p.destroy(); // ...and nor should this (and nor should the destructor)
}
fn test_destroy_actually_kills(force: bool) {
@ -61,14 +60,14 @@ fn test_destroy_actually_kills(force: bool) {
#[cfg(unix,not(target_os="android"))]
fn process_exists(pid: libc::pid_t) -> bool {
let run::ProcessOutput {output, ..} = run::process_output("ps", [~"-p", pid.to_str()])
.expect("failed to exec `ps`");
.unwrap();
str::from_utf8_owned(output).unwrap().contains(pid.to_str())
}
#[cfg(unix,target_os="android")]
fn process_exists(pid: libc::pid_t) -> bool {
let run::ProcessOutput {output, ..} = run::process_output("/system/bin/ps", [pid.to_str()])
.expect("failed to exec `/system/bin/ps`");
.unwrap();
str::from_utf8_owned(output).unwrap().contains(~"root")
}
@ -93,7 +92,7 @@ fn test_destroy_actually_kills(force: bool) {
// this process will stay alive indefinitely trying to read from stdin
let mut p = run::Process::new(BLOCK_COMMAND, [], run::ProcessOptions::new())
.expect(format!("failed to exec `{}`", BLOCK_COMMAND));
.unwrap();
assert!(process_exists(p.get_id()));

View File

@ -12,6 +12,7 @@
#[feature(macro_rules)];
#[deny(warnings)];
#[allow(unused_must_use)];
use std::fmt;
use std::io::MemWriter;
@ -22,10 +23,14 @@ struct A;
struct B;
impl fmt::Signed for A {
fn fmt(_: &A, f: &mut fmt::Formatter) { f.buf.write("aloha".as_bytes()); }
fn fmt(_: &A, f: &mut fmt::Formatter) -> fmt::Result {
f.buf.write("aloha".as_bytes())
}
}
impl fmt::Signed for B {
fn fmt(_: &B, f: &mut fmt::Formatter) { f.buf.write("adios".as_bytes()); }
fn fmt(_: &B, f: &mut fmt::Formatter) -> fmt::Result {
f.buf.write("adios".as_bytes())
}
}
macro_rules! t(($a:expr, $b:expr) => { assert_eq!($a, $b.to_owned()) })
@ -286,9 +291,9 @@ fn test_format_args() {
let mut buf = MemWriter::new();
{
let w = &mut buf as &mut io::Writer;
format_args!(|args| { fmt::write(w, args) }, "{}", 1);
format_args!(|args| { fmt::write(w, args) }, "test");
format_args!(|args| { fmt::write(w, args) }, "{test}", test=3);
format_args!(|args| { fmt::write(w, args); }, "{}", 1);
format_args!(|args| { fmt::write(w, args); }, "test");
format_args!(|args| { fmt::write(w, args); }, "{test}", test=3);
}
let s = str::from_utf8_owned(buf.unwrap()).unwrap();
t!(s, "1test3");

View File

@ -11,7 +11,7 @@
use std::io;
fn foo(a: &mut io::Writer) {
a.write([])
a.write([]).unwrap();
}
pub fn main(){}

View File

@ -17,10 +17,11 @@ use std::fmt;
struct Foo(Cell<int>);
impl fmt::Show for Foo {
fn fmt(f: &Foo, _fmt: &mut fmt::Formatter) {
fn fmt(f: &Foo, _fmt: &mut fmt::Formatter) -> fmt::Result {
let Foo(ref f) = *f;
assert!(f.get() == 0);
f.set(1);
Ok(())
}
}

View File

@ -19,8 +19,7 @@ pub fn main() {
// Raise a segfault.
unsafe { *(0 as *mut int) = 0; }
} else {
let status = run::process_status(args[0], [~"signal"])
.expect("failed to exec `signal`");
let status = run::process_status(args[0], [~"signal"]).unwrap();
// Windows does not have signal, so we get exit status 0xC0000028 (STATUS_BAD_STACK).
match status {
process::ExitSignal(_) if cfg!(unix) => {},

View File

@ -21,8 +21,8 @@ pub fn main() {
{
match File::create(&path) {
None => unreachable!(),
Some(f) => {
Err(..) => unreachable!(),
Ok(f) => {
let mut f = f;
for _ in range(0u, 1000) {
f.write([0]);
@ -32,5 +32,5 @@ pub fn main() {
}
assert!(path.exists());
assert_eq!(path.stat().size, 1000);
assert_eq!(path.stat().unwrap().size, 1000);
}