Skip to content

Commit 27a9bf7

Browse files
committed
compiletest: Remove io_error usage
1 parent 5e8ba72 commit 27a9bf7

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

src/compiletest/compiletest.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,13 @@ pub fn run_tests(config: &config) {
234234
// For context, see #8904
235235
io::test::raise_fd_limit();
236236
let res = test::run_tests_console(&opts, tests);
237-
if !res { fail!("Some tests failed"); }
237+
match res {
238+
Ok(true) => {}
239+
Ok(false) => fail!("Some tests failed"),
240+
Err(e) => {
241+
println!("I/O failure during tests: {}", e);
242+
}
243+
}
238244
}
239245

240246
pub fn test_opts(config: &config) -> test::TestOpts {
@@ -255,7 +261,7 @@ pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
255261
debug!("making tests from {}",
256262
config.src_base.display());
257263
let mut tests = ~[];
258-
let dirs = fs::readdir(&config.src_base);
264+
let dirs = fs::readdir(&config.src_base).unwrap();
259265
for file in dirs.iter() {
260266
let file = file.clone();
261267
debug!("inspecting file {}", file.display());

src/compiletest/procsrv.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ pub fn run(lib_path: &str,
5858
});
5959

6060
match opt_process {
61-
Some(ref mut process) => {
61+
Ok(ref mut process) => {
6262
for input in input.iter() {
63-
process.input().write(input.as_bytes());
63+
process.input().write(input.as_bytes()).unwrap();
6464
}
6565
let run::ProcessOutput { status, output, error } = process.finish_with_output();
6666

@@ -70,7 +70,7 @@ pub fn run(lib_path: &str,
7070
err: str::from_utf8_owned(error).unwrap()
7171
})
7272
},
73-
None => None
73+
Err(..) => None
7474
}
7575
}
7676

@@ -90,13 +90,13 @@ pub fn run_background(lib_path: &str,
9090
});
9191

9292
match opt_process {
93-
Some(mut process) => {
93+
Ok(mut process) => {
9494
for input in input.iter() {
95-
process.input().write(input.as_bytes());
95+
process.input().write(input.as_bytes()).unwrap();
9696
}
9797

9898
Some(process)
9999
},
100-
None => None
100+
Err(..) => None
101101
}
102102
}

src/compiletest/runtest.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
153153
let rounds =
154154
match props.pp_exact { Some(_) => 1, None => 2 };
155155

156-
let src = File::open(testfile).read_to_end();
156+
let src = File::open(testfile).read_to_end().unwrap();
157157
let src = str::from_utf8_owned(src).unwrap();
158158
let mut srcs = ~[src];
159159

@@ -175,7 +175,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
175175
let mut expected = match props.pp_exact {
176176
Some(ref file) => {
177177
let filepath = testfile.dir_path().join(file);
178-
let s = File::open(&filepath).read_to_end();
178+
let s = File::open(&filepath).read_to_end().unwrap();
179179
str::from_utf8_owned(s).unwrap()
180180
}
181181
None => { srcs[srcs.len() - 2u].clone() }
@@ -318,8 +318,10 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
318318
//waiting 1 second for gdbserver start
319319
timer::sleep(1000);
320320
let result = task::try(proc() {
321-
tcp::TcpStream::connect(
322-
SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 5039 });
321+
tcp::TcpStream::connect(SocketAddr {
322+
ip: Ipv4Addr(127, 0, 0, 1),
323+
port: 5039,
324+
}).unwrap();
323325
});
324326
if result.is_err() {
325327
continue;
@@ -361,7 +363,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
361363
stdout: out,
362364
stderr: err,
363365
cmdline: cmdline};
364-
process.force_destroy();
366+
process.force_destroy().unwrap();
365367
}
366368

367369
_=> {
@@ -727,7 +729,7 @@ fn compose_and_run_compiler(
727729

728730
fn ensure_dir(path: &Path) {
729731
if path.is_dir() { return; }
730-
fs::mkdir(path, io::UserRWX);
732+
fs::mkdir(path, io::UserRWX).unwrap();
731733
}
732734

733735
fn compose_and_run(config: &config, testfile: &Path,
@@ -852,7 +854,7 @@ fn dump_output(config: &config, testfile: &Path, out: &str, err: &str) {
852854
fn dump_output_file(config: &config, testfile: &Path,
853855
out: &str, extension: &str) {
854856
let outfile = make_out_name(config, testfile, extension);
855-
File::create(&outfile).write(out.as_bytes());
857+
File::create(&outfile).write(out.as_bytes()).unwrap();
856858
}
857859

858860
fn make_out_name(config: &config, testfile: &Path, extension: &str) -> Path {
@@ -1003,7 +1005,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
10031005
fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
10041006
let tdir = aux_output_dir_name(config, testfile);
10051007

1006-
let dirs = fs::readdir(&tdir);
1008+
let dirs = fs::readdir(&tdir).unwrap();
10071009
for file in dirs.iter() {
10081010
if file.extension_str() == Some("so") {
10091011
// FIXME (#9639): This needs to handle non-utf8 paths
@@ -1099,7 +1101,7 @@ fn disassemble_extract(config: &config, _props: &TestProps,
10991101

11001102

11011103
fn count_extracted_lines(p: &Path) -> uint {
1102-
let x = File::open(&p.with_extension("ll")).read_to_end();
1104+
let x = File::open(&p.with_extension("ll")).read_to_end().unwrap();
11031105
let x = str::from_utf8_owned(x).unwrap();
11041106
x.lines().len()
11051107
}

0 commit comments

Comments
 (0)