Skip to content

Logstderr #1787

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions src/comp/driver/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,16 @@ fn diagnosticcolor(lvl: level) -> u8 {

fn print_diagnostic(topic: str, lvl: level, msg: str) {
if str::is_not_empty(topic) {
io::stdout().write_str(#fmt["%s ", topic]);
io::stderr().write_str(#fmt["%s ", topic]);
}
if term::color_supported() {
term::fg(io::stdout(), diagnosticcolor(lvl));
term::fg(io::stderr(), diagnosticcolor(lvl));
}
io::stdout().write_str(#fmt["%s:", diagnosticstr(lvl)]);
io::stderr().write_str(#fmt["%s:", diagnosticstr(lvl)]);
if term::color_supported() {
term::reset(io::stdout());
term::reset(io::stderr());
}
io::stdout().write_str(#fmt[" %s\n", msg]);
io::stderr().write_str(#fmt[" %s\n", msg]);
}

fn emit(cmsp: option<(codemap::codemap, span)>,
Expand Down Expand Up @@ -202,10 +202,10 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
}
// Print the offending lines
for line: uint in display_lines {
io::stdout().write_str(#fmt["%s:%u ", fm.name, line + 1u]);
io::stderr().write_str(#fmt["%s:%u ", fm.name, line + 1u]);
let s = codemap::get_line(fm, line as int);
if !str::ends_with(s, "\n") { s += "\n"; }
io::stdout().write_str(s);
io::stderr().write_str(s);
}
if elided {
let last_line = display_lines[vec::len(display_lines) - 1u];
Expand All @@ -214,7 +214,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
let out = "";
while indent > 0u { out += " "; indent -= 1u; }
out += "...\n";
io::stdout().write_str(out);
io::stderr().write_str(out);
}


Expand All @@ -239,7 +239,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
let width = hi.col - lo.col - 1u;
while width > 0u { str::push_char(s, '~'); width -= 1u; }
}
io::stdout().write_str(s + "\n");
io::stderr().write_str(s + "\n");
}
}

Expand Down
29 changes: 26 additions & 3 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,33 @@ fn run(lib_path: str, prog: str, args: [str],


writeclose(pipe_in.out, input);
let output = readclose(pipe_out.in);
let errput = readclose(pipe_err.in);
let p = comm::port();
let ch = comm::chan(p);
task::spawn_sched(1u) {||
let errput = readclose(pipe_err.in);
comm::send(ch, (2, errput));
};
task::spawn_sched(1u) {||
let output = readclose(pipe_out.in);
comm::send(ch, (1, output));
};
let status = run::waitpid(pid);
ret {status: status, out: output, err: errput};
let errs = "";
let outs = "";
let count = 2;
while count > 0 {
let stream = comm::recv(p);
alt stream {
(1, s) {
outs = s;
}
(2, s) {
errs = s;
}
};
count -= 1;
};
ret {status: status, out: outs, err: errs};
}

fn writeclose(fd: fd_t, s: option<str>) {
Expand Down
4 changes: 2 additions & 2 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ fn check_error_patterns(props: test_props,

let next_err_idx = 0u;
let next_err_pat = props.error_patterns[next_err_idx];
for line: str in str::split_byte(procres.stdout, '\n' as u8) {
for line: str in str::split_byte(procres.stderr, '\n' as u8) {
if str::find(line, next_err_pat) > 0 {
#debug("found error pattern %s", next_err_pat);
next_err_idx += 1u;
Expand Down Expand Up @@ -245,7 +245,7 @@ fn check_expected_errors(expected_errors: [errors::expected_error],
// filename:line1:col1: line2:col2: *warning:* msg
// where line1:col1: is the starting point, line2:col2:
// is the ending point, and * represents ANSI color codes.
for line: str in str::split_byte(procres.stdout, '\n' as u8) {
for line: str in str::split_byte(procres.stderr, '\n' as u8) {
let was_expected = false;
vec::iteri(expected_errors) {|i, ee|
if !found_flags[i] {
Expand Down
4 changes: 2 additions & 2 deletions src/rt/rust_srv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ rust_srv::realloc(void *p, size_t bytes) {

void
rust_srv::log(char const *msg) {
printf("rust: %s\n", msg);
fprintf(stderr, "rust: %s\n", msg);
// FIXME: flushing each time is expensive, but at the moment
// necessary to get output through before a rust_task::fail
// call. This should be changed.
fflush(stdout);
fflush(stderr);
}

void
Expand Down