diff --git a/pkgs/applications/editors/emacs/build-support/wrapper-test/with-packages.el b/pkgs/applications/editors/emacs/build-support/wrapper-test/with-packages.el index 50715f7e5d27..30735966656d 100644 --- a/pkgs/applications/editors/emacs/build-support/wrapper-test/with-packages.el +++ b/pkgs/applications/editors/emacs/build-support/wrapper-test/with-packages.el @@ -9,25 +9,7 @@ ;; Try to make tests cause no side-effects. -;;;; Tests that can be run in a batch Emacs - -(ert-deftest with-packages-requested-packages-are-available () - (should (package-installed-p 'dash)) - (should (package-installed-p 'flx-ido))) - -(ert-deftest with-packages-deps-of-requested-packages-are-available () - "Test https://github.com/NixOS/nixpkgs/issues/388829." - (should (package-installed-p 'flx)) - (should (package-installed-p 'flx-ido))) - -(ert-deftest with-packages-info-manual-of-requested-packages-is-available () - "Test https://debbugs.gnu.org/cgi/bugreport.cgi?bug=81105." - ;; `package-activate-all' makes package info manuals available. - ;; It is called at startup normally, but not in batch mode. - ;; We call it if needed to emulate the "normal" case. - (unless package--activated - (package-activate-all)) - (should (Info-find-file "dash" t))) +;;;; Utils (defun with-packages--nix-store-dir () "Return nix store dir. @@ -56,6 +38,36 @@ which is generated by nix when building this elisp package." "Locate the natively-compiled LIBRARY file." (locate-eln-file (comp-el-to-eln-rel-filename (find-library-name library)))) +(defun with-packages-unwrapped-site-start-is-loaded () + (fboundp 'nix--profile-paths)) + +(defun with-packages-eval-in-sub-emacs (form) + "Evaluate FORM in a subprocess Emacs and return its result." + (pcase-exhaustive + (process-lines "emacs" "--batch" + "--eval" (format "(prin1 %S)" form)) + (`(,result) (read result)))) + +;;;; Tests that can be run in a batch Emacs + +(ert-deftest with-packages-requested-packages-are-available () + (should (package-installed-p 'dash)) + (should (package-installed-p 'flx-ido))) + +(ert-deftest with-packages-deps-of-requested-packages-are-available () + "Test https://github.com/NixOS/nixpkgs/issues/388829." + (should (package-installed-p 'flx)) + (should (package-installed-p 'flx-ido))) + +(ert-deftest with-packages-info-manual-of-requested-packages-is-available () + "Test https://debbugs.gnu.org/cgi/bugreport.cgi?bug=81105." + ;; `package-activate-all' makes package info manuals available. + ;; It is called at startup normally, but not in batch mode. + ;; We call it if needed to emulate the "normal" case. + (unless package--activated + (package-activate-all)) + (should (Info-find-file "dash" t))) + (ert-deftest with-packages-aot-native-comp-eln-files-are-available () (skip-unless (native-comp-available-p)) (ert-info ("search eln files of Emacs proper") @@ -63,14 +75,27 @@ which is generated by nix when building this elisp package." (ert-info ("search eln files of requested packages") (should (with-packages--nix-store-file-p (with-packages--locate-eln-file "dash"))))) -(defun with-packages-unwrapped-site-start-is-loaded () - (fboundp 'nix--profile-paths)) - (ert-deftest with-packages-unwrapped-site-start-is-loaded () (should (with-packages-unwrapped-site-start-is-loaded))) -(ert-deftest with-packages-bin-dirs-of-requested-packages-are-added-to-exec-path () - (should (executable-find "cowsay"))) +(ert-deftest with-packages-binaries-of-requested-packages-are-available () + (ert-info ("find binary via PATH") + (should (equal (call-process-shell-command "cowsay") 0))) + (ert-info ("find binary via exec-path") + (should (executable-find "cowsay"))) + (ert-info ("each item is unique") + (cl-flet ((item-should-be-unique (items) + (should (equal items + (cl-remove-duplicates items :test #'string=))))) + (ert-info ("PATH of this Emacs") + (item-should-be-unique (parse-colon-path (getenv "PATH")))) + (ert-info ("PATH of sub-Emacs") + (item-should-be-unique + (parse-colon-path (with-packages-eval-in-sub-emacs '(getenv "PATH"))))) + (ert-info ("exec-path of this Emacs") + (item-should-be-unique exec-path)) + (ert-info ("exec-path of sub-Emacs") + (item-should-be-unique (with-packages-eval-in-sub-emacs 'exec-path)))))) (ert-deftest with-packages-tree-sitter-dir-is-added-to-treesit-extra-load-path () (skip-unless (treesit-available-p)) diff --git a/pkgs/applications/editors/emacs/build-support/wrapper.nix b/pkgs/applications/editors/emacs/build-support/wrapper.nix index 051e5923d6b0..1f9fbb240c5a 100644 --- a/pkgs/applications/editors/emacs/build-support/wrapper.nix +++ b/pkgs/applications/editors/emacs/build-support/wrapper.nix @@ -171,16 +171,6 @@ runCommand (lib.appendToName "with-packages" emacs).name cat >"$siteStart" <