@@ -49,6 +49,7 @@ pub(crate) enum Status {
49
49
Success ,
50
50
/// Schemathesis found some failures.
51
51
Failure ,
52
+ Skip ,
52
53
/// Internal Schemathesis error.
53
54
Error ,
54
55
}
@@ -198,6 +199,10 @@ struct StdoutEntry<'a> {
198
199
failures : HashMap < & ' static str , u16 > ,
199
200
}
200
201
202
+ const HTTP_METHODS : & [ & str ] = & [
203
+ "GET " , "PUT " , "POST " , "DELETE " , "OPTIONS " , "HEAD " , "PATCH " , "TRACE " ,
204
+ ] ;
205
+
201
206
pub ( crate ) fn get_deduplicated_results ( directory : & Path , out_directory : & PathBuf ) {
202
207
let path = directory. join ( "stdout.txt" ) ;
203
208
let content = read_to_string ( path) . expect ( "Failed to read stdout.txt" ) ;
@@ -206,9 +211,13 @@ pub(crate) fn get_deduplicated_results(directory: &Path, out_directory: &PathBuf
206
211
}
207
212
let mut lines = content
208
213
. lines ( )
214
+ . skip_while ( |line| line. trim ( ) != "FAILURES" )
209
215
. filter_map ( |l| {
210
216
let trimmed = l. trim ( ) ;
211
- if trimmed. ends_with ( "[P]" ) || trimmed. ends_with ( "[N]" ) || STDOUT_FAILURE_RE . is_match ( l)
217
+ if HTTP_METHODS
218
+ . iter ( )
219
+ . any ( |method| trimmed. starts_with ( method) )
220
+ || STDOUT_FAILURE_RE . is_match ( l)
212
221
{
213
222
Some ( trimmed)
214
223
} else {
@@ -221,7 +230,11 @@ pub(crate) fn get_deduplicated_results(directory: &Path, out_directory: &PathBuf
221
230
let mut ser = serde_json:: Serializer :: new ( output_file) ;
222
231
let mut seq = ser. serialize_seq ( None ) . unwrap ( ) ;
223
232
while let Some ( line) = lines. next ( ) {
224
- if line. ends_with ( "[P]" ) || line. ends_with ( "[N]" ) {
233
+ let trimmed = line. trim ( ) ;
234
+ if HTTP_METHODS
235
+ . iter ( )
236
+ . any ( |method| trimmed. starts_with ( method) )
237
+ {
225
238
// New endpoint
226
239
let mut parts = line. split_ascii_whitespace ( ) ;
227
240
let method = parts. next ( ) . unwrap ( ) ;
@@ -251,10 +264,10 @@ pub(crate) fn get_deduplicated_results(directory: &Path, out_directory: &PathBuf
251
264
} else if UNEXPECTED_CONTENT_TYPE . captures ( next) . is_some ( ) {
252
265
seq. serialize_element ( & TestCase :: content_type_conformance ( method, path) )
253
266
. unwrap ( ) ;
254
- } else if next. contains ( "Response is missing the `Content-Type` header" ) {
267
+ } else if next. contains ( "response is missing the `Content-Type` header" ) {
255
268
seq. serialize_element ( & TestCase :: missing_content_type ( method, path) )
256
269
. unwrap ( ) ;
257
- } else if next. contains ( "Malformed media type" ) {
270
+ } else if next. contains ( "malformed media type" ) {
258
271
seq. serialize_element ( & TestCase :: malformed_media_type ( method, path) )
259
272
. unwrap ( ) ;
260
273
} else {
0 commit comments