Skip to content

Commit cbcc88d

Browse files
committed
---
yaml --- r: 15462 b: refs/heads/try c: 2955ecd h: refs/heads/master v: v3
1 parent 39707a2 commit cbcc88d

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 1adc26d5e750b9cfd06981533056c59b68a78a1b
5+
refs/heads/try: 2955ecd13c3c49a8c17dd2d02fdc75e66b5097a4
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/libstd/test.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ enum test_result { tr_ok, tr_failed, tr_ignored, }
9191
type console_test_state =
9292
@{out: io::writer,
9393
log_out: option<io::writer>,
94+
use_color: bool,
9495
mut total: uint,
9596
mut passed: uint,
9697
mut failed: uint,
@@ -116,6 +117,7 @@ fn run_tests_console(opts: test_opts,
116117
let st =
117118
@{out: io::stdout(),
118119
log_out: log_out,
120+
use_color: use_color(),
119121
mut total: 0u,
120122
mut passed: 0u,
121123
mut failed: 0u,
@@ -148,18 +150,18 @@ fn run_tests_console(opts: test_opts,
148150
alt result {
149151
tr_ok {
150152
st.passed += 1u;
151-
write_ok(st.out);
153+
write_ok(st.out, st.use_color);
152154
st.out.write_line("");
153155
}
154156
tr_failed {
155157
st.failed += 1u;
156-
write_failed(st.out);
158+
write_failed(st.out, st.use_color);
157159
st.out.write_line("");
158160
st.failures += [test];
159161
}
160162
tr_ignored {
161163
st.ignored += 1u;
162-
write_ignored(st.out);
164+
write_ignored(st.out, st.use_color);
163165
st.out.write_line("");
164166
}
165167
}
@@ -178,9 +180,11 @@ fn run_tests_console(opts: test_opts,
178180
}
179181

180182
st.out.write_str(#fmt["\nresult: "]);
181-
if success { write_ok(st.out); } else { write_failed(st.out); }
182-
st.out.write_str(#fmt[". %u passed; %u failed; %u ignored\n\n",
183-
st.passed, st.failed, st.ignored]);
183+
if success {
184+
write_ok(st.out, true);
185+
} else { write_failed(st.out, true); }
186+
st.out.write_str(#fmt[". %u passed; %u failed; %u ignored\n\n", st.passed,
187+
st.failed, st.ignored]);
184188

185189
ret success;
186190

@@ -193,24 +197,24 @@ fn run_tests_console(opts: test_opts,
193197
}, test.name));
194198
}
195199

196-
fn write_ok(out: io::writer) {
197-
write_pretty(out, "ok", term::color_green);
200+
fn write_ok(out: io::writer, use_color: bool) {
201+
write_pretty(out, "ok", term::color_green, use_color);
198202
}
199203

200-
fn write_failed(out: io::writer) {
201-
write_pretty(out, "FAILED", term::color_red);
204+
fn write_failed(out: io::writer, use_color: bool) {
205+
write_pretty(out, "FAILED", term::color_red, use_color);
202206
}
203207

204-
fn write_ignored(out: io::writer) {
205-
write_pretty(out, "ignored", term::color_yellow);
208+
fn write_ignored(out: io::writer, use_color: bool) {
209+
write_pretty(out, "ignored", term::color_yellow, use_color);
206210
}
207211

208-
fn write_pretty(out: io::writer, word: str, color: u8) {
209-
if term::color_supported() {
212+
fn write_pretty(out: io::writer, word: str, color: u8, use_color: bool) {
213+
if use_color && term::color_supported() {
210214
term::fg(out, color);
211215
}
212216
out.write_str(word);
213-
if term::color_supported() {
217+
if use_color && term::color_supported() {
214218
term::reset(out);
215219
}
216220
}
@@ -247,6 +251,7 @@ fn should_sort_failures_before_printing_them() {
247251
let st =
248252
@{out: writer,
249253
log_out: option::none,
254+
use_color: false,
250255
mut total: 0u,
251256
mut passed: 0u,
252257
mut failed: 0u,
@@ -262,6 +267,8 @@ fn should_sort_failures_before_printing_them() {
262267
assert apos < bpos;
263268
}
264269

270+
fn use_color() -> bool { ret get_concurrency() == 1u; }
271+
265272
enum testevent {
266273
te_filtered([test_desc]),
267274
te_wait(test_desc),

0 commit comments

Comments
 (0)