about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-08-24 21:26:19 -0700
committerBrian Anderson <banderson@mozilla.com>2011-08-27 15:54:43 -0700
commitfcc031c5b4dc8f64c497b8dd1e066068e862bd72 (patch)
treed31401261cbe92f9d5039c193dfcb66b3767e018 /src/test
parent20178b9312675f4889bd656916a1f32cbacc94d6 (diff)
downloadrust-fcc031c5b4dc8f64c497b8dd1e066068e862bd72.tar.gz
rust-fcc031c5b4dc8f64c497b8dd1e066068e862bd72.zip
Convert std::io to istrs. Issue #855
Diffstat (limited to 'src/test')
-rw-r--r--src/test/bench/shootout-pfib.rs6
-rw-r--r--src/test/bench/task-perf-word-count-generic.rs5
-rw-r--r--src/test/bench/task-perf-word-count.rs6
-rw-r--r--src/test/compiletest/header.rs4
-rw-r--r--src/test/compiletest/procsrv.rs2
-rw-r--r--src/test/compiletest/runtest.rs32
-rw-r--r--src/test/compiletest/util.rs4
-rw-r--r--src/test/stdtest/io.rs10
-rw-r--r--src/test/stdtest/run.rs12
9 files changed, 46 insertions, 35 deletions
diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs
index c0710c9018c..9a09e9d0bd0 100644
--- a/src/test/bench/shootout-pfib.rs
+++ b/src/test/bench/shootout-pfib.rs
@@ -107,8 +107,10 @@ fn main(argv: [str]) {
 
                     let elapsed = stop - start;
 
-                    out.write_line(#fmt["%d\t%d\t%s", n, fibn,
-                                        istr::to_estr(u64::str(elapsed))]);
+                    out.write_line(
+                        istr::from_estr(
+                            #fmt["%d\t%d\t%s", n, fibn,
+                                 istr::to_estr(u64::str(elapsed))]));
                 }
             }
         }
diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs
index c3fd544aa3d..0f1db55e886 100644
--- a/src/test/bench/task-perf-word-count-generic.rs
+++ b/src/test/bench/task-perf-word-count-generic.rs
@@ -31,7 +31,7 @@ import std::comm::recv;
 import std::comm::send;
 
 fn map(filename: &[u8], emit: &map_reduce::putter<[u8], int>) {
-    let f = io::file_reader(str::unsafe_from_bytes(filename));
+    let f = io::file_reader(istr::unsafe_from_bytes(filename));
 
     while true {
         alt read_word(f) {
@@ -202,7 +202,8 @@ fn main(argv: [str]) {
     if vec::len(argv) < 2u {
         let out = io::stdout();
 
-        out.write_line(#fmt["Usage: %s <filename> ...", argv[0]]);
+        out.write_line(
+            istr::from_estr(#fmt["Usage: %s <filename> ...", argv[0]]));
 
         // TODO: run something just to make sure the code hasn't
         // broken yet. This is the unit test mode of this program.
diff --git a/src/test/bench/task-perf-word-count.rs b/src/test/bench/task-perf-word-count.rs
index 703072eb511..e5355fdc955 100644
--- a/src/test/bench/task-perf-word-count.rs
+++ b/src/test/bench/task-perf-word-count.rs
@@ -14,6 +14,7 @@ import option = std::option::t;
 import std::option::some;
 import std::option::none;
 import std::str;
+import std::istr;
 import std::map;
 import std::vec;
 import std::io;
@@ -30,7 +31,7 @@ import std::comm::recv;
 import std::comm::send;
 
 fn map(filename: str, emit: map_reduce::putter) {
-    let f = io::file_reader(filename);
+    let f = io::file_reader(istr::from_estr(filename));
 
 
     while true {
@@ -196,7 +197,8 @@ fn main(argv: [str]) {
     if vec::len(argv) < 2u {
         let out = io::stdout();
 
-        out.write_line(#fmt["Usage: %s <filename> ...", argv[0]]);
+        out.write_line(istr::from_estr(
+            #fmt["Usage: %s <filename> ...", argv[0]]));
 
         // TODO: run something just to make sure the code hasn't
         // broken yet. This is the unit test mode of this program.
diff --git a/src/test/compiletest/header.rs b/src/test/compiletest/header.rs
index 61cd178a62e..0d1121e4b6b 100644
--- a/src/test/compiletest/header.rs
+++ b/src/test/compiletest/header.rs
@@ -71,9 +71,9 @@ fn is_test_ignored(config: &config, testfile: &str) -> bool {
 }
 
 iter iter_header(testfile: &str) -> str {
-    let rdr = io::file_reader(testfile);
+    let rdr = io::file_reader(istr::from_estr(testfile));
     while !rdr.eof() {
-        let ln = rdr.read_line();
+        let ln = istr::to_estr(rdr.read_line());
 
         // Assume that any directives will be found before the first
         // module or function. This doesn't seem to be an optimization
diff --git a/src/test/compiletest/procsrv.rs b/src/test/compiletest/procsrv.rs
index 140821473ad..0e4c2c87d83 100644
--- a/src/test/compiletest/procsrv.rs
+++ b/src/test/compiletest/procsrv.rs
@@ -73,7 +73,7 @@ fn run(handle: &handle, lib_path: &str, prog: &str, args: &[str],
 fn writeclose(fd: int, s: &option::t<str>) {
     if option::is_some(s) {
         let writer = io::new_writer(io::fd_buf_writer(fd, option::none));
-        writer.write_str(option::get(s));
+        writer.write_str(istr::from_estr(option::get(s)));
     }
 
     os::libc::close(fd);
diff --git a/src/test/compiletest/runtest.rs b/src/test/compiletest/runtest.rs
index ac883256157..a4e1b26b7ed 100644
--- a/src/test/compiletest/runtest.rs
+++ b/src/test/compiletest/runtest.rs
@@ -23,7 +23,7 @@ fn run(cx: &cx, _testfile: -[u8]) {
     let testfile = str::unsafe_from_bytes(_testfile);
     if cx.config.verbose {
         // We're going to be dumping a lot of info. Start on a new line.
-        io::stdout().write_str("\n\n");
+        io::stdout().write_str(~"\n\n");
     }
     log #fmt["running %s", testfile];
     let props = load_props(testfile);
@@ -87,7 +87,8 @@ fn run_pretty_test(cx: &cx, props: &test_props, testfile: &str) {
     let rounds =
         alt props.pp_exact { option::some(_) { 1 } option::none. { 2 } };
 
-    let srcs = [io::read_whole_file_str(testfile)];
+    let srcs = [istr::to_estr(io::read_whole_file_str(
+        istr::from_estr(testfile)))];
 
     let round = 0;
     while round < rounds {
@@ -108,7 +109,7 @@ fn run_pretty_test(cx: &cx, props: &test_props, testfile: &str) {
           option::some(file) {
             let filepath = fs::connect(fs::dirname(
                 istr::from_estr(testfile)), istr::from_estr(file));
-            io::read_whole_file_str(istr::to_estr(filepath))
+            istr::to_estr(io::read_whole_file_str(filepath))
           }
           option::none. { srcs[vec::len(srcs) - 2u] }
         };
@@ -159,7 +160,7 @@ actual:\n\
 ------------------------------------------\n\
 \n",
                      expected, actual];
-            io::stdout().write_str(msg);
+            io::stdout().write_str(istr::from_estr(msg));
             fail;
         }
     }
@@ -329,8 +330,9 @@ fn dump_output(config: &config, testfile: &str, out: &str, err: &str) {
 fn dump_output_file(config: &config, testfile: &str, out: &str,
                     extension: &str) {
     let outfile = make_out_name(config, testfile, extension);
-    let writer = io::file_writer(outfile, [io::create, io::truncate]);
-    writer.write_str(out);
+    let writer = io::file_writer(istr::from_estr(outfile),
+                                 [io::create, io::truncate]);
+    writer.write_str(istr::from_estr(out));
 }
 
 // FIXME (726): Can't use file_writer on mac
@@ -361,21 +363,23 @@ fn maybe_dump_to_stdout(config: &config, out: &str, err: &str) {
         let sep1 = #fmt["------%s------------------------------", "stdout"];
         let sep2 = #fmt["------%s------------------------------", "stderr"];
         let sep3 = "------------------------------------------";
-        io::stdout().write_line(sep1);
-        io::stdout().write_line(out);
-        io::stdout().write_line(sep2);
-        io::stdout().write_line(err);
-        io::stdout().write_line(sep3);
+        io::stdout().write_line(istr::from_estr(sep1));
+        io::stdout().write_line(istr::from_estr(out));
+        io::stdout().write_line(istr::from_estr(sep2));
+        io::stdout().write_line(istr::from_estr(err));
+        io::stdout().write_line(istr::from_estr(sep3));
     }
 }
 
-fn error(err: &str) { io::stdout().write_line(#fmt["\nerror: %s", err]); }
+fn error(err: &str) {
+    io::stdout().write_line(istr::from_estr(#fmt["\nerror: %s", err]));
+}
 
 fn fatal(err: &str) -> ! { error(err); fail; }
 
 fn fatal_procres(err: &str, procres: procres) -> ! {
     let msg =
-        #fmt["\n\
+        istr::from_estr(#fmt["\n\
 error: %s\n\
 command: %s\n\
 stdout:\n\
@@ -387,7 +391,7 @@ stderr:\n\
 %s\n\
 ------------------------------------------\n\
 \n",
-             err, procres.cmdline, procres.stdout, procres.stderr];
+             err, procres.cmdline, procres.stdout, procres.stderr]);
     io::stdout().write_str(msg);
     fail;
 }
diff --git a/src/test/compiletest/util.rs b/src/test/compiletest/util.rs
index 3dcd8699927..9bbcd6c7e99 100644
--- a/src/test/compiletest/util.rs
+++ b/src/test/compiletest/util.rs
@@ -25,5 +25,7 @@ fn lib_path_env_var() -> str { "PATH" }
 
 fn logv(config: &config, s: &str) {
     log s;
-    if config.verbose { io::stdout().write_line(s); }
+    if config.verbose {
+        io::stdout().write_line(std::istr::from_estr(s));
+    }
 }
diff --git a/src/test/stdtest/io.rs b/src/test/stdtest/io.rs
index 08330c619fc..679466cbece 100644
--- a/src/test/stdtest/io.rs
+++ b/src/test/stdtest/io.rs
@@ -1,15 +1,15 @@
 // -*- rust -*-
 use std;
 import std::io;
-import std::str;
+import std::istr;
 
 #[cfg(target_os = "linux")]
 #[cfg(target_os = "win32")]
 #[test]
 fn test_simple() {
-    let tmpfile: str = "test/run-pass/lib-io-test-simple.tmp";
+    let tmpfile: istr = ~"test/run-pass/lib-io-test-simple.tmp";
     log tmpfile;
-    let frood: str = "A hoopy frood who really knows where his towel is.";
+    let frood: istr = ~"A hoopy frood who really knows where his towel is.";
     log frood;
     {
         let out: io::writer =
@@ -17,9 +17,9 @@ fn test_simple() {
         out.write_str(frood);
     }
     let inp: io::reader = io::file_reader(tmpfile);
-    let frood2: str = inp.read_c_str();
+    let frood2: istr = inp.read_c_str();
     log frood2;
-    assert (str::eq(frood, frood2));
+    assert (istr::eq(frood, frood2));
 }
 
 // FIXME (726)
diff --git a/src/test/stdtest/run.rs b/src/test/stdtest/run.rs
index 54f33b3e057..d3e88b13738 100644
--- a/src/test/stdtest/run.rs
+++ b/src/test/stdtest/run.rs
@@ -3,7 +3,7 @@ import std::run;
 import std::os;
 import std::io;
 import std::option;
-import std::str;
+import std::istr;
 import std::vec;
 
 // Regression test for memory leaks
@@ -36,7 +36,7 @@ fn test_pipes() {
     os::libc::close(pipe_err.out);
 
     if pid == -1 { fail; }
-    let expected = "test";
+    let expected = ~"test";
     writeclose(pipe_in.out, expected);
     let actual = readclose(pipe_out.in);
     readclose(pipe_err.in);
@@ -46,21 +46,21 @@ fn test_pipes() {
     log actual;
     assert (expected == actual);
 
-    fn writeclose(fd: int, s: &str) {
+    fn writeclose(fd: int, s: &istr) {
         let writer = io::new_writer(io::fd_buf_writer(fd, option::none));
         writer.write_str(s);
 
         os::libc::close(fd);
     }
 
-    fn readclose(fd: int) -> str {
+    fn readclose(fd: int) -> istr {
         // Copied from run::program_output
         let file = os::fd_FILE(fd);
         let reader = io::new_reader(io::FILE_buf_reader(file, option::none));
-        let buf = "";
+        let buf = ~"";
         while !reader.eof() {
             let bytes = reader.read_bytes(4096u);
-            buf += str::unsafe_from_bytes(bytes);
+            buf += istr::unsafe_from_bytes(bytes);
         }
         os::libc::fclose(file);
         ret buf;