Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::rt improvements #9901

Merged
merged 23 commits into from
Oct 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bac9681
Implement io::net::unix
alexcrichton Oct 16, 2013
1db783b
Finish implementing io::net::addrinfo
alexcrichton Oct 16, 2013
c6fa4e2
Address a few XXX comments throughout the runtime
alexcrichton Oct 16, 2013
32b07c6
Remove unbound pipes from io::pipe
alexcrichton Oct 16, 2013
35756fb
Move rt::io::stdio from FileStream to a TTY
alexcrichton Oct 16, 2013
0cad984
Migrate Rtio objects to true trait objects
alexcrichton Oct 16, 2013
9110a38
Remove rt::io::support
alexcrichton Oct 16, 2013
b46f60a
Remove IoFactoryObject for ~IoFactory
alexcrichton Oct 17, 2013
59d45b8
Don't attempt to export uv functions directly
alexcrichton Oct 17, 2013
4ce71ea
Migrate the last typedefs to ~Trait in rtio
alexcrichton Oct 17, 2013
4eb5336
Move as much I/O as possible off of native::io
alexcrichton Oct 18, 2013
61ed2cf
Remove even more of std::io
alexcrichton Oct 14, 2013
e117aa0
Stop logging task failure to task loggers
alexcrichton Oct 18, 2013
6b70ddf
Remove io::read_error
alexcrichton Oct 18, 2013
279c351
Move stdin to using libuv's pipes instead of a tty
alexcrichton Oct 18, 2013
620ab38
Test fixes and merge conflicts
alexcrichton Oct 18, 2013
c4907cf
Remove std::io from ebml
alexcrichton Oct 22, 2013
6bb1df9
Remove std::io once and for all!
alexcrichton Oct 22, 2013
262b958
Migrate std::run to libuv processes
alexcrichton Oct 22, 2013
816e46d
Fixing some tests, adding some pipes
alexcrichton Oct 22, 2013
b5a02e0
wrapping libuv signal for use in Rust
Sep 19, 2013
d425218
Bring io::signal up to date with changes to rt::rtio
alexcrichton Oct 22, 2013
188e471
Another round of test fixes and merge conflicts
alexcrichton Oct 22, 2013
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
10 changes: 5 additions & 5 deletions doc/tutorial-conditions.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $ ./example numbers.txt

An example program that does this task reads like this:

~~~~
~~~~{.xfail-test}
# #[allow(unused_imports)];
extern mod extra;
use extra::fileinput::FileInput;
Expand Down Expand Up @@ -430,7 +430,7 @@ To trap a condition, use `Condition::trap` in some caller of the site that calls
For example, this version of the program traps the `malformed_line` condition
and replaces bad input lines with the pair `(-1,-1)`:

~~~~
~~~~{.xfail-test}
# #[allow(unused_imports)];
extern mod extra;
use extra::fileinput::FileInput;
Expand Down Expand Up @@ -507,7 +507,7 @@ In the example program, the first form of the `malformed_line` API implicitly as
This assumption may not be correct; some callers may wish to skip malformed lines, for example.
Changing the condition's return type from `(int,int)` to `Option<(int,int)>` will suffice to support this type of recovery:

~~~~
~~~~{.xfail-test}
# #[allow(unused_imports)];
extern mod extra;
use extra::fileinput::FileInput;
Expand Down Expand Up @@ -594,7 +594,7 @@ until all relevant combinations encountered in practice are encoded.
In the example, suppose a third possible recovery form arose: reusing the previous value read.
This can be encoded in the handler API by introducing a helper type: `enum MalformedLineFix`.

~~~~
~~~~{.xfail-test}
# #[allow(unused_imports)];
extern mod extra;
use extra::fileinput::FileInput;
Expand Down Expand Up @@ -720,7 +720,7 @@ task <unnamed> failed at 'called `Option::unwrap()` on a `None` value', .../libs
To make the program robust -- or at least flexible -- in the face of this potential failure,
a second condition and a helper function will suffice:

~~~~
~~~~{.xfail-test}
# #[allow(unused_imports)];
extern mod extra;
use extra::fileinput::FileInput;
Expand Down
1 change: 0 additions & 1 deletion doc/tutorial-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ calling the `spawn` function with a closure argument. `spawn` executes the
closure in the new task.

~~~~
# use std::io::println;
# use std::task::spawn;

// Print something profound in a different task using a named function
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -2907,12 +2907,12 @@ you just have to import it with an `use` statement.
For example, it re-exports `println` which is defined in `std::io::println`:

~~~
use puts = std::io::println;
use puts = std::rt::io::stdio::println;

fn main() {
println("println is imported per default.");
puts("Doesn't hinder you from importing it under an different name yourself.");
::std::io::println("Or from not using the automatic import.");
::std::rt::io::stdio::println("Or from not using the automatic import.");
}
~~~

Expand Down
52 changes: 25 additions & 27 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use util;
use util::logv;

