aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@toptal.com>2026-04-25 22:50:36 +0100
committerBozhidar Batsov <bozhidar@toptal.com>2026-04-25 22:50:36 +0100
commita8a90311044f240f9b1d4789a32d5144f8d955ec (patch)
tree30513d86b30bb72a405713fdb7c8969ab8568482 /test
parent82fd4a5d3ab97cf5a8fdf65c38a68995ec1b3ef1 (diff)
Warn when a + keep entry contains glob metacharactersdirconfig-improvements
The parser silently turns every keep entry into a directory via file-name-as-directory, which means a user-typed +*.json or +/foo.txt becomes "*.json/" or "foo.txt/" and quietly never matches anything. Spot the obvious misuses (anything containing *, ?, or [) at parse time and emit a warning so the user can correct the file or move the pattern to an ignore/ensure rule.
Diffstat (limited to 'test')
-rw-r--r--test/projectile-test.el26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el
index 21e04f9..7e1e2a1 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -572,7 +572,31 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
"-keep-this\n"))))
(let ((projectile-dirconfig-comment-prefix ?#))
(expect (projectile-parse-dirconfig-file)
- :to-equal '(nil ("keep-this") nil)))))
+ :to-equal '(nil ("keep-this") nil))))
+ (it "warns when a + keep entry contains glob metacharacters"
+ (spy-on 'file-exists-p :and-return-value t)
+ (spy-on 'insert-file-contents :and-call-fake
+ (lambda (_filename)
+ (save-excursion (insert "+/*.json\n+/src\n"))))
+ (spy-on 'display-warning)
+ (projectile-parse-dirconfig-file)
+ (expect 'display-warning :to-have-been-called-times 1))
+ (it "does not warn for plain + subdirectory entries"
+ (spy-on 'file-exists-p :and-return-value t)
+ (spy-on 'insert-file-contents :and-call-fake
+ (lambda (_filename)
+ (save-excursion (insert "+/src\n+/tests/foo\n"))))
+ (spy-on 'display-warning)
+ (projectile-parse-dirconfig-file)
+ (expect 'display-warning :not :to-have-been-called))
+ (it "does not warn for - ignore entries that contain globs"
+ (spy-on 'file-exists-p :and-return-value t)
+ (spy-on 'insert-file-contents :and-call-fake
+ (lambda (_filename)
+ (save-excursion (insert "-*.json\n-build/*.tmp\n"))))
+ (spy-on 'display-warning)
+ (projectile-parse-dirconfig-file)
+ (expect 'display-warning :not :to-have-been-called)))
(describe "projectile-parse-dirconfig-file with a real file"
(before-each