about summary refs log tree commit diff
path: root/src/compiletest
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-10-25 17:04:37 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-11-03 15:15:42 -0800
commit9c1851019f1ef9511fa8731b8f1acb0796d1e97f (patch)
tree0cd6d600bfc077e1d19722afdb042c9c016db621 /src/compiletest
parent7bf58c2baaac3f7cb3c8e8d735b27ac9e7d3cd78 (diff)
downloadrust-9c1851019f1ef9511fa8731b8f1acb0796d1e97f.tar.gz
rust-9c1851019f1ef9511fa8731b8f1acb0796d1e97f.zip
Remove all blocking std::os blocking functions
This commit moves all thread-blocking I/O functions from the std::os module.
Their replacements can be found in either std::rt::io::file or in a hidden
"old_os" module inside of native::file. I didn't want to outright delete these
functions because they have a lot of special casing learned over time for each
OS/platform, and I imagine that these will someday get integrated into a
blocking implementation of IoFactory. For now, they're moved to a private module
to prevent bitrot and still have tests to ensure that they work.

I've also expanded the extensions to a few more methods defined on Path, most of
which were previously defined in std::os but now have non-thread-blocking
implementations as part of using the current IoFactory.

The api of io::file is in flux, but I plan on changing it in the next commit as
well.

Closes #10057
Diffstat (limited to 'src/compiletest')
-rw-r--r--src/compiletest/compiletest.rs3
-rw-r--r--src/compiletest/errors.rs8
-rw-r--r--src/compiletest/header.rs5
-rw-r--r--src/compiletest/runtest.rs20
4 files changed, 16 insertions, 20 deletions
diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs
index 7f5a72e8a2c..a354bc84e52 100644
--- a/src/compiletest/compiletest.rs
+++ b/src/compiletest/compiletest.rs
@@ -17,6 +17,7 @@ extern mod extra;
 
 use std::os;
 use std::rt;
+use std::rt::io::file;
 
 use extra::getopts;
 use extra::getopts::groups::{optopt, optflag, reqopt};
@@ -247,7 +248,7 @@ pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
     debug!("making tests from {}",
            config.src_base.display());
     let mut tests = ~[];
-    let dirs = os::list_dir_path(&config.src_base);
+    let dirs = file::readdir(&config.src_base);
     for file in dirs.iter() {
         let file = file.clone();
         debug!("inspecting file {}", file.display());
diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs
index 0c94ec8ab8a..dfadea37cd0 100644
--- a/src/compiletest/errors.rs
+++ b/src/compiletest/errors.rs
@@ -8,16 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::rt::io::buffered::BufferedReader;
+use std::rt::io::file;
+
 pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }
 
 // Load any test directives embedded in the file
 pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
-    use std::rt::io::Open;
-    use std::rt::io::file::FileInfo;
-    use std::rt::io::buffered::BufferedReader;
 
     let mut error_patterns = ~[];
-    let mut rdr = BufferedReader::new(testfile.open_reader(Open).unwrap());
+    let mut rdr = BufferedReader::new(file::open(testfile).unwrap());
     let mut line_num = 1u;
     loop {
         let ln = match rdr.read_line() {
diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs
index 368c96ffe85..68e8fd76735 100644
--- a/src/compiletest/header.rs
+++ b/src/compiletest/header.rs
@@ -103,11 +103,10 @@ pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
 }
 
 fn iter_header(testfile: &Path, it: &fn(&str) -> bool) -> bool {
-    use std::rt::io::Open;
-    use std::rt::io::file::FileInfo;
     use std::rt::io::buffered::BufferedReader;
+    use std::rt::io::file;
 
-    let mut rdr = BufferedReader::new(testfile.open_reader(Open).unwrap());
+    let mut rdr = BufferedReader::new(file::open(testfile).unwrap());
     loop {
         let ln = match rdr.read_line() {
             Some(ln) => ln, None => break
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs
index 13c4c7948b8..7fc13467217 100644
--- a/src/compiletest/runtest.rs
+++ b/src/compiletest/runtest.rs
@@ -22,9 +22,7 @@ use util::logv;
 
 use std::cell::Cell;
 use std::rt::io;
-use std::rt::io::Writer;
-use std::rt::io::Reader;
-use std::rt::io::file::FileInfo;
+use std::rt::io::file;
 use std::os;
 use std::str;
 use std::task::{spawn_sched, SingleThreaded};
@@ -173,7 +171,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
     let rounds =
         match props.pp_exact { Some(_) => 1, None => 2 };
 
-    let src = testfile.open_reader(io::Open).read_to_end();
+    let src = file::open(testfile).read_to_end();
     let src = str::from_utf8_owned(src);
     let mut srcs = ~[src];
 
@@ -195,7 +193,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
     let mut expected = match props.pp_exact {
         Some(ref file) => {
             let filepath = testfile.dir_path().join(file);
-            let s = filepath.open_reader(io::Open).read_to_end();
+            let s = file::open(&filepath).read_to_end();
             str::from_utf8_owned(s)
           }
           None => { srcs[srcs.len() - 2u].clone() }
@@ -651,10 +649,8 @@ fn compose_and_run_compiler(
 }
 
 fn ensure_dir(path: &Path) {
-    if os::path_is_dir(path) { return; }
-    if !os::make_dir(path, 0x1c0i32) {
-        fail!("can't make dir {}", path.display());
-    }
+    if path.is_dir() { return; }
+    file::mkdir(path, io::UserRWX);
 }
 
 fn compose_and_run(config: &config, testfile: &Path,
@@ -768,7 +764,7 @@ fn dump_output(config: &config, testfile: &Path, out: &str, err: &str) {
 fn dump_output_file(config: &config, testfile: &Path,
                     out: &str, extension: &str) {
     let outfile = make_out_name(config, testfile, extension);
-    outfile.open_writer(io::CreateOrTruncate).write(out.as_bytes());
+    file::create(&outfile).write(out.as_bytes());
 }
 
 fn make_out_name(config: &config, testfile: &Path, extension: &str) -> Path {
@@ -924,7 +920,7 @@ fn _dummy_exec_compiled_test(config: &config, props: &TestProps,
 fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
     let tdir = aux_output_dir_name(config, testfile);
 
-    let dirs = os::list_dir_path(&tdir);
+    let dirs = file::readdir(&tdir);
     for file in dirs.iter() {
         if file.extension_str() == Some("so") {
             // FIXME (#9639): This needs to handle non-utf8 paths
@@ -1019,7 +1015,7 @@ fn disassemble_extract(config: &config, _props: &TestProps,
 
 
 fn count_extracted_lines(p: &Path) -> uint {
-    let x = p.with_extension("ll").open_reader(io::Open).read_to_end();
+    let x = file::open(&p.with_extension("ll")).read_to_end();
     let x = str::from_utf8_owned(x);
     x.line_iter().len()
 }