use std::cell::Cell;
use std::io;
use std::rt::io;
use std::rt::io::Writer;
use std::rt::io::extensions::ReaderUtil;
use std::rt::io::file::FileInfo;
use std::os;
use std::str;
use std::task::{spawn_sched, SingleThreaded};
Expand Down Expand Up @@ -60,7 +63,7 @@ pub fn run(config: config, testfile: ~str) {
pub fn run_metrics(config: config, testfile: ~str, mm: &mut MetricMap) {
if config.verbose {
// We're going to be dumping a lot of info. Start on a new line.
io::stdout().write_str("\n\n");
print!("\n\n");
}
let testfile = Path::new(testfile);
debug!("running {}", testfile.display());
Expand Down Expand Up @@ -170,7 +173,9 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
let rounds =
match props.pp_exact { Some(_) => 1, None => 2 };

let mut srcs = ~[io::read_whole_file_str(testfile).unwrap()];
let src = testfile.open_reader(io::Open).read_to_end();
let src = str::from_utf8_owned(src);
let mut srcs = ~[src];

let mut round = 0;
while round < rounds {
Expand All @@ -190,7 +195,8 @@ 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);
io::read_whole_file_str(&filepath).unwrap()
let s = filepath.open_reader(io::Open).read_to_end();
str::from_utf8_owned(s)
}
None => { srcs[srcs.len() - 2u].clone() }
};
Expand Down Expand Up @@ -228,8 +234,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
fn compare_source(expected: &str, actual: &str) {
if expected != actual {
error(~"pretty-printed source does not match expected source");
let msg =
format!("\n\
println!("\n\
expected:\n\
------------------------------------------\n\
{}\n\
Expand All @@ -240,7 +245,6 @@ actual:\n\
------------------------------------------\n\
\n",
expected, actual);
io::stdout().write_str(msg);
fail!();
}
}
Expand Down Expand Up @@ -741,9 +745,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);
let writer =
io::file_writer(&outfile, [io::Create, io::Truncate]).unwrap();
writer.write_str(out);
outfile.open_writer(io::CreateOrTruncate).write(out.as_bytes());
}

fn make_out_name(config: &config, testfile: &Path, extension: &str) -> Path {
Expand Down Expand Up @@ -771,24 +773,20 @@ fn output_base_name(config: &config, testfile: &Path) -> Path {

fn maybe_dump_to_stdout(config: &config, out: &str, err: &str) {
if config.verbose {
let sep1 = format!("------{}------------------------------", "stdout");
let sep2 = format!("------{}------------------------------", "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);
println!("------{}------------------------------", "stdout");
println!("{}", out);
println!("------{}------------------------------", "stderr");
println!("{}", err);
println!("------------------------------------------");
}
}

fn error(err: ~str) { io::stdout().write_line(format!("\nerror: {}", err)); }
fn error(err: ~str) { println!("\nerror: {}", err); }

fn fatal(err: ~str) -> ! { error(err); fail!(); }

fn fatal_ProcRes(err: ~str, ProcRes: &ProcRes) -> ! {
let msg =
format!("\n\
print!("\n\
error: {}\n\
command: {}\n\
stdout:\n\
Expand All @@ -801,7 +799,6 @@ stderr:\n\
------------------------------------------\n\
\n",
err, ProcRes.cmdline, ProcRes.stdout, ProcRes.stderr);
io::stdout().write_str(msg);
fail!();
}

Expand All @@ -821,9 +818,9 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
~[(~"",~"")], Some(~""));

if config.verbose {
io::stdout().write_str(format!("push ({}) {} {} {}",
println!("push ({}) {} {} {}",
config.target, args.prog,
copy_result.out, copy_result.err));
copy_result.out, copy_result.err);
}

logv(config, format!("executing ({}) {}", config.target, cmdline));
Expand Down Expand Up @@ -913,9 +910,9 @@ fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
~[(~"",~"")], Some(~""));

if config.verbose {
io::stdout().write_str(format!("push ({}) {} {} {}",
println!("push ({}) {} {} {}",
config.target, file.display(),
copy_result.out, copy_result.err));
copy_result.out, copy_result.err);
}
}
}
Expand Down Expand Up @@ -999,7 +996,8 @@ fn disassemble_extract(config: &config, _props: &TestProps,


fn count_extracted_lines(p: &Path) -> uint {
let x = io::read_whole_file_str(&p.with_extension("ll")).unwrap();
let x = p.with_extension("ll").open_reader(io::Open).read_to_end();
let x = str::from_utf8_owned(x);
x.line_iter().len()
}

Expand Down
3 changes: 1 addition & 2 deletions src/compiletest/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

use common::config;

use std::io;
use std::os::getenv;

/// Conversion table from triple OS name to Rust SYSNAME
Expand Down Expand Up @@ -64,5 +63,5 @@ pub fn path_div() -> ~str { ~";" }

pub fn logv(config: &config, s: ~str) {
debug!("{}", s);
if config.verbose { io::println(s); }
if config.verbose { println(s); }
}
8 changes: 4 additions & 4 deletions src/etc/combine-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def scrub(b):
d.write("extern mod extra;\n")
d.write("extern mod run_pass_stage2;\n")
d.write("use run_pass_stage2::*;\n")
d.write("use std::io::WriterUtil;\n");
d.write("use std::io;\n");
d.write("use std::rt::io;\n");
d.write("use std::rt::io::Writer;\n");
d.write("fn main() {\n");
d.write(" let out = io::stdout();\n");
d.write(" let mut out = io::stdout();\n");
i = 0
for t in stage2_tests:
p = os.path.join("test", "run-pass", t)
p = p.replace("\\", "\\\\")
d.write(" out.write_str(\"run-pass [stage2]: %s\\n\");\n" % p)
d.write(" out.write(\"run-pass [stage2]: %s\\n\".as_bytes());\n" % p)
d.write(" t_%d::main();\n" % i)
i += 1
d.write("}\n")
Loading