@@ -4,7 +4,6 @@ use anyhow::Result;
4
4
use libfuzzer_sys:: fuzz_target;
5
5
6
6
use std:: hint:: black_box;
7
- use std:: path:: Path ;
8
7
9
8
use arbitrary:: { Arbitrary , Unstructured } ;
10
9
use gix_attributes:: {
@@ -17,44 +16,26 @@ fn arbitrary_case(u: &mut Unstructured) -> arbitrary::Result<Case> {
17
16
Ok ( * u. choose ( & [ Case :: Sensitive , Case :: Fold ] ) ?)
18
17
}
19
18
20
- fn arbitrary_relative_path < ' a > ( u : & mut Unstructured < ' a > ) -> arbitrary:: Result < & ' a str > {
21
- let mut path = <& str >:: arbitrary ( u) ?;
22
- if path. starts_with ( "/" ) {
23
- path = path. trim_start_matches ( "/" ) ;
24
- }
25
- Ok ( path)
26
- }
27
-
28
19
#[ derive( Debug , Arbitrary ) ]
29
20
struct Ctx < ' a > {
30
21
pattern : & ' a str ,
31
- #[ arbitrary( with = arbitrary_relative_path) ]
32
- path : & ' a str ,
33
- relative_containing_dir : Option < & ' a str > ,
34
22
#[ arbitrary( with = arbitrary_case) ]
35
23
case : Case ,
36
24
}
37
25
38
- fn fuzz ( ctx : Ctx ) -> Result < ( ) > {
39
- let Ctx {
40
- pattern,
41
- path,
42
- relative_containing_dir,
43
- case,
44
- } = ctx;
45
-
26
+ fn fuzz ( Ctx { pattern, case } : Ctx ) -> Result < ( ) > {
46
27
let mut search = Search :: default ( ) ;
47
28
let mut collection = MetadataCollection :: default ( ) ;
48
29
search. add_patterns_buffer (
49
- format ! ( "{pattern} test " ) . as_bytes ( ) ,
50
- relative_containing_dir . map_or_else ( || Path :: new ( "<memory>" ) . into ( ) , |d| Path :: new ( d ) . join ( "filename" ) ) ,
51
- relative_containing_dir . map ( |_| Path :: new ( "" ) ) ,
30
+ format ! ( "{pattern} attr " ) . as_bytes ( ) ,
31
+ Default :: default ( ) ,
32
+ None ,
52
33
& mut collection,
53
34
true ,
54
35
) ;
55
36
let mut out = Outcome :: default ( ) ;
56
37
out. initialize ( & collection) ;
57
- _ = black_box ( search. pattern_matching_relative_path ( path. into ( ) , case, None , & mut out) ) ;
38
+ _ = black_box ( search. pattern_matching_relative_path ( "relative/ path" . into ( ) , case, None , & mut out) ) ;
58
39
Ok ( ( ) )
59
40
}
60
41
0 commit comments