Skip to content

Commit

Permalink
Merge b5d2dd5 into b324e62
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra authored Feb 6, 2023
2 parents b324e62 + b5d2dd5 commit 7f10a5c
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions crates/turbo-tasks-fs/src/glob.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::mem::take;

use anyhow::{bail, Result};
use anyhow::{anyhow, bail, Context, Result};
use serde::{Deserialize, Serialize};
use turbo_tasks::trace::TraceRawVcs;

Expand Down Expand Up @@ -75,7 +75,8 @@ impl Glob {
let mut expression = Vec::new();

while !current.is_empty() {
let (part, remainder) = GlobPart::parse(current, false)?;
let (part, remainder) = GlobPart::parse(current, false)
.with_context(|| anyhow!("Failed to parse glob {input}"))?;
expression.push(part);
current = remainder;
}
Expand Down Expand Up @@ -198,7 +199,10 @@ impl GlobPart {
current = &current[1..];
break;
}
_ => bail!("Unterminated glob braces"),
None => bail!("Unterminated glob braces"),
_ => {
// next part of the glob
}
}
}

Expand Down Expand Up @@ -391,6 +395,20 @@ mod tests {
"**/*/next/dist/server/next.js",
"node_modules/next/dist/server/next.js"
)]
#[case::node_modules_root("**/node_modules/**", "node_modules/next/dist/server/next.js")]
#[case::node_modules_nested(
"**/node_modules/**",
"apps/some-app/node_modules/regenerate-unicode-properties/Script_Extensions/Osage.js"
)]
#[case::node_modules_pnpm(
"**/node_modules/**",
"node_modules/.pnpm/regenerate-unicode-properties@9.0.0/node_modules/\
regenerate-unicode-properties/Script_Extensions/Osage.js"
)]
#[case::alternatives_nested1("{a,b/c,d/e/{f,g/h}}", "a")]
#[case::alternatives_nested2("{a,b/c,d/e/{f,g/h}}", "b/c")]
#[case::alternatives_nested3("{a,b/c,d/e/{f,g/h}}", "d/e/f")]
#[case::alternatives_nested4("{a,b/c,d/e/{f,g/h}}", "d/e/g/h")]
fn glob_match(#[case] glob: &str, #[case] path: &str) {
let glob = Glob::parse(glob).unwrap();

Expand Down

0 comments on commit 7f10a5c

Please sign in to comment.