File tree Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -36,16 +36,63 @@ fn test_main(&test_desc[] tests) -> int {
36
36
}
37
37
38
38
fn run_tests( & test_desc[ ] tests) -> bool {
39
+
39
40
auto out = io:: stdout ( ) ;
40
41
42
+ auto total = ivec:: len ( tests) ;
43
+ out. write_line ( #fmt ( "running %u tests" , total) ) ;
44
+
45
+ auto passed = 0 u;
46
+ auto failed = 0 u;
47
+
41
48
for ( test_desc test in tests) {
42
- out. write_line ( "running " + test. name ) ;
49
+ out. write_str ( #fmt ( "running %s ... " , test. name ) ) ;
50
+ if ( run_test ( test) ) {
51
+ passed += 1 u;
52
+ write_ok ( out) ;
53
+ out. write_line ( "" ) ;
54
+ } else {
55
+ failed += 1 u;
56
+ write_failed ( out) ;
57
+ out. write_line ( "" ) ;
58
+ }
43
59
}
44
60
61
+ assert passed + failed == total;
62
+
63
+ out. write_str ( #fmt ( "\n results: %u passed; %u failed\n \n " ,
64
+ passed, failed) ) ;
65
+
45
66
ret true;
67
+
68
+ fn run_test ( & test_desc test) -> bool {
69
+ test. fn ( ) ;
70
+ ret true;
71
+ }
72
+
73
+ fn write_ok ( & io:: writer out) {
74
+ if ( term:: color_supported ( ) ) {
75
+ term:: fg ( out. get_buf_writer ( ) , term:: color_green) ;
76
+ }
77
+ out. write_str ( "ok" ) ;
78
+ if ( term:: color_supported ( ) ) {
79
+ term:: reset ( out. get_buf_writer ( ) ) ;
80
+ }
81
+ }
82
+
83
+ fn write_failed ( & io:: writer out) {
84
+ if ( term:: color_supported ( ) ) {
85
+ term:: fg ( out. get_buf_writer ( ) , term:: color_red) ;
86
+ }
87
+ out. write_str ( "FAILED" ) ;
88
+ if ( term:: color_supported ( ) ) {
89
+ term:: reset ( out. get_buf_writer ( ) ) ;
90
+ }
91
+ }
46
92
}
47
93
48
94
95
+
49
96
// Local Variables:
50
97
// mode: rust;
51
98
// fill-column: 78;
You can’t perform that action at this time.
0 commit comments