diff options
| author | Bozhidar Batsov <bozhidar@toptal.com> | 2026-04-25 22:49:20 +0100 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@toptal.com> | 2026-04-25 22:49:20 +0100 |
| commit | 82fd4a5d3ab97cf5a8fdf65c38a68995ec1b3ef1 (patch) | |
| tree | a92f36f358531b0ebb5c2e6f0d02395952e7bf49 | |
| parent | 5e4471b10dc59274e7608489b28897a69c585cc8 (diff) | |
Add real-file integration tests for the dirconfig parser
The existing parser tests stub insert-file-contents; nothing exercises
the full IO path. Add three sandbox-based tests: a mixed +/-/!/no-prefix
file, a non-ASCII round-trip, and a file with no trailing newline. These
guard against IO-layer regressions that the stubbed tests can't see.
| -rw-r--r-- | test/projectile-test.el | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el index f460194..21e04f9 100644 --- a/test/projectile-test.el +++ b/test/projectile-test.el @@ -574,6 +574,49 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'. (expect (projectile-parse-dirconfig-file) :to-equal '(nil ("keep-this") nil))))) +(describe "projectile-parse-dirconfig-file with a real file" + (before-each + (clrhash projectile--dirconfig-cache)) + (it "parses a mix of keep, ignore, ensure and unprefixed entries from disk" + (projectile-test-with-sandbox + (projectile-test-with-files + ("project/.projectile") + (let ((root (file-truename (expand-file-name "project/")))) + (with-temp-file (expand-file-name ".projectile" root) + (insert "+/src\n" + "-/build\n" + "!/build/keepme\n" + "stale-pattern\n")) + (spy-on 'projectile-project-root :and-return-value root) + (expect (projectile-parse-dirconfig-file) + :to-equal '(("/src/") + ("/build" "stale-pattern") + ("/build/keepme"))))))) + (it "round-trips non-ASCII paths through the parser" + (projectile-test-with-sandbox + (projectile-test-with-files + ("project/.projectile") + (let ((root (file-truename (expand-file-name "project/"))) + (coding-system-for-write 'utf-8-unix)) + (with-temp-file (expand-file-name ".projectile" root) + (insert "-héllo/wörld\n" + "+/プロジェクト\n")) + (spy-on 'projectile-project-root :and-return-value root) + (expect (projectile-parse-dirconfig-file) + :to-equal '(("/プロジェクト/") + ("héllo/wörld") + nil)))))) + (it "tolerates a trailing line without a final newline" + (projectile-test-with-sandbox + (projectile-test-with-files + ("project/.projectile") + (let ((root (file-truename (expand-file-name "project/")))) + (with-temp-file (expand-file-name ".projectile" root) + (insert "-foo\n-bar")) + (spy-on 'projectile-project-root :and-return-value root) + (expect (cadr (projectile-parse-dirconfig-file)) + :to-equal '("foo" "bar"))))))) + (describe "dirconfig cache" (before-each (clrhash projectile--dirconfig-cache)) |
