@@ -43,10 +43,22 @@ pub trait StatusEmitter: Sync + RefUnwindSafe {
43
43
) -> Box < dyn Summary > ;
44
44
}
45
45
46
+ /// Some configuration options for revisions
47
+ #[ derive( Debug , Clone , Copy ) ]
48
+ pub enum RevisionStyle {
49
+ /// Things like dependencies or aux files building are noise in non-interactif mode
50
+ /// and thus silenced.
51
+ Quiet ,
52
+ /// Always show them, even if rendering to a file
53
+ Show ,
54
+ /// The parent, only show in indicatif mode and on failure
55
+ Parent ,
56
+ }
57
+
46
58
/// Information about a specific test run.
47
59
pub trait TestStatus : Send + Sync + RefUnwindSafe {
48
60
/// Create a copy of this test for a new revision.
49
- fn for_revision ( & self , revision : & str ) -> Box < dyn TestStatus > ;
61
+ fn for_revision ( & self , revision : & str , style : RevisionStyle ) -> Box < dyn TestStatus > ;
50
62
51
63
/// Create a copy of this test for a new path.
52
64
fn for_path ( & self , path : & Path ) -> Box < dyn TestStatus > ;
@@ -60,9 +72,6 @@ pub trait TestStatus: Send + Sync + RefUnwindSafe {
60
72
stdout : & ' a [ u8 ] ,
61
73
) -> Box < dyn Debug + ' a > ;
62
74
63
- /// Change the status of the test while it is running to supply some kind of progress
64
- fn update_status ( & self , msg : String ) ;
65
-
66
75
/// A test has finished, handle the result immediately.
67
76
fn done ( & self , _result : & TestResult ) { }
68
77
@@ -111,7 +120,7 @@ pub struct SilentStatus {
111
120
}
112
121
113
122
impl TestStatus for SilentStatus {
114
- fn for_revision ( & self , revision : & str ) -> Box < dyn TestStatus > {
123
+ fn for_revision ( & self , revision : & str , _style : RevisionStyle ) -> Box < dyn TestStatus > {
115
124
Box :: new ( SilentStatus {
116
125
revision : revision. into ( ) ,
117
126
path : self . path . clone ( ) ,
@@ -134,8 +143,6 @@ impl TestStatus for SilentStatus {
134
143
Box :: new ( ( ) )
135
144
}
136
145
137
- fn update_status ( & self , _msg : String ) { }
138
-
139
146
fn path ( & self ) -> & Path {
140
147
& self . path
141
148
}
@@ -179,7 +186,6 @@ enum Msg {
179
186
Inc ,
180
187
IncLength ,
181
188
Finish ,
182
- Status ( String , String ) ,
183
189
}
184
190
185
191
impl Text {
@@ -212,9 +218,6 @@ impl Text {
212
218
spinner. finish_and_clear ( ) ;
213
219
}
214
220
}
215
- Msg :: Status ( msg, status) => {
216
- threads. get_mut ( & msg) . unwrap ( ) . set_message ( status) ;
217
- }
218
221
Msg :: Push ( msg) => {
219
222
let spinner =
220
223
bars. add ( ProgressBar :: new_spinner ( ) . with_prefix ( msg. clone ( ) ) ) ;
@@ -295,6 +298,7 @@ struct TextTest {
295
298
path : PathBuf ,
296
299
revision : String ,
297
300
first : AtomicBool ,
301
+ style : RevisionStyle ,
298
302
}
299
303
300
304
impl TextTest {
@@ -322,17 +326,23 @@ impl TestStatus for TextTest {
322
326
let old_msg = self . msg ( ) ;
323
327
let msg = format ! ( "... {result}" ) ;
324
328
if ProgressDrawTarget :: stdout ( ) . is_hidden ( ) {
325
- println ! ( "{old_msg} {msg}" ) ;
326
- std:: io:: stdout ( ) . flush ( ) . unwrap ( ) ;
329
+ match self . style {
330
+ RevisionStyle :: Quiet => { }
331
+ RevisionStyle :: Show | RevisionStyle :: Parent => {
332
+ let revision = if self . revision . is_empty ( ) {
333
+ String :: new ( )
334
+ } else {
335
+ format ! ( " (revision `{}`)" , self . revision)
336
+ } ;
337
+ println ! ( "{}{revision} {msg}" , display( & self . path) ) ;
338
+ std:: io:: stdout ( ) . flush ( ) . unwrap ( ) ;
339
+ }
340
+ }
327
341
}
328
342
self . text . sender . send ( Msg :: Pop ( old_msg, Some ( msg) ) ) . unwrap ( ) ;
329
343
}
330
344
}
331
345
332
- fn update_status ( & self , msg : String ) {
333
- self . text . sender . send ( Msg :: Status ( self . msg ( ) , msg) ) . unwrap ( ) ;
334
- }
335
-
336
346
fn failed_test < ' a > (
337
347
& self ,
338
348
cmd : & str ,
@@ -373,7 +383,7 @@ impl TestStatus for TextTest {
373
383
& self . path
374
384
}
375
385
376
- fn for_revision ( & self , revision : & str ) -> Box < dyn TestStatus > {
386
+ fn for_revision ( & self , revision : & str , style : RevisionStyle ) -> Box < dyn TestStatus > {
377
387
if !self . first . swap ( false , std:: sync:: atomic:: Ordering :: Relaxed )
378
388
&& self . text . is_quiet_output ( )
379
389
{
@@ -385,6 +395,7 @@ impl TestStatus for TextTest {
385
395
path : self . path . clone ( ) ,
386
396
revision : revision. to_owned ( ) ,
387
397
first : AtomicBool :: new ( false ) ,
398
+ style,
388
399
} ;
389
400
self . text . sender . send ( Msg :: Push ( text. msg ( ) ) ) . unwrap ( ) ;
390
401
Box :: new ( text)
@@ -396,6 +407,7 @@ impl TestStatus for TextTest {
396
407
path : path. to_path_buf ( ) ,
397
408
revision : self . revision . clone ( ) ,
398
409
first : AtomicBool :: new ( false ) ,
410
+ style : RevisionStyle :: Show ,
399
411
} ;
400
412
self . text . sender . send ( Msg :: Push ( text. msg ( ) ) ) . unwrap ( ) ;
401
413
Box :: new ( text)
@@ -416,6 +428,7 @@ impl StatusEmitter for Text {
416
428
path,
417
429
revision : String :: new ( ) ,
418
430
first : AtomicBool :: new ( true ) ,
431
+ style : RevisionStyle :: Parent ,
419
432
} )
420
433
}
421
434
@@ -917,7 +930,7 @@ impl<const GROUP: bool> TestStatus for PathAndRev<GROUP> {
917
930
& self . path
918
931
}
919
932
920
- fn for_revision ( & self , revision : & str ) -> Box < dyn TestStatus > {
933
+ fn for_revision ( & self , revision : & str , _style : RevisionStyle ) -> Box < dyn TestStatus > {
921
934
Box :: new ( Self {
922
935
path : self . path . clone ( ) ,
923
936
revision : revision. to_owned ( ) ,
@@ -946,8 +959,6 @@ impl<const GROUP: bool> TestStatus for PathAndRev<GROUP> {
946
959
fn revision ( & self ) -> & str {
947
960
& self . revision
948
961
}
949
-
950
- fn update_status ( & self , _msg : String ) { }
951
962
}
952
963
953
964
impl < const GROUP : bool > StatusEmitter for Gha < GROUP > {
@@ -1050,18 +1061,16 @@ impl<T: TestStatus, U: TestStatus> TestStatus for (T, U) {
1050
1061
rev
1051
1062
}
1052
1063
1053
- fn for_revision ( & self , revision : & str ) -> Box < dyn TestStatus > {
1054
- Box :: new ( ( self . 0 . for_revision ( revision) , self . 1 . for_revision ( revision) ) )
1064
+ fn for_revision ( & self , revision : & str , style : RevisionStyle ) -> Box < dyn TestStatus > {
1065
+ Box :: new ( (
1066
+ self . 0 . for_revision ( revision, style) ,
1067
+ self . 1 . for_revision ( revision, style) ,
1068
+ ) )
1055
1069
}
1056
1070
1057
1071
fn for_path ( & self , path : & Path ) -> Box < dyn TestStatus > {
1058
1072
Box :: new ( ( self . 0 . for_path ( path) , self . 1 . for_path ( path) ) )
1059
1073
}
1060
-
1061
- fn update_status ( & self , msg : String ) {
1062
- self . 0 . update_status ( msg. clone ( ) ) ;
1063
- self . 1 . update_status ( msg)
1064
- }
1065
1074
}
1066
1075
1067
1076
impl < T : StatusEmitter , U : StatusEmitter > StatusEmitter for ( T , U ) {
@@ -1099,8 +1108,8 @@ impl<T: TestStatus + ?Sized> TestStatus for Box<T> {
1099
1108
( * * self ) . revision ( )
1100
1109
}
1101
1110
1102
- fn for_revision ( & self , revision : & str ) -> Box < dyn TestStatus > {
1103
- ( * * self ) . for_revision ( revision)
1111
+ fn for_revision ( & self , revision : & str , style : RevisionStyle ) -> Box < dyn TestStatus > {
1112
+ ( * * self ) . for_revision ( revision, style )
1104
1113
}
1105
1114
1106
1115
fn for_path ( & self , path : & Path ) -> Box < dyn TestStatus > {
@@ -1115,10 +1124,6 @@ impl<T: TestStatus + ?Sized> TestStatus for Box<T> {
1115
1124
) -> Box < dyn Debug + ' a > {
1116
1125
( * * self ) . failed_test ( cmd, stderr, stdout)
1117
1126
}
1118
-
1119
- fn update_status ( & self , msg : String ) {
1120
- ( * * self ) . update_status ( msg)
1121
- }
1122
1127
}
1123
1128
1124
1129
impl < T : StatusEmitter + ?Sized > StatusEmitter for Box < T > {
0 commit comments