Skip to content

Commit be713dd

Browse files
committed
Fix certain problems caused by --disable-dependencies in projects that use autoloads.
1 parent 92de7f9 commit be713dd

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

eldev-build.el

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ This function may only be called while inside the body of a
374374
;; When building, project loading mode is ignored. The reason is that building itself
375375
;; can involve compiling or packaging.
376376
(run-hooks 'eldev-build-system-hook)
377+
(unless eldev-normal-dependency-management
378+
(setf dont-touch-packages t))
377379
(unless dont-touch-packages
378380
(let ((eldev-project-loading-mode 'as-is))
379381
(when (memq 'test eldev-build-sets)

test/autoloads.el

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,29 @@
102102
(should (= exit-code 0)))))
103103

104104

105+
(ert-deftest eldev-autoloads-disabled-dependencies ()
106+
(let ((eldev--test-project "project-j"))
107+
(eldev--test-delete-cache)
108+
(eldev--test-run nil ("prepare")
109+
(should (= exit-code 0)))
110+
;; In real use, dependency `project-i' would be found from the project sources by
111+
;; whoever sets `EMACSLOADPATH'. Here we hardcode it to simplify things.
112+
(let ((process-environment `(,(eldev--test-emacsloadpath (eldev--test-project-dir) (eldev--test-project-dir "project-i"))
113+
,@process-environment)))
114+
;; This would work without `--disable-dependencies', as the function should be
115+
;; autoloaded. However, at least as of now, `--disable-dependencies' also disables
116+
;; autoload handling. Codify this in tests to be reminded if this somehow changes.
117+
;; `project-j' itself may or may not be loaded, depending on target `:autoloads'
118+
;; being rebuilt (see also `eldev--unload-package' which is _not_ called when using
119+
;; `--disable-dependencies'); so it fails either already on `project-j-hello', or
120+
;; else on `project-i-hello'.
121+
(eldev--test-run nil ("--disable-dependencies" "eval" "--dont-require" `(project-j-hello))
122+
(should (string-match-p "function definition is void.+project-[ij]-hello" stderr))
123+
(should (= exit-code 1)))
124+
;; Works only when requiring everything (`project-j' is autorequired by the command).
125+
(eldev--test-run nil ("--disable-dependencies" "eval" `(progn (require 'project-i) (project-j-hello)))
126+
(should (string= stdout "\"Hello\"\n"))
127+
(should (= exit-code 0))))))
128+
129+
105130
(provide 'test/autoloads)

test/common.el

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ beginning. Exit code of the process is bound as EXIT-CODE."
179179
,(format "ELDEV_DIR=%s" (eldev--test-eldev-dir))
180180
,@process-environment))
181181

182+
(defun eldev--test-emacsloadpath (&rest extras)
183+
(format "EMACSLOADPATH=%s" (mapconcat #'identity (append extras load-path) path-separator)))
184+
185+
182186
(defun eldev--test-force-bootstrapping-now ()
183187
(eldev-call-process eldev--test-shell-command nil :die-on-error t))
184188

test/test.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@
175175
(ert-deftest eldev-test-project-c-disabled-dependencies-2 ()
176176
;; Dependencies are disabled, but we supply `load-path', so testing should work.
177177
(let* ((eldev--test-project "project-c")
178-
(process-environment `(,(format "EMACSLOADPATH=%s"
179-
(mapconcat #'identity (append (list (eldev--test-project-dir) (eldev--test-project-dir "dependency-a")) load-path) path-separator))
178+
;; In real use, `dependency-a' would be found from the project sources by whoever
179+
;; sets `EMACSLOADPATH'. Here we hardcode it to simplify things.
180+
(process-environment `(,(eldev--test-emacsloadpath (eldev--test-project-dir) (eldev--test-project-dir "dependency-a"))
180181
,@process-environment)))
181182
(eldev--test-delete-cache)
182183
(eldev--test-run nil ("--disable-dependencies" "test")

0 commit comments

Comments
 (0)