Skip to content

Commit 29e7247

Browse files
committed
rpass: Remove io_error usage
1 parent 6132f7f commit 29e7247

File tree

7 files changed

+27
-23
lines changed

7 files changed

+27
-23
lines changed

src/test/run-pass/capturing-logging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ fn main() {
4343
debug!("debug");
4444
info!("info");
4545
});
46-
assert_eq!(r.read_to_str(), ~"info\n");
46+
assert_eq!(r.read_to_str().unwrap(), ~"info\n");
4747
}

src/test/run-pass/core-run-destroy.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ fn test_destroy_once() {
2727
#[cfg(target_os="android")]
2828
static PROG: &'static str = "ls"; // android don't have echo binary
2929

30-
let mut p = run::Process::new(PROG, [], run::ProcessOptions::new())
31-
.expect(format!("failed to exec `{}`", PROG));
30+
let mut p = run::Process::new(PROG, [], run::ProcessOptions::new()).unwrap();
3231
p.destroy(); // this shouldn't crash (and nor should the destructor)
3332
}
3433

@@ -39,12 +38,12 @@ fn test_destroy_twice() {
3938
#[cfg(target_os="android")]
4039
static PROG: &'static str = "ls"; // android don't have echo binary
4140

42-
let mut p = run::Process::new(PROG, [], run::ProcessOptions::new())
43-
.expect(format!("failed to exec `{}`", PROG));
41+
let mut p = match run::Process::new(PROG, [], run::ProcessOptions::new()) {
42+
Ok(p) => p,
43+
Err(e) => fail!("wut: {}", e),
44+
};
4445
p.destroy(); // this shouldnt crash...
45-
io::io_error::cond.trap(|_| {}).inside(|| {
46-
p.destroy(); // ...and nor should this (and nor should the destructor)
47-
})
46+
p.destroy(); // ...and nor should this (and nor should the destructor)
4847
}
4948

5049
fn test_destroy_actually_kills(force: bool) {
@@ -61,14 +60,14 @@ fn test_destroy_actually_kills(force: bool) {
6160
#[cfg(unix,not(target_os="android"))]
6261
fn process_exists(pid: libc::pid_t) -> bool {
6362
let run::ProcessOutput {output, ..} = run::process_output("ps", [~"-p", pid.to_str()])
64-
.expect("failed to exec `ps`");
63+
.unwrap();
6564
str::from_utf8_owned(output).unwrap().contains(pid.to_str())
6665
}
6766

6867
#[cfg(unix,target_os="android")]
6968
fn process_exists(pid: libc::pid_t) -> bool {
7069
let run::ProcessOutput {output, ..} = run::process_output("/system/bin/ps", [pid.to_str()])
71-
.expect("failed to exec `/system/bin/ps`");
70+
.unwrap();
7271
str::from_utf8_owned(output).unwrap().contains(~"root")
7372
}
7473

@@ -93,7 +92,7 @@ fn test_destroy_actually_kills(force: bool) {
9392

9493
// this process will stay alive indefinitely trying to read from stdin
9594
let mut p = run::Process::new(BLOCK_COMMAND, [], run::ProcessOptions::new())
96-
.expect(format!("failed to exec `{}`", BLOCK_COMMAND));
95+
.unwrap();
9796

9897
assert!(process_exists(p.get_id()));
9998

src/test/run-pass/ifmt.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#[feature(macro_rules)];
1414
#[deny(warnings)];
15+
#[allow(unused_must_use)];
1516

1617
use std::fmt;
1718
use std::io::MemWriter;
@@ -22,10 +23,14 @@ struct A;
2223
struct B;
2324

2425
impl fmt::Signed for A {
25-
fn fmt(_: &A, f: &mut fmt::Formatter) { f.buf.write("aloha".as_bytes()); }
26+
fn fmt(_: &A, f: &mut fmt::Formatter) -> fmt::Result {
27+
f.buf.write("aloha".as_bytes())
28+
}
2629
}
2730
impl fmt::Signed for B {
28-
fn fmt(_: &B, f: &mut fmt::Formatter) { f.buf.write("adios".as_bytes()); }
31+
fn fmt(_: &B, f: &mut fmt::Formatter) -> fmt::Result {
32+
f.buf.write("adios".as_bytes())
33+
}
2934
}
3035

3136
macro_rules! t(($a:expr, $b:expr) => { assert_eq!($a, $b.to_owned()) })
@@ -286,9 +291,9 @@ fn test_format_args() {
286291
let mut buf = MemWriter::new();
287292
{
288293
let w = &mut buf as &mut io::Writer;
289-
format_args!(|args| { fmt::write(w, args) }, "{}", 1);
290-
format_args!(|args| { fmt::write(w, args) }, "test");
291-
format_args!(|args| { fmt::write(w, args) }, "{test}", test=3);
294+
format_args!(|args| { fmt::write(w, args); }, "{}", 1);
295+
format_args!(|args| { fmt::write(w, args); }, "test");
296+
format_args!(|args| { fmt::write(w, args); }, "{test}", test=3);
292297
}
293298
let s = str::from_utf8_owned(buf.unwrap()).unwrap();
294299
t!(s, "1test3");

src/test/run-pass/issue-8398.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use std::io;
1212

1313
fn foo(a: &mut io::Writer) {
14-
a.write([])
14+
a.write([]).unwrap();
1515
}
1616

1717
pub fn main(){}

src/test/run-pass/logging-only-prints-once.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ use std::fmt;
1717
struct Foo(Cell<int>);
1818

1919
impl fmt::Show for Foo {
20-
fn fmt(f: &Foo, _fmt: &mut fmt::Formatter) {
20+
fn fmt(f: &Foo, _fmt: &mut fmt::Formatter) -> fmt::Result {
2121
let Foo(ref f) = *f;
2222
assert!(f.get() == 0);
2323
f.set(1);
24+
Ok(())
2425
}
2526
}
2627

src/test/run-pass/signal-exit-status.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ pub fn main() {
1919
// Raise a segfault.
2020
unsafe { *(0 as *mut int) = 0; }
2121
} else {
22-
let status = run::process_status(args[0], [~"signal"])
23-
.expect("failed to exec `signal`");
22+
let status = run::process_status(args[0], [~"signal"]).unwrap();
2423
// Windows does not have signal, so we get exit status 0xC0000028 (STATUS_BAD_STACK).
2524
match status {
2625
process::ExitSignal(_) if cfg!(unix) => {},

src/test/run-pass/stat.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pub fn main() {
2121

2222
{
2323
match File::create(&path) {
24-
None => unreachable!(),
25-
Some(f) => {
24+
Err(..) => unreachable!(),
25+
Ok(f) => {
2626
let mut f = f;
2727
for _ in range(0u, 1000) {
2828
f.write([0]);
@@ -32,5 +32,5 @@ pub fn main() {
3232
}
3333

3434
assert!(path.exists());
35-
assert_eq!(path.stat().size, 1000);
35+
assert_eq!(path.stat().unwrap().size, 1000);
3636
}

0 commit comments

Comments
 (0)