File tree 3 files changed +22
-9
lines changed
3 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,13 @@ use std::sync::Mutex;
10
10
pub use color_eyre;
11
11
use color_eyre:: eyre:: Result ;
12
12
use colored:: * ;
13
- use comments :: ErrorMatch ;
13
+ use parser :: ErrorMatch ;
14
14
use regex:: Regex ;
15
15
use rustc_stderr:: { Level , Message } ;
16
16
17
- use crate :: comments :: { Comments , Condition } ;
17
+ use crate :: parser :: { Comments , Condition } ;
18
18
19
- mod comments ;
19
+ mod parser ;
20
20
mod rustc_stderr;
21
21
#[ cfg( test) ]
22
22
mod tests;
Original file line number Diff line number Diff line change @@ -117,12 +117,8 @@ impl Comments {
117
117
let next = args
118
118
. next ( )
119
119
. expect ( "the `position` above guarantees that there is at least one char" ) ;
120
- // FIXME: this replicates the existing flexibility in our syntax. Consider requiring the colon.
121
- let args = match next {
122
- ':' | ' ' => args. as_str ( ) ,
123
- _ => bail ! ( "expected space or `:`, got `{next}`" ) ,
124
- } ;
125
- ( command, args. trim ( ) )
120
+ ensure ! ( next == ':' , "test command must be followed by : (or end the line)" ) ;
121
+ ( command, args. as_str ( ) . trim ( ) )
126
122
}
127
123
} ;
128
124
@@ -188,16 +184,19 @@ impl Comments {
188
184
self . error_pattern = Some ( ( args. trim ( ) . to_string ( ) , l) ) ;
189
185
}
190
186
"stderr-per-bitwidth" => {
187
+ // args are ignored (can be used as comment)
191
188
ensure ! ( !self . stderr_per_bitwidth, "cannot specifiy stderr-per-bitwidth twice" ) ;
192
189
self . stderr_per_bitwidth = true ;
193
190
}
194
191
command => {
195
192
if let Some ( s) = command. strip_prefix ( "ignore-" ) {
193
+ // args are ignored (can be sue as comment)
196
194
self . ignore . push ( Condition :: parse ( s) ) ;
197
195
return Ok ( ( ) ) ;
198
196
}
199
197
200
198
if let Some ( s) = command. strip_prefix ( "only-" ) {
199
+ // args are ignored (can be sue as comment)
201
200
self . only . push ( Condition :: parse ( s) ) ;
202
201
return Ok ( ( ) ) ;
203
202
}
Original file line number Diff line number Diff line change @@ -53,3 +53,17 @@ use std::mem;
53
53
Err ( _) => Ok ( ( ) ) ,
54
54
}
55
55
}
56
+
57
+ #[ test]
58
+ fn missing_colon_fail ( ) -> Result < ( ) > {
59
+ init ( ) ;
60
+ let s = r"
61
+ //@stderr-per-bitwidth hello
62
+ use std::mem;
63
+
64
+ " ;
65
+ match Comments :: parse ( Path :: new ( "<dummy>" ) , s) {
66
+ Ok ( _) => bail ! ( "expected parsing to fail" ) ,
67
+ Err ( _) => Ok ( ( ) ) ,
68
+ }
69
+ }
You can’t perform that action at this time.
0 commit comments