globset: add opt-in Arbitrary trait implementations

This feature is mandatory when using `Glob` in fuzz testing.

Closes #2720
This commit is contained in:
William Johnson
2024-01-24 11:15:22 -05:00
committed by Andrew Gallant
parent bfe2def121
commit 52115ab633
12 changed files with 358 additions and 1 deletions

View File

@@ -72,6 +72,7 @@ impl MatchStrategy {
/// It cannot be used directly to match file paths, but it can be converted
/// to a regular expression string or a matcher.
#[derive(Clone, Debug, Eq)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Glob {
glob: String,
re: String,
@@ -194,6 +195,7 @@ pub struct GlobBuilder<'a> {
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
struct GlobOptions {
/// Whether to match case insensitively.
case_insensitive: bool,
@@ -220,6 +222,7 @@ impl GlobOptions {
}
#[derive(Clone, Debug, Default, Eq, PartialEq)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
struct Tokens(Vec<Token>);
impl std::ops::Deref for Tokens {
@@ -236,6 +239,7 @@ impl std::ops::DerefMut for Tokens {
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
enum Token {
Literal(char),
Any,