diff --git a/eldev-plugins.el b/eldev-plugins.el index 7d2e0ff..cd3dcbc 100644 --- a/eldev-plugins.el +++ b/eldev-plugins.el @@ -61,7 +61,7 @@ Since 0.3." ;; Autoloads. (defun eldev--autoloads-source-dir () - (if eldev-project-source-dirs (file-name-as-directory (car eldev-project-source-dirs)) "")) + (if eldev-project-source-dirs (file-name-as-directory (car (eldev-listify eldev-project-source-dirs))) "")) (defvar eldev--collect-autoloads-from ;; FIXME: Here we explicitly use only one (the first) source directory. Should that be diff --git a/test/autoloads.el b/test/autoloads.el index 8fc99d8..e1e8a07 100644 --- a/test/autoloads.el +++ b/test/autoloads.el @@ -64,11 +64,28 @@ (ert-deftest eldev-autoloads-6 () ;; This project has special source directories and activates `autoloads' plugin. (let ((eldev--test-project "project-l")) + (eldev--test-delete-cache) (eldev--test-run nil ("eval" "--dont-require" `(project-l-hello)) (should (string= stdout "\"Hello\"\n")) (should (= exit-code 0))) (eldev--test-run nil ("eval" "--dont-require" `(project-l-misc-hello)) (should (string= stdout "\"Hello\"\n")) + (should (= exit-code 0))) + ;; It's a dependency of the project, and also has autoloaded functions. + (eldev--test-run nil ("eval" "--dont-require" `(dependency-d-autoloaded) `(dependency-d-stable)) + (should (string= stdout (eldev--test-lines "\"Loaded automatically\"" "t"))) + (should (= exit-code 0))) + ;; Make sure this works also with local dependencies. + (eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-d") + "eval" "--dont-require" `(dependency-d-autoloaded) `(dependency-d-stable)) + (should (string= stdout (eldev--test-lines "\"Loaded automatically\"" "nil"))) + (should (= exit-code 0))))) + +(ert-deftest eldev-autoloads-7 () + ;; This dependency library has a special source directory and activates `autoloads' plugin. + (let ((eldev--test-project "dependency-d")) + (eldev--test-run nil ("eval" "--dont-require" `(dependency-d-autoloaded)) + (should (string= stdout "\"Loaded automatically\"\n")) (should (= exit-code 0))))) diff --git a/test/dependency-d/.gitignore b/test/dependency-d/.gitignore new file mode 100644 index 0000000..a2d4c93 --- /dev/null +++ b/test/dependency-d/.gitignore @@ -0,0 +1 @@ +/lisp/dependency-d-autoloads.el diff --git a/test/dependency-d/Eldev b/test/dependency-d/Eldev new file mode 100644 index 0000000..2defd29 --- /dev/null +++ b/test/dependency-d/Eldev @@ -0,0 +1,3 @@ +(setf eldev-project-source-dirs "lisp") + +(eldev-use-plugin 'autoloads) diff --git a/test/dependency-d/lisp/dependency-d.el b/test/dependency-d/lisp/dependency-d.el new file mode 100644 index 0000000..5a2fe5e --- /dev/null +++ b/test/dependency-d/lisp/dependency-d.el @@ -0,0 +1,17 @@ +;;; dependency-d.el --- Dependency test package D with a special source directory + +;; Version: 1.0.99 + +(defun dependency-d-hello () + "Hello") + +(defun dependency-d-stable () + nil) + +;;;###autoload +(defun dependency-d-autoloaded () + "Loaded automatically") + +(provide 'dependency-d) + +;;; dependency-d.el ends here diff --git a/test/local-dependencies.el b/test/local-dependencies.el index 6c2f119..a9a9411 100644 --- a/test/local-dependencies.el +++ b/test/local-dependencies.el @@ -50,6 +50,23 @@ (should (string= stdout (eldev--test-lines "t" "t" "(1 0)" "(1 0)"))) (should (= exit-code 0))))) +(ert-deftest eldev-local-dependencies-3 () + (let ((eldev--test-project "project-l")) + (eldev--test-delete-cache) + ;; `dependency-d' uses a source directory. Make sure it is handled correctly when it + ;; is loaded as a local. Explicitly requiring the dependency feature since the + ;; project doesn't do that for autoload testing. + (eldev--test-run nil ("--quiet" "eval" `(progn (require 'dependency-d) (dependency-d-stable)) `(package-desc-version (eldev-find-package-descriptor 'dependency-d))) + (should (string= stdout (eldev--test-lines "t" "(1 0)"))) + (should (= exit-code 0))) + (eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-d") + "eval" `(progn (require 'dependency-d) (dependency-d-stable)) `(package-desc-version (eldev-find-package-descriptor 'dependency-d))) + (should (string= stdout (eldev--test-lines "nil" "(1 0 99)"))) + (should (= exit-code 0))) + (eldev--test-run nil ("--quiet" "eval" `(progn (require 'dependency-d) (dependency-d-stable)) `(package-desc-version (eldev-find-package-descriptor 'dependency-d))) + (should (string= stdout (eldev--test-lines "t" "(1 0)"))) + (should (= exit-code 0))))) + (ert-deftest eldev-local-dependency-fixes-missing-dependency-1 () (eldev--test-run "dependency-a" ("clean") diff --git a/test/package-archive-a/archive-contents b/test/package-archive-a/archive-contents index 06f5ac8..4ce1371 100644 --- a/test/package-archive-a/archive-contents +++ b/test/package-archive-a/archive-contents @@ -1,6 +1,7 @@ (1 (dependency-a . [(1 0) nil "Dependency test package A" single nil]) (dependency-b . [(1 0) ((dependency-a (0))) "Dependency test package B" single nil]) + (dependency-d . [(1 0) nil "Dependency test package D with a special source directory" single nil]) (dummy-lint . [(1 0) nil "Dummy linter" single nil]) (misc-a . [(1 0) nil "Miscellaneous package A" single nil]) (project-i . [(1 0) nil "Test project with autoload cookies in multiple files" tar nil]) diff --git a/test/package-archive-a/dependency-d-1.0.el b/test/package-archive-a/dependency-d-1.0.el new file mode 100644 index 0000000..15b0439 --- /dev/null +++ b/test/package-archive-a/dependency-d-1.0.el @@ -0,0 +1,17 @@ +;;; dependency-d.el --- Dependency test package D with a special source directory + +;; Version: 1.0 + +(defun dependency-d-hello () + "Hello") + +(defun dependency-d-stable () + t) + +;;;###autoload +(defun dependency-d-autoloaded () + "Loaded automatically") + +(provide 'dependency-d) + +;;; dependency-d.el ends here diff --git a/test/project-l/src/project-l.el b/test/project-l/src/project-l.el index 772598f..f500c4a 100644 --- a/test/project-l/src/project-l.el +++ b/test/project-l/src/project-l.el @@ -1,7 +1,7 @@ ;;; project-l.el --- Test project where source code is contained in a subdirectory of project root; and with autoloads ;; Version: 1.0 -;; Package-Requires: ((dependency-a "0.1")) +;; Package-Requires: ((dependency-a "0.1") (dependency-d "1.0")) ;; Homepage: https://example.com/ ;;; Commentary: