diff --git a/src/libstd/test.rs b/src/libstd/test.rs index d0814c01f377a..ec06e1dd70482 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -91,7 +91,6 @@ enum test_result { tr_ok, tr_failed, tr_ignored, } type console_test_state = @{out: io::writer, log_out: option, - use_color: bool, mut total: uint, mut passed: uint, mut failed: uint, @@ -117,7 +116,6 @@ fn run_tests_console(opts: test_opts, let st = @{out: io::stdout(), log_out: log_out, - use_color: use_color(), mut total: 0u, mut passed: 0u, mut failed: 0u, @@ -150,18 +148,18 @@ fn run_tests_console(opts: test_opts, alt result { tr_ok { st.passed += 1u; - write_ok(st.out, st.use_color); + write_ok(st.out); st.out.write_line(""); } tr_failed { st.failed += 1u; - write_failed(st.out, st.use_color); + write_failed(st.out); st.out.write_line(""); st.failures += [test]; } tr_ignored { st.ignored += 1u; - write_ignored(st.out, st.use_color); + write_ignored(st.out); st.out.write_line(""); } } @@ -180,11 +178,9 @@ fn run_tests_console(opts: test_opts, } st.out.write_str(#fmt["\nresult: "]); - if success { - write_ok(st.out, true); - } else { write_failed(st.out, true); } - st.out.write_str(#fmt[". %u passed; %u failed; %u ignored\n\n", st.passed, - st.failed, st.ignored]); + if success { write_ok(st.out); } else { write_failed(st.out); } + st.out.write_str(#fmt[". %u passed; %u failed; %u ignored\n\n", + st.passed, st.failed, st.ignored]); ret success; @@ -197,24 +193,24 @@ fn run_tests_console(opts: test_opts, }, test.name)); } - fn write_ok(out: io::writer, use_color: bool) { - write_pretty(out, "ok", term::color_green, use_color); + fn write_ok(out: io::writer) { + write_pretty(out, "ok", term::color_green); } - fn write_failed(out: io::writer, use_color: bool) { - write_pretty(out, "FAILED", term::color_red, use_color); + fn write_failed(out: io::writer) { + write_pretty(out, "FAILED", term::color_red); } - fn write_ignored(out: io::writer, use_color: bool) { - write_pretty(out, "ignored", term::color_yellow, use_color); + fn write_ignored(out: io::writer) { + write_pretty(out, "ignored", term::color_yellow); } - fn write_pretty(out: io::writer, word: str, color: u8, use_color: bool) { - if use_color && term::color_supported() { + fn write_pretty(out: io::writer, word: str, color: u8) { + if term::color_supported() { term::fg(out, color); } out.write_str(word); - if use_color && term::color_supported() { + if term::color_supported() { term::reset(out); } } @@ -251,7 +247,6 @@ fn should_sort_failures_before_printing_them() { let st = @{out: writer, log_out: option::none, - use_color: false, mut total: 0u, mut passed: 0u, mut failed: 0u, @@ -267,8 +262,6 @@ fn should_sort_failures_before_printing_them() { assert apos < bpos; } -fn use_color() -> bool { ret get_concurrency() == 1u; } - enum testevent { te_filtered([test_desc]), te_wait(test_desc),