Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rpass: Remove io_error usage
  • Loading branch information
alexcrichton committed Feb 3, 2014
commit 29e7247fd8be5a9879ebcd1a3ddc47e2fa743abd
2 changes: 1 addition & 1 deletion src/test/run-pass/capturing-logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
19 changes: 9 additions & 10 deletions src/test/run-pass/core-run-destroy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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) {
Expand All @@ -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")
}

Expand All @@ -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()));

Expand Down
15 changes: 10 additions & 5 deletions src/test/run-pass/ifmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#[feature(macro_rules)];
#[deny(warnings)];
#[allow(unused_must_use)];

use std::fmt;
use std::io::MemWriter;
Expand All @@ -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()) })
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/issue-8398.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use std::io;

fn foo(a: &mut io::Writer) {
a.write([])
a.write([]).unwrap();
}

pub fn main(){}
Expand Down
3 changes: 2 additions & 1 deletion src/test/run-pass/logging-only-prints-once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/test/run-pass/signal-exit-status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {},
Expand Down
6 changes: 3 additions & 3 deletions src/test/run-pass/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -32,5 +32,5 @@ pub fn main() {
}

assert!(path.exists());
assert_eq!(path.stat().size, 1000);
assert_eq!(path.stat().unwrap().size, 1000);
}