Skip to content

Commit

Permalink
Rename eldev-use-local-dependency to eldev-use-local-sources; use…
Browse files Browse the repository at this point in the history
… the old name as an obsolete alias, to retain compatibility.
  • Loading branch information
doublep committed Dec 10, 2024
1 parent 59030e9 commit dd2a4bf
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 114 deletions.
7 changes: 3 additions & 4 deletions eldev-plugins.el
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ the file is up-to-date.
It is recommended to instruct your VCS to ignore file
`PROJECT-autoloads.el', as it will be autogenerated.
When using a project with this plugin as a local dependency,
specify loading mode `built' (or `built-and-compiled',
`built-source'):
When using a project with this plugin as local sources, specify
loading mode `built' (or `built-and-compiled', `built-source'):
(eldev-use-local-dependency \"...\" 'built)
(eldev-use-local-sources \"...\" 'built)
Otherwise, autoloads file for the dependency may become
out-of-date."
Expand Down
6 changes: 3 additions & 3 deletions eldev-vc.el
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ Since 1.2."
package)))

(defun eldev--vc-install-as-package (repository)
;; Unlike with local dependencies, for VC-fetched we generate and install Emacs package
;; here rather than when loading. The reason is that the source checkout is controlled
;; by Eldev and thus shouldn't outside.
;; Unlike with local sources, for VC-fetched projects we generate and install Emacs
;; packages here rather than when loading. The reason is that the source checkout is
;; controlled by Eldev and thus shouldn't ever be changed outside.
(let ((tmp-package-dir (make-temp-file "eldev-vc-" t))
(package (cdr (assq (car repository) eldev--vc-repository-packages))))
(eldev-verbose "Creating a package from `%s'" (eldev--vc-repository-name repository))
Expand Down
133 changes: 71 additions & 62 deletions eldev.el

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions test/README
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ org-pseudoarchive/
dependency-*/

Test "projects" also available from the local test archives above.
Used to test local dependencies.
Used to test local sources.

missing-dependency-*/

Projects that don't provide a way to look up at least one
dependency. Can only be repaired using local dependencies. Used
to test that certain Eldev commands work anyway.
dependency. Can only be repaired using local sources. Used to
test that certain Eldev commands work anyway.

*/

Expand Down
18 changes: 9 additions & 9 deletions test/autoloads.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@
(should (= exit-code 0)))))

(ert-deftest eldev-autoloads-3 ()
;; Test that when using local dependencies for `project-i', its autoloads are still
;; Test that when using local sources for `project-i', its autoloads are still
;; available.
(let ((eldev--test-project "project-j"))
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../project-i") "eval" `(project-j-hello))
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../project-i") "eval" `(project-j-hello))
(should (string= stdout "\"Hello\"\n"))
(should (= exit-code 0)))
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../project-i") "eval" `(project-j-hello-to "world"))
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../project-i") "eval" `(project-j-hello-to "world"))
(should (string= stdout "\"Hello, world!\"\n"))
(should (= exit-code 0)))))

(ert-deftest eldev-autoloads-4 ()
;; Like the previous test, only with a different loading mode.
(let ((eldev--test-project "project-j"))
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../project-i" 'packaged) "eval" `(project-j-hello))
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../project-i" 'packaged) "eval" `(project-j-hello))
(should (string= stdout "\"Hello\"\n"))
(should (= exit-code 0)))
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../project-i" 'packaged) "eval" `(project-j-hello-to "world"))
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../project-i" 'packaged) "eval" `(project-j-hello-to "world"))
(should (string= stdout "\"Hello, world!\"\n"))
(should (= exit-code 0)))))

(ert-deftest eldev-autoloads-5 ()
;; Test that when `project-j' is used as a local dependency, its autoloads file is still
;; Test that when `project-j' is loaded from local sources, its autoloads file is still
;; generated automatically.
(dolist (loading-mode '(as-is source byte-compiled))
(let ((eldev--test-project "project-j"))
Expand All @@ -56,7 +56,7 @@
(let ((eldev--test-project "project-a"))
(eldev--test-delete-cache)
(eldev--test-run nil ("--setup" `(eldev-add-extra-dependencies 'eval 'project-j)
"--setup" `(eldev-use-local-dependency "../project-j" ',loading-mode)
"--setup" `(eldev-use-local-sources "../project-j" ',loading-mode)
"eval" `(project-j-hello))
(should (string= stdout "\"Hello\"\n"))
(should (= exit-code 0))))))
Expand All @@ -75,8 +75,8 @@
(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")
;; Make sure this works also with local sources.
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../dependency-d")
"eval" "--dont-require" `(dependency-d-autoloaded) `(dependency-d-stable))
(should (string= stdout (eldev--test-lines "\"Loaded automatically\"" "nil")))
(should (= exit-code 0)))))
Expand Down
8 changes: 4 additions & 4 deletions test/integration/elisp-lint.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

