aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/projectile-legacy-test.el112
-rw-r--r--test/projectile-test.el113
2 files changed, 113 insertions, 112 deletions
diff --git a/test/projectile-legacy-test.el b/test/projectile-legacy-test.el
index 0b79af1..d749253 100644
--- a/test/projectile-legacy-test.el
+++ b/test/projectile-legacy-test.el
@@ -41,118 +41,6 @@
(file-name-as-directory directory))))
(file-truename (projectile-project-root)))))))
-(ert-deftest projectile-test-ignored-directory-p ()
- (noflet ((projectile-ignored-directories () '("/path/to/project/tmp" "/path/to/project/t\\.*")))
- (should (projectile-ignored-directory-p "/path/to/project/tmp"))
- (should (projectile-ignored-directory-p "/path/to/project/t.ignore"))
- (should-not (projectile-ignored-directory-p "/path/to/project/log"))))
-
-(ert-deftest projectile-test-ignored-file-p ()
- (noflet ((projectile-ignored-files () '("/path/to/project/TAGS" "/path/to/project/T.*")))
- (should (projectile-ignored-file-p "/path/to/project/TAGS"))
- (should-not (projectile-ignored-file-p "/path/to/project/foo.el"))))
-
-(ert-deftest projectile-test-ignored-files ()
- (noflet ((projectile-project-root () "/path/to/project")
- (projectile-project-name () "project")
- (projectile-project-ignored-files () '("foo.js" "bar.rb")))
- (let ((expected '("/path/to/project/TAGS"
- "/path/to/project/foo.js"
- "/path/to/project/bar.rb"
- "/path/to/project/file1.log"
- "/path/to/project/file2.log"))
- (projectile-ignored-files '("TAGS" "file\d+\\.log")))
- (should-not (equal (projectile-ignored-files) expected)))))
-
-(ert-deftest projectile-test-ignored-directories ()
- (noflet ((projectile-project-ignored-directories () '("tmp" "log"))
- (projectile-project-root () "/path/to/project"))
- (let ((expected '("/path/to/project/compiled/"
- "/path/to/project/ignoreme"
- "/path/to/project/ignoremetoo"
- "/path/to/project/tmp"
- "/path/to/project/log"))
- (projectile-globally-ignored-directories '("compiled" "ignoreme")))
- (should-not (equal (projectile-ignored-directories) expected)))))
-
-(ert-deftest projectile-test-project-ignored-files ()
- (let ((files '("/path/to/project/foo.el" "/path/to/project/foo.elc")))
- (noflet ((projectile-project-ignored () files))
- (noflet ((file-directory-p (filename) nil))
- (should (equal (projectile-project-ignored-files) files)))
- (noflet ((file-directory-p (filename) t))
- (should-not (projectile-project-ignored-files))))))
-
-(ert-deftest projectile-test-project-ignored-directories ()
- (let ((directories '("/path/to/project/tmp" "/path/to/project/log")))
- (noflet ((projectile-project-ignored () directories))
- (noflet ((file-directory-p (filename) t))
- (should (equal (projectile-project-ignored-directories) directories)))
- (noflet ((file-directory-p (filename) nil))
- (should-not (projectile-project-ignored-directories))))))
-
-(ert-deftest projectile-test-project-ignored ()
- (noflet ((projectile-project-root () "/path/to/project")
- (projectile-project-name () "project"))
- (let* ((file-names '("log" "tmp" "compiled"))
- (files (mapcar 'projectile-expand-root file-names)))
- (noflet ((projectile-paths-to-ignore () (list "log" "tmp" "compiled"))
- (file-expand-wildcards (pattern ignored)
- (cond
- ((string-equal pattern "log")
- "/path/to/project/log")
- ((string-equal pattern "tmp")
- "/path/to/project/tmp")
- ((string-equal pattern "compiled")
- "/path/to/project/compiled"))))
- (should (equal (projectile-project-ignored) files))))))
-
-(ert-deftest projectile-remove-ignored-suffixes ()
- (noflet ((projectile-project-root () "/path/to/project")
- (projectile-project-name () "project")
- (projectile-ignored-files-rel () ())
- (projectile-ignored-directories-rel () ()))
- (let* ((file-names '("foo.c" "foo.o" "foo.so" "foo.o.gz" "foo.tar.gz" "foo.tar.GZ"))
- (files (mapcar 'projectile-expand-root file-names)))
- (let ((projectile-globally-ignored-file-suffixes '(".o" ".so" ".tar.gz")))
- (should (equal (projectile-remove-ignored files)
- (mapcar 'projectile-expand-root
- '("foo.c" "foo.o.gz"))))))))
-
-(ert-deftest projectile-add-unignored-files ()
- (noflet ((projectile-get-repo-ignored-files (project vcs) '("unignored-file"
- "path/unignored-file2")))
- (let ((projectile-globally-unignored-files '("unignored-file")))
- (should (equal (projectile-add-unignored '("file"))
- '("file" "unignored-file"))))
- ;; Files inside ignored paths need to be explicitely unignored
- (let ((projectile-globally-unignored-files '("unignored-file"
- "path/unignored-file2")))
- (should (equal (projectile-add-unignored '("file"))
- '("file" "unignored-file" "path/unignored-file2"))))))
-
-(ert-deftest projectile-add-unignored-files-no-vcs ()
- (noflet ((projectile-project-vcs (project) 'none))
- ;; on an unsupported VCS we simply return the list of globally unignored files
- (let ((projectile-globally-unignored-files '("unignored-file")))
- (should (equal (projectile-add-unignored '("file")) '("file"))))))
-
-(ert-deftest projectile-add-unignored-directories ()
- (noflet ((projectile-project-vcs (project) 'git)
- (projectile-get-repo-ignored-files (project vcs) '("path/unignored-file"))
- (projectile-get-repo-ignored-directory (project dir vcs) (list (concat dir "unignored-file"))))
- (let ((projectile-globally-unignored-directories '("path")))
- (should (equal (projectile-add-unignored '("file"))
- '("file" "path/unignored-file")))
- ;; Ignored files inside unignored paths need to be explicitly
- ;; unignored
- (let ((projectile-globally-ignored-files '("unignored-file")))
- (should (equal (projectile-add-unignored '("file"))
- '("file")))
- (let ((projectile-globally-unignored-files '("path/unignored-file")))
- (should (equal (projectile-add-unignored '("file"))
- '("file" "path/unignored-file"))))))))
-
(defun projectile-test-tmp-file-path ()
"Return a filename suitable to save data to in the
test temp directory"
diff --git a/test/projectile-test.el b/test/projectile-test.el
index a89fefa..f273913 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -100,6 +100,119 @@ test temp directory"
(it "caches the project type"
(expect (gethash (projectile-project-root) projectile-project-type-cache) :to-equal 'emacs-cask)))
+(describe "projectile-ignored-directory-p"
+ (it "checks if directory should be ignored"
+ (spy-on 'projectile-ignored-directories :and-return-value '("/path/to/project/tmp" "/path/to/project/t\\.*"))
+ (expect (projectile-ignored-directory-p "/path/to/project/tmp") :to-be-truthy)
+ (expect (projectile-ignored-directory-p "/path/to/project/t.ignore") :to-be-truthy)
+ (expect (projectile-ignored-directory-p "/path/to/project/log") :not :to-be-truthy)))
+
+(describe "projectile-ignored-file-p"
+ (it "checks if file should be ignored"
+ (spy-on 'projectile-ignored-files :and-return-value '("/path/to/project/TAGS" "/path/to/project/T.*"))
+ (expect (projectile-ignored-file-p "/path/to/project/TAGS") :to-be-truthy)
+ (expect (projectile-ignored-file-p "/path/to/project/foo.el") :not :to-be-truthy)))
+
+(describe "projectile-ignored-files"
+ (it "returns list of ignored files"
+ (spy-on 'projectile-project-root :and-return-value "/path/to/project")
+ (spy-on 'projectile-project-name :and-return-value "project")
+ (spy-on 'projectile-project-ignored-files :and-return-value '("foo.js" "bar.rb"))
+ (let ((files'("/path/to/project/TAGS"
+ "/path/to/project/foo.js"
+ "/path/to/project/bar.rb"
+ "/path/to/project/file1.log"
+ "/path/to/project/file2.log"))
+ (projectile-ignored-files '("TAGS" "file\d+\\.log")))
+ (expect (projectile-ignored-files) :not :to-equal files)
+ (expect (projectile-ignored-files) :to-equal '("/path/to/project/TAGS"
+ "/path/to/project/foo.js"
+ "/path/to/project/bar.rb")))))
+
+(describe "projectile-ignored-directories"
+ (it "returns list of ignored directories"
+ (spy-on 'projectile-project-ignored-directories :and-return-value '("tmp" "log"))
+ (spy-on 'projectile-project-root :and-return-value "/path/to/project")
+ (let ((paths '("/path/to/project/compiled/"
+ "/path/to/project/ignoreme"
+ "/path/to/project/ignoremetoo"
+ "/path/to/project/tmp"
+ "/path/to/project/log"))
+ (projectile-globally-ignored-directories '("compiled" "ignoreme")))
+ (expect (projectile-ignored-directories) :not :to-equal paths)
+ (expect (projectile-ignored-directories) :to-equal '("/path/to/project/compiled/"
+ "/path/to/project/ignoreme/"
+ "/path/to/project/tmp/"
+ "/path/to/project/log/")))))
+
+(describe "projectile-project-ignored-files"
+ (it "returns list of project ignored files"
+ (let ((files '("/path/to/project/foo.el" "/path/to/project/foo.elc")))
+ (spy-on 'projectile-project-ignored :and-return-value files)
+ (spy-on 'file-directory-p :and-return-value nil)
+ (expect (projectile-project-ignored-files) :to-equal files)
+ (spy-on 'file-directory-p :and-return-value t)
+ (expect (projectile-project-ignored-files) :not :to-be-truthy))))
+
+(describe "projectile-project-ignored-directories"
+ (it "returns list of project ignored directories"
+ (let ((directories '("/path/to/project/tmp" "/path/to/project/log")))
+ (spy-on 'projectile-project-ignored :and-return-value directories)
+ (spy-on 'file-directory-p :and-return-value t)
+ (expect (projectile-project-ignored-directories) :to-equal directories)
+ (spy-on 'file-directory-p :and-return-value nil)
+ (expect (projectile-project-ignored-directories) :not :to-be-truthy))))
+
+(describe "projectile-project-ignored"
+ (it "returns list of ignored files/directories"
+ (spy-on 'projectile-project-root :and-return-value "/path/to/project")
+ (spy-on 'projectile-project-name :and-return-value "project")
+ (spy-on 'projectile-paths-to-ignore :and-return-value (list "log" "tmp" "compiled"))
+ (spy-on 'file-expand-wildcards :and-call-fake
+ (lambda (pattern ignored)
+ (cond
+ ((string-equal pattern "log") "/path/to/project/log")
+ ((string-equal pattern "tmp") "/path/to/project/tmp")
+ ((string-equal pattern "compiled") "/path/to/project/compiled"))))
+ (let* ((file-names '("log" "tmp" "compiled"))
+ (files (mapcar 'projectile-expand-root file-names)))
+ (expect (projectile-project-ignored) :to-equal files))))
+
+(describe "projectile-remove-ignored"
+ (it "removes ignored folders and files"
+ (spy-on 'projectile-project-root :and-return-value "/path/to/project")
+ (spy-on 'projectile-project-name :and-return-value "project")
+ (spy-on 'projectile-ignored-files-rel)
+ (spy-on 'projectile-ignored-directories-rel)
+ (let* ((file-names '("foo.c" "foo.o" "foo.so" "foo.o.gz" "foo.tar.gz" "foo.tar.GZ"))
+ (files (mapcar 'projectile-expand-root file-names)))
+ (let ((projectile-globally-ignored-file-suffixes '(".o" ".so" ".tar.gz")))
+ (expect (projectile-remove-ignored files) :to-equal (mapcar 'projectile-expand-root '("foo.c" "foo.o.gz")))))))
+
+(describe "projectile-add-unignored"
+ (it "requires explicitly unignoring files inside ignored paths"
+ (spy-on 'projectile-get-repo-ignored-files :and-return-value '("unignored-file" "path/unignored-file2"))
+ (let ((projectile-globally-unignored-files '("unignored-file")))
+ (expect (projectile-add-unignored nil nil '("file")) :to-equal '("file" "unignored-file")))
+ (let ((projectile-globally-unignored-files '("unignored-file" "path/unignored-file2")))
+ (expect (projectile-add-unignored nil nil '("file")) :to-equal '("file" "unignored-file" "path/unignored-file2"))))
+ (it "returns the list of globally unignored files on an unsupported VCS"
+ (spy-on 'projectile-project-vcs :and-return-value 'none)
+ (let ((projectile-globally-unignored-files '("unignored-file")))
+ (expect (projectile-add-unignored nil nil '("file")) :to-equal '("file"))))
+ (it "requires explicitly unignoring ignored files inside unignored paths"
+ (spy-on 'projectile-project-vcs :and-return-value 'git)
+ (spy-on 'projectile-get-repo-ignored-files :and-return-value '("path/unignored-file"))
+ (spy-on 'projectile-get-repo-ignored-directory :and-call-fake
+ (lambda (project vcs dir)
+ (list (concat dir "unignored-file"))))
+ (let ((projectile-globally-unignored-directories '("path")))
+ (expect (projectile-add-unignored nil nil '("file")) :to-equal '("file" "path/unignored-file"))
+ (let ((projectile-globally-ignored-files '("unignored-file")))
+ (expect (projectile-add-unignored nil nil '("file")) :to-equal '("file"))
+ (let ((projectile-globally-unignored-files '("path/unignored-file")))
+ (expect (projectile-add-unignored nil nil '("file")) :to-equal '("file" "path/unignored-file")))))))
+
(describe "projectile-parse-dirconfig-file"
(it "parses dirconfig and returns directories to ignore and keep"
(spy-on 'file-exists-p :and-return-value t)