1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use {TestResult,TestResultKind};
use std;
use term;
pub fn result(result: &TestResult) {
match result.kind {
TestResultKind::Pass => {
success(format!("PASS :: {}", result.path));
},
TestResultKind::Skip => {
line();
warning(format!(
"SKIP :: {} (test does not contain any directives)",
result.path));
line();
},
TestResultKind::Fail(ref msg, ref desc) => {
line();
failure(format!("FAIL :: {}", result.path));
text(msg.clone());
if !desc.is_empty() {
line();
text("stderr:");
line();
text(desc.clone());
}
line();
},
}
}
pub fn line() {
with("\n",
term::stdout().unwrap(),
term::color::WHITE);
}
pub fn text<S>(msg: S)
where S: Into<String> {
with(format!("{}\n", msg.into()),
term::stdout().unwrap(),
term::color::WHITE);
}
pub fn success<S>(msg: S)
where S: Into<String> {
with(format!("{}\n", msg.into()),
term::stdout().unwrap(),
term::color::GREEN);
}
pub fn warning<S>(msg: S)
where S: Into<String> {
with(format!("{}\n", msg.into()),
term::stderr().unwrap(),
term::color::YELLOW);
}
pub fn failure<S>(msg: S)
where S: Into<String> {
with(format!("{}\n", msg.into()),
term::stderr().unwrap(),
term::color::RED);
}
pub fn with<S,W>(msg: S,
mut term: Box<term::Terminal<Output=W>>,
color: term::color::Color)
where S: Into<String>, W: std::io::Write {
term.fg(color).unwrap();
write!(term, "{}", msg.into()).unwrap();
}