From 81b31429e48ec6ea8fd91679246d847ecf0fc762 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 31 Aug 2011 14:59:45 -0700 Subject: [PATCH] Remove more uses of str from std::run. Issue #855 --- src/fuzzer/fuzzer.rs | 38 +++++++++++++++++++------------------- src/lib/run_program.rs | 8 ++++---- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 44d80bd3d7dc..4e53f79a6bb4 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -197,51 +197,51 @@ fn check_whole_compiler(code: &str) { //log_err #ifmt("Status: %d", p.status); //log_err "Output: " + p.out; - if p.err != "" { - if contains(p.err, "argument of incompatible type") { + if p.err != ~"" { + if contains(istr::to_estr(p.err), "argument of incompatible type") { log_err "https://github.com/graydon/rust/issues/769"; - } else if contains(p.err, + } else if contains(istr::to_estr(p.err), "Cannot create binary operator with two operands of differing type") { log_err "https://github.com/graydon/rust/issues/770"; - } else if contains(p.err, "May only branch on boolean predicates!") { + } else if contains(istr::to_estr(p.err), "May only branch on boolean predicates!") { log_err "https://github.com/graydon/rust/issues/770 or https://github.com/graydon/rust/issues/776"; - } else if contains(p.err, "Invalid constantexpr cast!") && + } else if contains(istr::to_estr(p.err), "Invalid constantexpr cast!") && contains(code, "!") { log_err "https://github.com/graydon/rust/issues/777"; - } else if contains(p.err, + } else if contains(istr::to_estr(p.err), "Both operands to ICmp instruction are not of the same type!") && contains(code, "!") { log_err "https://github.com/graydon/rust/issues/777 #issuecomment-1678487"; - } else if contains(p.err, "Ptr must be a pointer to Val type!") && + } else if contains(istr::to_estr(p.err), "Ptr must be a pointer to Val type!") && contains(code, "!") { log_err "https://github.com/graydon/rust/issues/779"; - } else if contains(p.err, "Calling a function with bad signature!") && + } else if contains(istr::to_estr(p.err), "Calling a function with bad signature!") && (contains(code, "iter") || contains(code, "range")) { log_err "https://github.com/graydon/rust/issues/771 - calling an iter fails"; - } else if contains(p.err, "Calling a function with a bad signature!") + } else if contains(istr::to_estr(p.err), "Calling a function with a bad signature!") && contains(code, "empty") { log_err "https://github.com/graydon/rust/issues/775 - possibly a modification of run-pass/import-glob-crate.rs"; - } else if contains(p.err, "Invalid type for pointer element!") && + } else if contains(istr::to_estr(p.err), "Invalid type for pointer element!") && contains(code, "put") { log_err "https://github.com/graydon/rust/issues/773 - put put ()"; - } else if contains(p.err, "pointer being freed was not allocated") && - contains(p.out, "Out of stack space, sorry") { + } else if contains(istr::to_estr(p.err), "pointer being freed was not allocated") && + contains(istr::to_estr(p.out), "Out of stack space, sorry") { log_err "https://github.com/graydon/rust/issues/768 + https://github.com/graydon/rust/issues/778" } else { - log_err "Stderr: " + p.err; + log_err ~"Stderr: " + p.err; fail "Unfamiliar error message"; } - } else if contains(p.out, "non-exhaustive match failure") && - contains(p.out, "alias.rs") { + } else if contains(istr::to_estr(p.out), "non-exhaustive match failure") && + contains(istr::to_estr(p.out), "alias.rs") { log_err "https://github.com/graydon/rust/issues/772"; - } else if contains(p.out, "non-exhaustive match failure") && - contains(p.out, "trans.rs") && contains(code, "put") { + } else if contains(istr::to_estr(p.out), "non-exhaustive match failure") && + contains(istr::to_estr(p.out), "trans.rs") && contains(code, "put") { log_err "https://github.com/graydon/rust/issues/774"; - } else if contains(p.out, "Out of stack space, sorry") { + } else if contains(istr::to_estr(p.out), "Out of stack space, sorry") { log_err "Possibly a variant of https://github.com/graydon/rust/issues/768"; } else if p.status == 256 { - if !contains(p.out, "error:") { + if !contains(istr::to_estr(p.out), "error:") { fail "Exited with status 256 without a span-error"; } } else if p.status == 11 { diff --git a/src/lib/run_program.rs b/src/lib/run_program.rs index 6d6940db872f..f8dfa56d950e 100644 --- a/src/lib/run_program.rs +++ b/src/lib/run_program.rs @@ -100,17 +100,17 @@ fn start_program(prog: &istr, args: &[istr]) -> @program_res { os::fd_FILE(pipe_err.in), false)); } -fn read_all(rd: &io::reader) -> str { - let buf = ""; +fn read_all(rd: &io::reader) -> istr { + let buf = ~""; while !rd.eof() { let bytes = rd.read_bytes(4096u); - buf += str::unsafe_from_bytes(bytes); + buf += istr::unsafe_from_bytes(bytes); } ret buf; } fn program_output(prog: &istr, args: &[istr]) -> - {status: int, out: str, err: str} { + {status: int, out: istr, err: istr} { let pr = start_program(prog, args); pr.close_input(); ret {status: pr.finish(),