|
142 | 142 | (should (equal expected-events events))
|
143 | 143 | (lsp-kill-watch watch)))
|
144 | 144 |
|
| 145 | +(ert-deftest lsp-file-watch--glob-split () |
| 146 | + (should (equal (lsp-glob-unbrace-at-top-level "{/home/alice/project/**/*.hs,/home/alice/project/stack.yaml}") |
| 147 | + '("/home/alice/project/**/*.hs" "/home/alice/project/stack.yaml"))) |
| 148 | + (should (equal (lsp-glob-unbrace-at-top-level "{/home/alice/project/**/*.{ml,eliom},/home/alice/project/dune.project}") |
| 149 | + '("/home/alice/project/**/*.{ml,eliom}" "/home/alice/project/dune.project")))) |
| 150 | + |
145 | 151 | (ert-deftest lsp-file-watch--glob-pattern ()
|
146 |
| - (should (string-match (lsp-glob-to-regexp "pom.xml") "pom.xml")) |
147 |
| - (should (string-match (lsp-glob-to-regexp "**/pom.xml") "/pom.xml")) |
148 |
| - (should (string-match (lsp-glob-to-regexp "**/*.xml") "data/pom.xml")) |
149 |
| - (should (string-match (lsp-glob-to-regexp "**/*.xml") "pom.xml")) |
| 152 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "pom.xml") "pom.xml")) |
| 153 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "**/pom.xml") "/pom.xml")) |
| 154 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "**/*.xml") "data/pom.xml")) |
| 155 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "**/*.xml") "pom.xml")) |
150 | 156 |
|
151 | 157 | ;; Some VSCode tests
|
152 | 158 | ;; (https://github.com/Microsoft/vscode/blob/466da1c9013c624140f6d1473b23a870abc82d44/src/vs/base/test/node/glob.test.ts)
|
153 |
| - (should (string-match (lsp-glob-to-regexp "**/.*") ".git")) |
154 |
| - (should (string-match (lsp-glob-to-regexp "**/.*") ".hidden.txt")) |
155 |
| - (should (not (string-match (lsp-glob-to-regexp "**/.*") "git"))) |
156 |
| - (should (not (string-match (lsp-glob-to-regexp "**/.*") "hidden.txt"))) |
| 159 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "**/.*") ".git")) |
| 160 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "**/.*") ".hidden.txt")) |
| 161 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "**/.*") "git"))) |
| 162 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "**/.*") "hidden.txt"))) |
157 | 163 |
|
158 |
| - (should (string-match (lsp-glob-to-regexp "**/.*") "path/.git")) |
159 |
| - (should (string-match (lsp-glob-to-regexp "**/.*") "path/.hidden.txt")) |
160 |
| - (should (not (string-match (lsp-glob-to-regexp "**/.*") "path/git"))) |
161 |
| - (should (not (string-match (lsp-glob-to-regexp "**/.*") "pat.h/hidden.txt"))) |
| 164 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "**/.*") "path/.git")) |
| 165 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "**/.*") "path/.hidden.txt")) |
| 166 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "**/.*") "path/git"))) |
| 167 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "**/.*") "pat.h/hidden.txt"))) |
162 | 168 |
|
163 |
| - (should (string-match (lsp-glob-to-regexp "**/node_modules/**") "node_modules")) |
164 |
| - (should (string-match (lsp-glob-to-regexp "**/node_modules/**") "node_modules/")) |
165 |
| - (should (not (string-match (lsp-glob-to-regexp "**/node_modules/**") "node/_modules/"))) |
| 169 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "**/node_modules/**") "node_modules")) |
| 170 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "**/node_modules/**") "node_modules/")) |
| 171 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "**/node_modules/**") "node/_modules/"))) |
166 | 172 |
|
167 |
| - (should (string-match (lsp-glob-to-regexp "?") "h")) |
168 |
| - (should (not (string-match (lsp-glob-to-regexp "?") "hi"))) |
| 173 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "?") "h")) |
| 174 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "?") "hi"))) |
169 | 175 |
|
170 |
| - (should (string-match (lsp-glob-to-regexp "foo.[[]") "foo.[")) |
| 176 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "foo.[[]") "foo.[")) |
171 | 177 |
|
172 |
| - (should (string-match (lsp-glob-to-regexp "{foo,bar}/**") "foo")) |
173 |
| - (should (string-match (lsp-glob-to-regexp "{foo,bar}/**") "bar")) |
174 |
| - (should (string-match (lsp-glob-to-regexp "{foo,bar}/**") "foo/test")) |
175 |
| - (should (string-match (lsp-glob-to-regexp "{foo,bar}/**") "bar/test")) |
| 178 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "{foo,bar}/**") "foo")) |
| 179 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "{foo,bar}/**") "bar")) |
| 180 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "{foo,bar}/**") "foo/test")) |
| 181 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "{foo,bar}/**") "bar/test")) |
176 | 182 |
|
177 |
| - (should (string-match (lsp-glob-to-regexp "{**/*.d.ts,**/*.js}") "/testing/foo.js")) |
178 |
| - (should (string-match (lsp-glob-to-regexp "{**/*.d.ts,**/*.js}") "testing/foo.d.ts")) |
179 |
| - (should (string-match (lsp-glob-to-regexp "{**/*.d.ts,**/*.js,foo.[0-9]}") "foo.5")) |
| 183 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "{**/*.d.ts,**/*.js}") "/testing/foo.js")) |
| 184 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "{**/*.d.ts,**/*.js}") "testing/foo.d.ts")) |
| 185 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "{**/*.d.ts,**/*.js,foo.[0-9]}") "foo.5")) |
180 | 186 |
|
181 |
| - (should (string-match (lsp-glob-to-regexp "some/**/*") "some/foo.js")) |
182 |
| - (should (string-match (lsp-glob-to-regexp "some/**/*") "some/folder/foo.js")) |
| 187 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "some/**/*") "some/foo.js")) |
| 188 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "some/**/*") "some/folder/foo.js")) |
183 | 189 |
|
184 |
| - (should (not (string-match (lsp-glob-to-regexp "some/**/*") "something/foo.js"))) |
185 |
| - (should (not (string-match (lsp-glob-to-regexp "some/**/*") "something/folder/foo.js"))) |
| 190 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "some/**/*") "something/foo.js"))) |
| 191 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "some/**/*") "something/folder/foo.js"))) |
186 | 192 |
|
187 |
| - (should (not (string-match (lsp-glob-to-regexp "{**/*.d.ts,**/*.js,foo.[0-9]}") "foo.f"))) |
188 |
| - (should (string-match (lsp-glob-to-regexp "prefix/{**/*.d.ts,**/*.js,foo.[0-9]}") "prefix/foo.8")) |
189 |
| - (should (not (string-match (lsp-glob-to-regexp "prefix/{**/*.d.ts,**/*.js,foo.[0-9]}") "prefix/foo.f"))) |
| 193 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "{**/*.d.ts,**/*.js,foo.[0-9]}") "foo.f"))) |
| 194 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "prefix/{**/*.d.ts,**/*.js,foo.[0-9]}") "prefix/foo.8")) |
| 195 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "prefix/{**/*.d.ts,**/*.js,foo.[0-9]}") "prefix/foo.f"))) |
190 | 196 |
|
191 |
| - (should (not (string-match (lsp-glob-to-regexp "foo.[!0-9]") "foo.5"))) |
192 |
| - (should (not (string-match (lsp-glob-to-regexp "foo.[!0-9]") "foo.8"))) |
193 |
| - (should (string-match (lsp-glob-to-regexp "foo.[!0-9]") "foo.f")) |
| 197 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "foo.[!0-9]") "foo.5"))) |
| 198 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "foo.[!0-9]") "foo.8"))) |
| 199 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "foo.[!0-9]") "foo.f")) |
194 | 200 |
|
195 |
| - (should (not (string-match (lsp-glob-to-regexp "foo.[^0-9]") "foo.5"))) |
196 |
| - (should (not (string-match (lsp-glob-to-regexp "foo.[^0-9]") "foo.8"))) |
197 |
| - (should (string-match (lsp-glob-to-regexp "foo.[^0-9]") "foo.f")) |
| 201 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "foo.[^0-9]") "foo.5"))) |
| 202 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "foo.[^0-9]") "foo.8"))) |
| 203 | + (should (string-match (lsp-glob-convert-to-wrapped-regexp "foo.[^0-9]") "foo.f")) |
198 | 204 |
|
199 | 205 | ;; ???: This should properly fail since path-separators should be
|
200 | 206 | ;; ignored inside brackets, but here (and in VSCode) it fails for a
|
|
206 | 212 | ;; way of handling this to recognize that because we're unbalanced
|
207 | 213 | ;; at the end, that everything should be treated as a literal. But
|
208 | 214 | ;; after experimenting with zsh, this isn't what they use.
|
209 |
| - (should (not (string-match (lsp-glob-to-regexp "foo[/]bar") "foo/bar")))) |
| 215 | + (should (not (string-match (lsp-glob-convert-to-wrapped-regexp "foo[/]bar") "foo/bar")))) |
210 | 216 |
|
211 | 217 | (ert-deftest lsp-file-watch--ignore-list ()
|
212 | 218 | :tags '(no-win)
|
|
0 commit comments