;; https://github.com/emacs-eldev/eldev/issues/19
;;
;; `package-lint' (called by by `elisp-lint') would deem local dependencies uninstallable
;; if they were not available from "normal" archives.
(ert-deftest eldev-elisp-lint-local-dependencies-1 ()
;; `package-lint' (called by by `elisp-lint') would deem local-sourced packages
;; uninstallable if they were not available from "normal" archives.
(ert-deftest eldev-elisp-lint-local-sources-1 ()
(let ((eldev--test-project "missing-dependency-a"))
(eldev--test-without-files nil ("missing-dependency-a-autoloads.el" "missing-dependency-a-autoloads.el~")
(eldev--test-delete-cache)
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-a")
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../dependency-a")
"lint" "el" "--required")
(eldev--test-skip-if-missing-linter exit-code stderr)
(should (= exit-code 0))))))
Expand Down
8 changes: 4 additions & 4 deletions test/integration/package-lint.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@

;; https://github.com/emacs-eldev/eldev/issues/19
;;
;; `package-lint' would deem local dependencies uninstallable if they were not available
;; from "normal" archives.
(ert-deftest eldev-package-lint-local-dependencies-1 ()
;; `package-lint' would deem local-sourced packages uninstallable if they were not
;; available from "normal" archives.
(ert-deftest eldev-package-lint-local-sources-1 ()
(let ((eldev--test-project "missing-dependency-a"))
(eldev--test-delete-cache)
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-a")
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../dependency-a")
"lint" "package" "--required")
(eldev--test-skip-if-missing-linter exit-code stderr)
(should (= exit-code 0)))))
Expand Down
40 changes: 21 additions & 19 deletions test/local-dependencies.el → test/local-sources.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
(require 'test/common)


(ert-deftest eldev-local-dependencies-1 ()
(ert-deftest eldev-local-sources-1 ()
(let ((eldev--test-project "project-a"))
(eldev--test-delete-cache)
;; Run all commands in the same test to make sure that the various
;; setups don't influence each other in some way.
(eldev--test-run nil ("--quiet" "eval" `(dependency-a-stable) `(package-desc-version (eldev-find-package-descriptor 'dependency-a)))
(should (string= stdout (eldev--test-lines "t" "(1 0)")))
(should (= exit-code 0)))
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-a")
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../dependency-a")
"eval" `(dependency-a-stable) `(package-desc-version (eldev-find-package-descriptor 'dependency-a)))
(should (string= stdout (eldev--test-lines "nil" "(1 0 99)")))
(should (= exit-code 0)))
(eldev--test-run nil ("eval" `(dependency-a-stable) `(package-desc-version (eldev-find-package-descriptor 'dependency-a)))
(should (string= stdout (eldev--test-lines "t" "(1 0)")))
(should (= exit-code 0)))))

(ert-deftest eldev-local-dependencies-2 ()
(ert-deftest eldev-local-sources-2 ()
(let ((eldev--test-project "project-b"))
(eldev--test-delete-cache)
;; Similar to the previous test. Now we have two dependencies, A
Expand All @@ -30,17 +30,18 @@
`(package-desc-version (eldev-find-package-descriptor 'dependency-a)) `(package-desc-version (eldev-find-package-descriptor 'dependency-b)))
(should (string= stdout (eldev--test-lines "t" "t" "(1 0)" "(1 0)")))
(should (= exit-code 0)))
;; Intentionally using obsolete function alias here, don't change.
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-a")
"eval" `(dependency-a-stable) `(dependency-b-stable)
`(package-desc-version (eldev-find-package-descriptor 'dependency-a)) `(package-desc-version (eldev-find-package-descriptor 'dependency-b)))
(should (string= stdout (eldev--test-lines "nil" "t" "(1 0 99)" "(1 0)")))
(should (= exit-code 0)))
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-b")
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../dependency-b")
"eval" `(dependency-a-stable) `(dependency-b-stable)
`(package-desc-version (eldev-find-package-descriptor 'dependency-a)) `(package-desc-version (eldev-find-package-descriptor 'dependency-b)))
(should (string= stdout (eldev--test-lines "t" "nil" "(1 0)" "(1 0 99)")))
(should (= exit-code 0)))
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-a") "--setup" `(eldev-use-local-dependency "../dependency-b")
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../dependency-a") "--setup" `(eldev-use-local-sources "../dependency-b")
"eval" `(dependency-a-stable) `(dependency-b-stable)
`(package-desc-version (eldev-find-package-descriptor 'dependency-a)) `(package-desc-version (eldev-find-package-descriptor 'dependency-b)))
(should (string= stdout (eldev--test-lines "nil" "nil" "(1 0 99)" "(1 0 99)")))
Expand All @@ -50,7 +51,7 @@
(should (string= stdout (eldev--test-lines "t" "t" "(1 0)" "(1 0)")))
(should (= exit-code 0)))))

(ert-deftest eldev-local-dependencies-3 ()
(ert-deftest eldev-local-sources-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
Expand All @@ -59,7 +60,7 @@
(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")
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../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)))
Expand All @@ -68,7 +69,7 @@
(should (= exit-code 0)))))


(ert-deftest eldev-local-dependency-fixes-missing-dependency-1 ()
(ert-deftest eldev-local-sources-fix-missing-dependency-1 ()
(eldev--test-run "dependency-a" ("clean")
(should (= exit-code 0)))
(let ((eldev--test-project "missing-dependency-a"))
Expand All @@ -79,13 +80,14 @@
(should (= exit-code 1)))
;; In `as-is' (default) loading mode `byte-code-function-p's
;; result should depend on the state of the dependency.
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-a")
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../dependency-a")
"eval" `(dependency-a-stable) `(byte-code-function-p (symbol-function 'dependency-a-stable))
`(package-desc-version (eldev-find-package-descriptor 'dependency-a)))
(should (string= stdout (eldev--test-lines "nil" "nil" "(1 0 99)")))
(should (= exit-code 0)))
(eldev--test-run "dependency-a" ("compile")
(should (= exit-code 0)))
;; Intentionally using obsolete function alias here, don't change.
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-a")
"eval" `(dependency-a-stable) `(byte-code-function-p (symbol-function 'dependency-a-stable))
`(package-desc-version (eldev-find-package-descriptor 'dependency-a)))
Expand All @@ -96,7 +98,7 @@
(should (string= stdout ""))
(should (= exit-code 1)))))

(eldev-ert-defargtest eldev-local-dependency-fixes-missing-dependency-2 (display-stdout)
(eldev-ert-defargtest eldev-local-sources-fix-missing-dependency-2 (display-stdout)
(nil t)
(eldev--test-run "dependency-a" ("clean")
(should (= exit-code 0)))
Expand All @@ -108,7 +110,7 @@
(should (= exit-code 1)))
;; In `byte-compiled' loading mode `byte-code-function-p' must
;; always return t, i.e. dependency must be compiled implicitly.
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-a" 'byte-compiled)
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../dependency-a" 'byte-compiled)
"--setup" `(setf eldev-display-indirect-build-stdout ,display-stdout)
"eval" `(dependency-a-stable) `(byte-code-function-p (symbol-function 'dependency-a-stable))
`(package-desc-version (eldev-find-package-descriptor 'dependency-a)))
Expand All @@ -119,7 +121,7 @@
(should (string= stdout ""))
(should (= exit-code 1)))))

(eldev-ert-defargtest eldev-local-dependency-fixes-missing-dependency-3 (display-stdout)
(eldev-ert-defargtest eldev-local-sources-fix-missing-dependency-3 (display-stdout)
(nil t)
(eldev--test-run "dependency-a" ("compile")
(should (= exit-code 0)))
Expand All @@ -132,7 +134,7 @@
;; In `source' loading mode `byte-code-function-p' must always
;; return nil, i.e. dependency must be cleaned even if compiled
;; before.
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-a" 'source)
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../dependency-a" 'source)
"--setup" `(setf eldev-display-indirect-build-stdout ,display-stdout)
"eval" `(dependency-a-stable) `(byte-code-function-p (symbol-function 'dependency-a-stable))
`(package-desc-version (eldev-find-package-descriptor 'dependency-a)))
Expand All @@ -143,7 +145,7 @@
(should (string= stdout ""))
(should (= exit-code 1)))))

(eldev-ert-defargtest eldev-local-dependency-fixes-missing-dependency-4 (display-stdout)
(eldev-ert-defargtest eldev-local-sources-fix-missing-dependency-4 (display-stdout)
(nil t)
(eldev--test-run "dependency-a" ("clean")
(should (= exit-code 0)))
Expand All @@ -156,7 +158,7 @@
;; In `packaged' loading mode `byte-code-function-p' must always
;; return t, i.e. dependency must be compiled when installed as a
;; package. FIXME: Probably could use a better check.
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-a" 'packaged)
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../dependency-a" 'packaged)
"--setup" `(setf eldev-display-indirect-build-stdout ,display-stdout)
"eval" `(dependency-a-stable) `(byte-code-function-p (symbol-function 'dependency-a-stable))
`(package-desc-version (eldev-find-package-descriptor 'dependency-a)))
Expand All @@ -168,16 +170,16 @@
(should (= exit-code 1)))))


;; Make sure that local dependencies are still honored even when an external directory is
;; Make sure that local sources are still honored even when an external directory is
;; specified.
(ert-deftest eldev-local-dependencies-overwrite-external-dir-1 ()
(ert-deftest eldev-local-sources-overwrite-external-dir-1 ()
(eldev--test-with-external-dir "project-a" 'dependency-a
(eldev--test-delete-cache)
(eldev--test-run nil ((format "--external=%s" external-dir)
"eval" `(dependency-a-stable) `(package-desc-version (eldev-find-package-descriptor 'dependency-a)))
(should (string= stdout (eldev--test-lines "t" "(1 0)")))
(should (= exit-code 0)))
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../dependency-a") (format "--external=%s" external-dir)
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../dependency-a") (format "--external=%s" external-dir)
"eval" `(dependency-a-stable) `(package-desc-version (eldev-find-package-descriptor 'dependency-a)))
(should (string= stdout (eldev--test-lines "nil" "(1 0 99)")))
(should (= exit-code 0)))
Expand All @@ -187,4 +189,4 @@
(should (= exit-code 0)))))


(provide 'test/local-dependencies)
(provide 'test/local-sources)
6 changes: 3 additions & 3 deletions test/misc.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
;; often report dependencies as required by wrong packages, if they were required by
;; several, but in different versions.
(ert-deftest eldev-issue-29 ()
(eldev--test-run "issue-29-project" ("--setup" `(eldev-use-local-dependency "../issue-29-insane-dependency") "prepare")
(eldev--test-run "issue-29-project" ("--setup" `(eldev-use-local-sources "../issue-29-insane-dependency") "prepare")
(should (string-match-p "issue-29-insane-dependency" stderr))
(should (= exit-code 1))))

Expand Down Expand Up @@ -49,8 +49,8 @@
(eldev--test-run nil ("eval" `(progn (require 'org) (bound-and-true-p org-is-fake)))
(should (string= stdout "nil\n"))
(should (= exit-code 0)))
;; Must load the local dependency if requested, even if Org is a built-in.
(eldev--test-run nil ("--setup" `(eldev-use-local-dependency "../project-fake-org")
;; Must load the local-sourced dependency package if requested, even if Org is a built-in.
(eldev--test-run nil ("--setup" `(eldev-use-local-sources "../project-fake-org")
"eval" `(progn (require 'org) (bound-and-true-p org-is-fake)))
(should (string= stdout "t\n"))
(should (= exit-code 0)))))
Expand Down
6 changes: 3 additions & 3 deletions test/vc-repositories.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
`(eldev-use-vc-repository 'dependency-a :git ,dependency-a-dir))
"eval" `(dependency-a-hello) `(dependency-a-stable) `(package-desc-version (eldev-find-package-descriptor 'dependency-a)))
:description (if from-pa "Using package archive to resolve `dependency-a'" "Using Git repository to resolve `dependency-a'")
;; Unlike with local dependencies, exchanging archives must not affect installed
;; packages: they will remain untouched until you issue `upgrade' or `clean
;; ...'. So, the expected output is determined by the first run.
;; Unlike with local package sources, exchanging archives must not affect
;; installed packages: they will remain untouched until you issue `upgrade' or
;; `clean ...'. So, the expected output is determined by the first run.
(should (string= (nth 0 (eldev--test-line-list stdout)) "\"Hello\""))
(should (string= (nth 1 (eldev--test-line-list stdout)) (if from-pa-first "t" "nil")))
(if from-pa-first
Expand Down

0 comments on commit dd2a4bf

Please sign in to comment.