From 3323caa4057ae0f91c9669142b040168e52835f6 Mon Sep 17 00:00:00 2001 From: Josh Bax Date: Thu, 3 Apr 2025 17:20:52 -0700 Subject: [PATCH 1/8] fix typos --- lisp/core/install-file.el | 2 +- lisp/core/install-vc.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/core/install-file.el b/lisp/core/install-file.el index f1846773..d7121535 100644 --- a/lisp/core/install-file.el +++ b/lisp/core/install-file.el @@ -52,7 +52,7 @@ ;; If package [files..] are specified, we try to install it (eask-install-file--packages files) ;; Otherwise, report error. - (eask-info "(No file packages have been intalled)") + (eask-info "(No file packages have been installed)") (eask-help "core/install-file"))) ;;; core/install-file.el ends here diff --git a/lisp/core/install-vc.el b/lisp/core/install-vc.el index 6d26519d..b514dc7a 100644 --- a/lisp/core/install-vc.el +++ b/lisp/core/install-vc.el @@ -67,7 +67,7 @@ ;; If package [specs..] are specified, we try to install it (eask-install-vc--packages specs) ;; Otherwise, report error. - (eask-info "(No vc packages have been intalled)") + (eask-info "(No vc packages have been installed)") (eask-help "core/install-vc"))) ;;; core/install-vc.el ends here From 0e66260754b63bef0cccb071d2da54ad17d8463e Mon Sep 17 00:00:00 2001 From: Josh Bax Date: Thu, 3 Apr 2025 17:27:51 -0700 Subject: [PATCH 2/8] Get actual package name --- lisp/core/install-file.el | 13 +++++++++---- lisp/core/install-vc.el | 7 +++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lisp/core/install-file.el b/lisp/core/install-file.el index d7121535..10c6de3f 100644 --- a/lisp/core/install-file.el +++ b/lisp/core/install-file.el @@ -22,14 +22,19 @@ (eask-load "core/install") -(defun eask-install-file--guess-name (file) - "Guess the package name of the install FILE." - (file-name-sans-extension (file-name-nondirectory (directory-file-name file)))) +(defun eask-install-file--get-package-name (path) + "Get the package name from PATH, which is a file, directory or archive." + (when (not (file-exists-p path)) + (eask-error "File does not exist %s" path)) + ;; Note package-dir-info doesn't work outside of dired mode! + (let ((pkg-desc (with-current-buffer (dired (expand-file-name path)) + (eask-ignore-errors-silent (package-dir-info))))) + (package-desc-name pkg-desc))) (defun eask-install-file--packages (files) "The file install packages with FILES." (let* ((deps (mapcar (lambda (file) - (list (eask-install-file--guess-name file) file)) + (list (eask-install-file--get-package-name file) file)) files)) (names (mapcar #'car deps)) (len (length deps)) diff --git a/lisp/core/install-vc.el b/lisp/core/install-vc.el index b514dc7a..7eb54ebf 100644 --- a/lisp/core/install-vc.el +++ b/lisp/core/install-vc.el @@ -21,7 +21,10 @@ nil t)) (eask-load "core/install") -(eask-load "core/install-file") + +(defun eask-install-vc--guess-name (file) + "Guess the package name of the install FILE." + (file-name-sans-extension (file-name-nondirectory (directory-file-name file)))) (defun eask-install-vc--split-sepcs (specs) "Split the SPECS and return a list of specification." @@ -32,7 +35,7 @@ (cond ((ffap-url-p spec) (push (reverse current-spec) new-specs) ;; We're using the push, so the order is reversed. - (setq current-spec (list spec (eask-install-file--guess-name spec)))) + (setq current-spec (list spec (eask-install-vc--guess-name spec)))) (t (push spec current-spec)))) ;; Push thes rest of the specification. From d93f29e4f3ae97587a4336712e9d013d7bc75eb3 Mon Sep 17 00:00:00 2001 From: Josh Bax Date: Thu, 3 Apr 2025 18:02:35 -0700 Subject: [PATCH 3/8] Need to ignore unhelpful package.el errors --- lisp/_prepare.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/_prepare.el b/lisp/_prepare.el index e73ffb00..d76a2cee 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -733,7 +733,7 @@ Argument BODY are forms for execution." ;; Handle `--force` flag. (when should-reinstall-p (package-delete (eask-package-desc pkg t) t)) ;; Install it. - (package-install-file (expand-file-name file))) + (eask-ignore-errors (package-install-file (expand-file-name file)))) "done ✓"))))) (defun eask-package-install (pkg) From badae0e92fd1892ecd52d65392be40ab8ddf80e6 Mon Sep 17 00:00:00 2001 From: Josh Bax Date: Thu, 3 Apr 2025 18:15:57 -0700 Subject: [PATCH 4/8] Add more tests for install-file --- test/jest/install.test.js | 44 ++++++++++++++++++++++++--- test/jest/install/foo-mode/Eask | 14 +++++++++ test/jest/install/foo-mode/foo-pkg.el | 2 ++ test/jest/install/foo-mode/foo.el | 38 +++++++++++++++++++++++ test/jest/install/foo-no-pkg/Eask | 14 +++++++++ test/jest/install/foo-no-pkg/foo.el | 38 +++++++++++++++++++++++ 6 files changed, 145 insertions(+), 5 deletions(-) create mode 100644 test/jest/install/foo-mode/Eask create mode 100644 test/jest/install/foo-mode/foo-pkg.el create mode 100644 test/jest/install/foo-mode/foo.el create mode 100644 test/jest/install/foo-no-pkg/Eask create mode 100644 test/jest/install/foo-no-pkg/foo.el diff --git a/test/jest/install.test.js b/test/jest/install.test.js index ea2f2849..ee20290c 100644 --- a/test/jest/install.test.js +++ b/test/jest/install.test.js @@ -53,11 +53,6 @@ describe("install and uninstall", () => { expect(stderr).not.toMatch(packageName); }); - it("installs file directly", async () => { - const { stderr } = await ctx.runEask("install-file ./mini.pkg.2"); - expect(stderr).toMatch("mini.pkg.2"); - }); - test.skip("installs vc directly", async () => { if ((await emacsVersion()) >= "29.1") { const { stderr } = await ctx.runEask( @@ -66,6 +61,45 @@ describe("install and uninstall", () => { expect(stderr).toMatch("msgu"); } }); + + describe("eask install-file", () => { + beforeAll(async () => { + await ctx.runEask("clean workspace"); + }); + + it("installs file directly", async () => { + const { stderr } = await ctx.runEask("install-file ./mini.pkg.2"); + expect(stderr).toMatch("mini.pkg.2"); + }); + + it("uses the correct package name", async () => { + const { stderr } = await ctx.runEask("install-file ./foo-mode"); + expect(stderr).toMatch("Installing foo"); + }); + + it("can repeat installs", async () => { + await ctx.runEask("install-file ./foo-mode"); + }); + + it("reinstalls a package using --force", async () => { + const { stderr } = await ctx.runEask("install-file --force ./foo-mode"); + expect(stderr).toMatch("Reinstalling foo"); + }); + + it("installs a package with only an Eask file", async () => { + await ctx.runEask("install-file ./foo-no-pkg"); + }); + + it("errors when path is non-existing", async () => { + await expect(ctx.runEask("install-file ./foo")).rejects.toThrow(); + }); + + it("errors when path is an empty directory", async () => { + await expect(ctx.runEask("install-file ../empty")).rejects.toThrow(); + }); + + // it("gets the package name from a tar file", () => {}); + }); }); describe("in an empty project", () => { diff --git a/test/jest/install/foo-mode/Eask b/test/jest/install/foo-mode/Eask new file mode 100644 index 00000000..dc2bc1d3 --- /dev/null +++ b/test/jest/install/foo-mode/Eask @@ -0,0 +1,14 @@ +(package "foo" + "0.0.1" + "") + +(website-url "") +(keywords ) + +(package-file "foo.el") + +(script "test" "echo \"Error: no test specified\" && exit 1") + +(source "gnu") + +(depends-on "emacs" "26.1") diff --git a/test/jest/install/foo-mode/foo-pkg.el b/test/jest/install/foo-mode/foo-pkg.el new file mode 100644 index 00000000..c7b3b1da --- /dev/null +++ b/test/jest/install/foo-mode/foo-pkg.el @@ -0,0 +1,2 @@ +;;; Generated package description from foo.el -*- no-byte-compile: t -*- +(define-package "foo" "0.0.1" "foo" '((emacs "0")) :keywords '("test")) diff --git a/test/jest/install/foo-mode/foo.el b/test/jest/install/foo-mode/foo.el new file mode 100644 index 00000000..b9cafe63 --- /dev/null +++ b/test/jest/install/foo-mode/foo.el @@ -0,0 +1,38 @@ +;;; foo.el --- foo -*- lexical-binding: t -*- + +;; Author: none +;; Maintainer: none +;; Version: 0.0.1 +;; Package-Requires: (emacs) +;; Keywords: test + + +;; This file is not part of GNU Emacs + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + + +;;; Commentary: + +;; commentary + +;;; Code: + +(defun foo-message () + "docstring" + (interactive "P") + (message "Hello World!")) + +(provide 'foo) +;;; foo.el ends here diff --git a/test/jest/install/foo-no-pkg/Eask b/test/jest/install/foo-no-pkg/Eask new file mode 100644 index 00000000..dc2bc1d3 --- /dev/null +++ b/test/jest/install/foo-no-pkg/Eask @@ -0,0 +1,14 @@ +(package "foo" + "0.0.1" + "") + +(website-url "") +(keywords ) + +(package-file "foo.el") + +(script "test" "echo \"Error: no test specified\" && exit 1") + +(source "gnu") + +(depends-on "emacs" "26.1") diff --git a/test/jest/install/foo-no-pkg/foo.el b/test/jest/install/foo-no-pkg/foo.el new file mode 100644 index 00000000..b9cafe63 --- /dev/null +++ b/test/jest/install/foo-no-pkg/foo.el @@ -0,0 +1,38 @@ +;;; foo.el --- foo -*- lexical-binding: t -*- + +;; Author: none +;; Maintainer: none +;; Version: 0.0.1 +;; Package-Requires: (emacs) +;; Keywords: test + + +;; This file is not part of GNU Emacs + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + + +;;; Commentary: + +;; commentary + +;;; Code: + +(defun foo-message () + "docstring" + (interactive "P") + (message "Hello World!")) + +(provide 'foo) +;;; foo.el ends here From 2018d9597488d182043eb7189040dd00382a0b3a Mon Sep 17 00:00:00 2001 From: Josh Bax Date: Thu, 3 Apr 2025 18:16:07 -0700 Subject: [PATCH 5/8] Should error if install-file FILE is not a package --- lisp/core/install-file.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/core/install-file.el b/lisp/core/install-file.el index 10c6de3f..d5284679 100644 --- a/lisp/core/install-file.el +++ b/lisp/core/install-file.el @@ -29,6 +29,9 @@ ;; Note package-dir-info doesn't work outside of dired mode! (let ((pkg-desc (with-current-buffer (dired (expand-file-name path)) (eask-ignore-errors-silent (package-dir-info))))) + (unless pkg-desc + ;; package-dir-info will return nil if there is no -pkg.el and no .el files at path + (eask-error "No package in %s" path)) (package-desc-name pkg-desc))) (defun eask-install-file--packages (files) From f33f4c86f7eed724d960a11799721c4047f12eb4 Mon Sep 17 00:00:00 2001 From: Josh Bax Date: Thu, 3 Apr 2025 19:11:49 -0700 Subject: [PATCH 6/8] Correctly handle tar files --- lisp/core/install-file.el | 33 +++++++++++++++++++++++++-------- test/jest/install.test.js | 9 ++++++++- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lisp/core/install-file.el b/lisp/core/install-file.el index d5284679..66b5c2f8 100644 --- a/lisp/core/install-file.el +++ b/lisp/core/install-file.el @@ -24,15 +24,32 @@ (defun eask-install-file--get-package-name (path) "Get the package name from PATH, which is a file, directory or archive." - (when (not (file-exists-p path)) + (cond + ((not (file-exists-p path)) (eask-error "File does not exist %s" path)) - ;; Note package-dir-info doesn't work outside of dired mode! - (let ((pkg-desc (with-current-buffer (dired (expand-file-name path)) - (eask-ignore-errors-silent (package-dir-info))))) - (unless pkg-desc - ;; package-dir-info will return nil if there is no -pkg.el and no .el files at path - (eask-error "No package in %s" path)) - (package-desc-name pkg-desc))) + ((or (string-suffix-p ".tar" path) + (string-suffix-p ".tar.gz" path)) + ;; tar file + ;; Note this can throw strange errors if + ;; - there is no -pkg.el in the tar file + ;; - the tar file was built in a folder with a different name + ;; tar files created with eask package are fine + (require 'tar-mode) + (let ((pkg-desc (with-current-buffer (find-file (expand-file-name path)) + (eask-ignore-errors-silent (package-tar-file-info))))) + (unless pkg-desc + ;; package-dir-info will return nil if there is no -pkg.el and no .el files at path + (eask-error "No package in %s" path)) + (package-desc-name pkg-desc)) + ) + (t ;; .el file or directory + ;; Note package-dir-info doesn't work outside of dired mode! + (let ((pkg-desc (with-current-buffer (dired (expand-file-name path)) + (eask-ignore-errors-silent (package-dir-info))))) + (unless pkg-desc + ;; package-dir-info will return nil if there is no -pkg.el and no .el files at path + (eask-error "No package in %s" path)) + (package-desc-name pkg-desc))))) (defun eask-install-file--packages (files) "The file install packages with FILES." diff --git a/test/jest/install.test.js b/test/jest/install.test.js index ee20290c..09b81877 100644 --- a/test/jest/install.test.js +++ b/test/jest/install.test.js @@ -98,7 +98,14 @@ describe("install and uninstall", () => { await expect(ctx.runEask("install-file ../empty")).rejects.toThrow(); }); - // it("gets the package name from a tar file", () => {}); + it("gets the package name from a tar file", async () => { + await ctx.runEask("install-file ./foo.tar.gz"); + }); + + it("can install tar files created with eask package", async () => { + // foo-0.0.1.tar is created by running eask package in ./foo-no-pkg + await ctx.runEask("install-file ./foo-0.0.1.tar"); + }); }); }); From 0f6ee7077990a12fe8c2d630b4a5f4d4ad2ad9b2 Mon Sep 17 00:00:00 2001 From: Josh Bax Date: Thu, 3 Apr 2025 19:57:28 -0700 Subject: [PATCH 7/8] Add missing test files --- test/jest/install/foo-0.0.1.tar | Bin 0 -> 10240 bytes test/jest/install/foo.tar.gz | Bin 0 -> 1059 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/jest/install/foo-0.0.1.tar create mode 100644 test/jest/install/foo.tar.gz diff --git a/test/jest/install/foo-0.0.1.tar b/test/jest/install/foo-0.0.1.tar new file mode 100644 index 0000000000000000000000000000000000000000..706360692c5f5a2d75d145b26543d9075019c9e4 GIT binary patch literal 10240 zcmeHIZEqSm5au(#Vs5{boU**9NN_rdi$a5%CJ0EQd^EeWV8z&bwin93@5};il2)x+ zHK&v6l~(JW8IPZN=Ea#YakJj6w;Gifdz$q0&dw_QrRVv#l(o9OUgveE*Y2^t*Y36| zaQ0$|9yuJ6}*{A&TDt}nkQT^)pIl-^H-RF5f{x{prPUT7dTdh{RS%Lo~ zC%<|A2Lp)zj6s`tvGW)wW}QogeeeTN_(3K@#S5uZsh54wQn7KhmSQF~#<@ry#1bK* z(up7{$4FEKh(^ZLdGV@N!?j2p>7tVp67(N%w>36(q>4N`&*EQQZo%IVFz}@RU!eCH z%6Iy|P4oU)|2I3`v(W!Pkj9@j9nb)v8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on Sep 17 00:00:00 2001 From: Josh Bax Date: Thu, 3 Apr 2025 20:04:28 -0700 Subject: [PATCH 8/8] Match only package name in test to avoid control chars --- test/jest/install.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jest/install.test.js b/test/jest/install.test.js index 09b81877..e9dc3450 100644 --- a/test/jest/install.test.js +++ b/test/jest/install.test.js @@ -74,7 +74,7 @@ describe("install and uninstall", () => { it("uses the correct package name", async () => { const { stderr } = await ctx.runEask("install-file ./foo-mode"); - expect(stderr).toMatch("Installing foo"); + expect(stderr).toMatch("foo"); }); it("can repeat installs", async () => { @@ -83,7 +83,7 @@ describe("install and uninstall", () => { it("reinstalls a package using --force", async () => { const { stderr } = await ctx.runEask("install-file --force ./foo-mode"); - expect(stderr).toMatch("Reinstalling foo"); + expect(stderr).toMatch("foo"); }); it("installs a package with only an Eask file", async () => {