summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-01-13 10:39:22 -0500
committerGitHub <noreply@github.com>2024-01-13 10:39:22 -0500
commitdaed58855775b4da042272a296b500d9b9e76e7d (patch)
treeae5312c8bff3ecb71d2a97d9e291f1018cd2baec
parent0b9c06b632f25454f4aace8565830195e8320677 (diff)
fix(config): regression - handle relative patterns with leading dot slash (#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
-rw-r--r--cli/tests/integration/test_tests.rs6
-rw-r--r--cli/tests/testdata/test/relative_pattern_dot_slash/deno.json7
-rw-r--r--cli/tests/testdata/test/relative_pattern_dot_slash/output.out5
-rw-r--r--cli/tests/testdata/test/relative_pattern_dot_slash/test/add.mjs3
-rw-r--r--cli/tests/testdata/test/relative_pattern_dot_slash/test/add.test.mjs7
-rw-r--r--cli/util/glob.rs8
6 files changed, 33 insertions, 3 deletions
diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs
index 5150aeb92..97aba8051 100644
--- a/cli/tests/integration/test_tests.rs
+++ b/cli/tests/integration/test_tests.rs
@@ -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"),
+});
diff --git a/cli/tests/testdata/test/relative_pattern_dot_slash/deno.json b/cli/tests/testdata/test/relative_pattern_dot_slash/deno.json
new file mode 100644
index 000000000..7c2c4a5d3
--- /dev/null
+++ b/cli/tests/testdata/test/relative_pattern_dot_slash/deno.json
@@ -0,0 +1,7 @@
+{
+ "test": {
+ "include": [
+ "./test/**/*.test.mjs"
+ ]
+ }
+}
diff --git a/cli/tests/testdata/test/relative_pattern_dot_slash/output.out b/cli/tests/testdata/test/relative_pattern_dot_slash/output.out
new file mode 100644
index 000000000..be2961cff
--- /dev/null
+++ b/cli/tests/testdata/test/relative_pattern_dot_slash/output.out
@@ -0,0 +1,5 @@
+running 1 test from ./test/add.test.mjs
+should add ... ok ([WILDCARD])
+
+ok | 1 passed | 0 failed ([WILDCARD])
+
diff --git a/cli/tests/testdata/test/relative_pattern_dot_slash/test/add.mjs b/cli/tests/testdata/test/relative_pattern_dot_slash/test/add.mjs
new file mode 100644
index 000000000..7d658310b
--- /dev/null
+++ b/cli/tests/testdata/test/relative_pattern_dot_slash/test/add.mjs
@@ -0,0 +1,3 @@
+export function add(a, b) {
+ return a + b;
+}
diff --git a/cli/tests/testdata/test/relative_pattern_dot_slash/test/add.test.mjs b/cli/tests/testdata/test/relative_pattern_dot_slash/test/add.test.mjs
new file mode 100644
index 000000000..7b21d2fbc
--- /dev/null
+++ b/cli/tests/testdata/test/relative_pattern_dot_slash/test/add.test.mjs
@@ -0,0 +1,7 @@
+import { add } from "./add.mjs";
+
+Deno.test("should add", () => {
+ if (add(1, 2) !== 3) {
+ throw new Error("FAIL");
+ }
+});
diff --git a/cli/util/glob.rs b/cli/util/glob.rs
index 7bd600167..4fe8a9a0a 100644
--- a/cli/util/glob.rs
+++ b/cli/util/glob.rs
@@ -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))
}