Skip to content

Commit

Permalink
fix(config): regression - handle relative patterns with leading dot s…
Browse files Browse the repository at this point in the history
…lash (#21922)

This is a hacky quick fix. We need to spend more time cleaning up this
code and push more stuff down into deno_config.

Closes #21916
  • Loading branch information
dsherret authored Jan 13, 2024
1 parent 0b9c06b commit daed588
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
6 changes: 6 additions & 0 deletions cli/tests/integration/test_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,3 +663,9 @@ fn conditionally_loads_type_graph() {
.run();
assert_not_contains!(output.combined_output(), "type_reference.d.ts");
}

itest!(test_include_relative_pattern_dot_slash {
args: "test",
output: "test/relative_pattern_dot_slash/output.out",
cwd: Some("test/relative_pattern_dot_slash"),
});
7 changes: 7 additions & 0 deletions cli/tests/testdata/test/relative_pattern_dot_slash/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"test": {
"include": [
"./test/**/*.test.mjs"
]
}
}
5 changes: 5 additions & 0 deletions cli/tests/testdata/test/relative_pattern_dot_slash/output.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
running 1 test from ./test/add.test.mjs
should add ... ok ([WILDCARD])

ok | 1 passed | 0 failed ([WILDCARD])

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function add(a, b) {
return a + b;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { add } from "./add.mjs";

Deno.test("should add", () => {
if (add(1, 2) !== 3) {
throw new Error("FAIL");
}
});
8 changes: 5 additions & 3 deletions cli/util/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ impl GlobPattern {
}

pub fn new(pattern: &str) -> Result<Self, AnyError> {
let pattern =
glob::Pattern::new(&escape_brackets(pattern).replace('\\', "/"))
.with_context(|| format!("Failed to expand glob: \"{}\"", pattern))?;
let pattern = escape_brackets(pattern)
.replace('\\', "/")
.replace("/./", "/");
let pattern = glob::Pattern::new(&pattern)
.with_context(|| format!("Failed to expand glob: \"{}\"", pattern))?;
Ok(Self(pattern))
}

Expand Down

0 comments on commit daed588

Please sign in to comment.