From 97e4b30756871fe7e32fad7db750db61578667fc Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 16:40:07 +0800 Subject: [PATCH 01/13] feat: Report exit status globally --- lisp/_prepare.el | 28 +++++++++++++++++++++++++--- lisp/lint/elint.el | 10 +--------- lisp/lint/elsa.el | 11 +---------- lisp/lint/package.el | 10 +--------- lisp/lint/regexps.el | 10 +--------- 5 files changed, 29 insertions(+), 40 deletions(-) diff --git a/lisp/_prepare.el b/lisp/_prepare.el index a929a421..ffd99226 100644 --- a/lisp/_prepare.el +++ b/lisp/_prepare.el @@ -1432,7 +1432,29 @@ This uses function `locate-dominating-file' to look up directory tree." (ignore-errors (make-directory package-user-dir t)) (eask--silent (eask-setup-paths)) (eask-with-verbosity 'debug (eask--load-config)) - (eask--with-hooks ,@body)))))))))) + (eask--with-hooks ,@body)))))) + ;; Report exit stats if any. + (eask--handle-exit-status))))) + +(defun eask--error-status () + "Return error status." + (let ((result)) + ;; Error. + (when eask--has-error-p + (push 'error result)) + ;; Warning. + (when eask--has-warn-p + (push (if (eask-strict-p) + 'error + 'warn) + result)) + ;; No repeat. + (delete-dups result))) + +(defun eask--handle-exit-status () + "Return non-nil if we should report error for exit status." + (when (memq 'error (eask--error-status)) + (eask--exit 'failure))) ;; ;;; Eask file @@ -2000,7 +2022,7 @@ Argument ARGS are direct arguments for functions `eask-error' or `eask-warn'." "On error. Arguments FNC and ARGS are used for advice `:around'." - (setq eask--has-error-p t) + (setq eask--has-error-p t) ; Just a record. (let ((msg (eask--ansi 'error (apply #'format-message args)))) (unless eask-inhibit-error-message (eask--unsilent (eask-msg "%s" msg))) @@ -2012,7 +2034,7 @@ Arguments FNC and ARGS are used for advice `:around'." "On warn. Arguments FNC and ARGS are used for advice `:around'." - (setq eask--has-warn-p t) + (setq eask--has-warn-p t) ; Just a record. (let ((msg (eask--ansi 'warn (apply #'format-message args)))) (unless eask-inhibit-error-message (eask--unsilent (eask-msg "%s" msg))) diff --git a/lisp/lint/elint.el b/lisp/lint/elint.el index 278f4815..ede7f7a9 100644 --- a/lisp/lint/elint.el +++ b/lisp/lint/elint.el @@ -44,11 +44,6 @@ (eask-print-log-buffer log-buffer) (kill-buffer log-buffer)))) -(defun eask-lint-elint--has-error-p () - "Return non-nil if we should report error for exit status." - (and eask--has-warn-p - (eask-strict-p))) - (eask-start (require 'elint) (let* ((patterns (eask-args)) @@ -62,10 +57,7 @@ (eask-msg "") (eask-info "(Total of %s file%s %s checked)" (length files) (eask--sinr files "" "s") - (eask--sinr files "has" "have")) - ;; Report error. - (when (eask-lint-elint--has-error-p) - (eask--exit 'failure))) + (eask--sinr files "has" "have"))) ;; Pattern defined, but no file found! (patterns (eask-info "(No files match wildcard: %s)" diff --git a/lisp/lint/elsa.el b/lisp/lint/elsa.el index 21392432..69b0e107 100644 --- a/lisp/lint/elsa.el +++ b/lisp/lint/elsa.el @@ -60,12 +60,6 @@ (t (eask-log line))))) (eask-msg "No issues found")))) -(defun eask-lint-elsa--has-error-p () - "Return non-nil if we should report error for exit status." - (or eask--has-error-p - (and eask--has-warn-p - (eask-strict-p)))) - (eask-start ;; Preparation (eask-archive-install-packages '("gnu" "melpa") @@ -85,10 +79,7 @@ (mapcar #'eask-lint-elsa--analyse-file files) (eask-msg "") (eask-info "(Total of %s file%s linted)" (length files) - (eask--sinr files "" "s")) - ;; Report error. - (when (eask-lint-elsa--has-error-p) - (eask--exit 'failure))) + (eask--sinr files "" "s"))) ;; Pattern defined, but no file found! (patterns (eask-msg "") diff --git a/lisp/lint/package.el b/lisp/lint/package.el index 9ba6d09b..676ddcdc 100644 --- a/lisp/lint/package.el +++ b/lisp/lint/package.el @@ -57,11 +57,6 @@ (kill-current-buffer))) (eask-print-log-buffer "*Package-Lint*")) -(defun eask-lint-package--has-error-p () - "Return non-nil if we should report error for exit status." - (and eask--has-warn-p - (eask-strict-p))) - (eask-start ;; Preparation (eask-archive-install-packages '("gnu" "melpa") @@ -82,10 +77,7 @@ (mapcar #'eask-lint-package--file files) (eask-msg "") (eask-info "(Total of %s file%s linted)" (length files) - (eask--sinr files "" "s")) - ;; Report error. - (when (eask-lint-package--has-error-p) - (eask--exit 'failure))) + (eask--sinr files "" "s"))) ;; Pattern defined, but no file found! (patterns (eask-msg "") diff --git a/lisp/lint/regexps.el b/lisp/lint/regexps.el index 5818ef3d..dfddef4f 100644 --- a/lisp/lint/regexps.el +++ b/lisp/lint/regexps.el @@ -61,11 +61,6 @@ (eask-msg "No issues found")) (kill-current-buffer)))) -(defun eask-lint-regexps--has-error-p () - "Return non-nil if we should report error for exit status." - (and eask--has-warn-p - (eask-strict-p))) - (eask-start ;; Preparation (eask-archive-install-packages '("gnu") @@ -85,10 +80,7 @@ (mapcar #'eask-lint-regexps--relint-file files) (eask-msg "") (eask-info "(Total of %s file%s linted)" (length files) - (eask--sinr files "" "s")) - ;; Report error. - (when (eask-lint-regexps--has-error-p) - (eask--exit 'failure))) + (eask--sinr files "" "s"))) ;; Pattern defined, but no file found! (patterns (eask-msg "") From a8c727a6c893f3eb1baff2b4aa45e6367990e94d Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 17:01:30 +0800 Subject: [PATCH 02/13] chore: Fix test files summary --- test/jest/lint/checkdoc-fail.el | 4 ++-- test/jest/lint/declare-fail.el | 2 +- test/jest/lint/declare-ok.el | 2 +- test/jest/lint/elisp-lint-ok.el | 2 +- test/jest/lint/elsa-warn.el | 2 +- test/jest/lint/indent-warn.el | 2 +- test/jest/lint/regexp-warn.el | 2 +- test/jest/options/options.el | 30 ++++++++++++++++++++++++++++++ 8 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 test/jest/options/options.el diff --git a/test/jest/lint/checkdoc-fail.el b/test/jest/lint/checkdoc-fail.el index f521198d..07c05e53 100644 --- a/test/jest/lint/checkdoc-fail.el +++ b/test/jest/lint/checkdoc-fail.el @@ -1,4 +1,4 @@ -;;; ert-test.el --- Test the command ert -*- lexical-binding: t; -*- +;;; checkdoc-fail.el --- Test checkdoc fail -*- lexical-binding: t; -*- ;; Copyright (C) 2025 the Eask authors. @@ -26,4 +26,4 @@ in this " ignore) -;;; declare-ok.el ends here +;;; checkdoc-fail.el ends here diff --git a/test/jest/lint/declare-fail.el b/test/jest/lint/declare-fail.el index 2a3207e5..08c132e6 100644 --- a/test/jest/lint/declare-fail.el +++ b/test/jest/lint/declare-fail.el @@ -1,4 +1,4 @@ -;;; declare-fail.el --- Test lint declare -*- lexical-binding: t; -*- +;;; declare-fail.el --- Test declare-fail -*- lexical-binding: t; -*- ;; Copyright (C) 2025 the Eask authors. diff --git a/test/jest/lint/declare-ok.el b/test/jest/lint/declare-ok.el index 70ab1bfe..fe82549a 100644 --- a/test/jest/lint/declare-ok.el +++ b/test/jest/lint/declare-ok.el @@ -1,4 +1,4 @@ -;;; ert-test.el --- Test the command ert -*- lexical-binding: t; -*- +;;; declare-ok.el --- Test declare-ok -*- lexical-binding: t; -*- ;; Copyright (C) 2025 the Eask authors. diff --git a/test/jest/lint/elisp-lint-ok.el b/test/jest/lint/elisp-lint-ok.el index 29915e81..409f5558 100644 --- a/test/jest/lint/elisp-lint-ok.el +++ b/test/jest/lint/elisp-lint-ok.el @@ -1,4 +1,4 @@ -;;; elisp-lint-ok.el --- Test the linting -*- lexical-binding: t; -*- +;;; elisp-lint-ok.el --- Test elisp-lint-ok -*- lexical-binding: t; -*- ;; Copyright (C) 2025 the Eask authors. diff --git a/test/jest/lint/elsa-warn.el b/test/jest/lint/elsa-warn.el index d7e9ace4..563f7b31 100644 --- a/test/jest/lint/elsa-warn.el +++ b/test/jest/lint/elsa-warn.el @@ -1,4 +1,4 @@ -;;; elsa-warn.el --- Test elsa linting -*- lexical-binding: t; -*- +;;; elsa-warn.el --- Test elsa-warn -*- lexical-binding: t; -*- ;; Copyright (C) 2025 the Eask authors. diff --git a/test/jest/lint/indent-warn.el b/test/jest/lint/indent-warn.el index d2d6156e..42b65490 100644 --- a/test/jest/lint/indent-warn.el +++ b/test/jest/lint/indent-warn.el @@ -1,4 +1,4 @@ -;;; indent-warn.el --- Test indent linting -*- lexical-binding: t; -*- +;;; indent-warn.el --- Test indent-warn -*- lexical-binding: t; -*- ;; Copyright (C) 2025 the Eask authors. diff --git a/test/jest/lint/regexp-warn.el b/test/jest/lint/regexp-warn.el index ecfdc2b2..83f9d8a9 100644 --- a/test/jest/lint/regexp-warn.el +++ b/test/jest/lint/regexp-warn.el @@ -1,4 +1,4 @@ -;;; regexp-warn.el --- Test regexp linting -*- lexical-binding: t; -*- +;;; regexp-warn.el --- Test regexp-warn -*- lexical-binding: t; -*- ;; Copyright (C) 2025 the Eask authors. diff --git a/test/jest/options/options.el b/test/jest/options/options.el new file mode 100644 index 00000000..7b7729fa --- /dev/null +++ b/test/jest/options/options.el @@ -0,0 +1,30 @@ +;;; options.el --- Test options -*- lexical-binding: t; -*- + +;; Copyright (C) 2025 the Eask authors. + +;; 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: +;; +;; Test options. +;; + +;;; Code: + +;; Empty.. + +(provide 'options) +;;; options.el ends here From 9d33b9dccc9826c688ec70d555a8eecffd0fdcf1 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 17:04:33 +0800 Subject: [PATCH 03/13] test: Attempt to fix options --- test/jest/options/options.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/jest/options/options.el b/test/jest/options/options.el index 7b7729fa..c46c536b 100644 --- a/test/jest/options/options.el +++ b/test/jest/options/options.el @@ -1,7 +1,14 @@ -;;; options.el --- Test options -*- lexical-binding: t; -*- +;;; options.el --- Test all options flag -*- lexical-binding: t; -*- ;; Copyright (C) 2025 the Eask authors. +;; Author: Shen, Jen-Chieh +;; Maintainer: Shen, Jen-Chieh +;; URL: https://github.com/emacs-eask/options +;; Version: 0.0.0 +;; Package-Requires: ((emacs "26.1")) +;; Keywords: test + ;; This file is not part of GNU Emacs. ;; This program is free software: you can redistribute it and/or modify From 3837eafc3c806874845308e1ec2b6835fc887447 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 18:12:52 +0800 Subject: [PATCH 04/13] test: Avoid reporting error on incompat versions --- test/jest/helpers.js | 13 +++++++++---- test/jest/install.test.js | 7 +++++-- test/jest/local.test.js | 22 +++++++++++++++++----- test/jest/local/Eask | 2 +- test/jest/local/mini.pkg.1.el | 2 +- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/test/jest/helpers.js b/test/jest/helpers.js index d23488af..60a36f42 100644 --- a/test/jest/helpers.js +++ b/test/jest/helpers.js @@ -157,8 +157,8 @@ class TestContext { * @param {any} config * @returns {Promise.} */ - runEask(command, config) { - return this.run(this.easkCommand + " " + command, config); + runEask(command, config, safe = false) { + return this.run(this.easkCommand + " " + command, config, safe); } /** @@ -170,7 +170,7 @@ class TestContext { * @param {any} config * @returns {Promise.} */ - run(command, config) { + run(command, config, safe = false) { return exec(command, { cwd: this.cwd, signal: this.controller.signal, @@ -188,7 +188,12 @@ class TestContext { return new CommandOutput(obj, this.cwd); }) .catch((err) => { - if (!err.code) err.message += "\nexec: TIMEOUT"; + if (safe) + return this.errorToCommandOutput(err); + + if (!err.code) + err.message += "\nexec: TIMEOUT"; + throw err; }); } diff --git a/test/jest/install.test.js b/test/jest/install.test.js index d7bd81d2..8bbb9ba0 100644 --- a/test/jest/install.test.js +++ b/test/jest/install.test.js @@ -5,6 +5,9 @@ describe("install and uninstall", () => { const ctx = new TestContext("./test/jest/install/"); const packageName = "mini.pkg.1"; + // See https://github.com/emacs-eask/cli/issues/11. + const avoid11 = (emacsVersion() < "28.1"); + beforeAll(async () => { await ctx.runEask("clean all"); }); @@ -12,7 +15,7 @@ describe("install and uninstall", () => { afterAll(() => ctx.cleanUp()); it("installs project package", async () => { - await ctx.runEask("package"); // creates dist/.tar + await ctx.runEask("package", avoid11); // creates dist/.tar await ctx.runEask("install"); // installs dependencies and generated package const { stderr } = await ctx.runEask("list"); expect(stderr).toMatch(packageName); @@ -36,7 +39,7 @@ describe("install and uninstall", () => { }); it("uninstalls project package", async () => { - await ctx.runEask("uninstall"); + await ctx.runEask("uninstall", avoid11); const { stderr } = await ctx.runEask("list"); expect(stderr).not.toMatch(packageName); }); diff --git a/test/jest/local.test.js b/test/jest/local.test.js index 1b2b3278..d18533aa 100644 --- a/test/jest/local.test.js +++ b/test/jest/local.test.js @@ -10,10 +10,15 @@ describe("local", () => { const cwd = "./test/jest/local"; const ctx = new TestContext(cwd); - // NOTE: install-deps takes a long time in this package + // See https://github.com/emacs-eask/cli/issues/11. + const avoid11 = (emacsVersion() < "28.1"); + + // NOTE: `install-deps` takes a long time in this package // this is because of recipe dependencies triggering // "temporary archives" build. - beforeAll(async () => await ctx.runEask("install-deps", { timeout: 40000 })); + beforeAll(async () => { + await ctx.runEask("install-deps", { timeout: 40000 }, avoid11) + }); afterAll(() => ctx.cleanUp()); @@ -77,7 +82,10 @@ describe("local", () => { }); describe("Development", () => { - beforeAll(async () => await ctx.runEask("install-deps")); + beforeAll(async () => { + await ctx.runEask("install-deps", { timeout: 40000 }, avoid11) + }); + // this requires install-deps it("compile", async () => { await ctx.runEask("compile"); @@ -110,7 +118,9 @@ describe("local", () => { }); describe("Execution", () => { - beforeAll(async () => await ctx.runEask("install-deps")); + beforeAll(async () => { + await ctx.runEask("install-deps", { timeout: 40000 }, avoid11) + }); test("eval", async () => { await ctx.runEask('eval "(progn (require \'mini.pkg.1))"'); @@ -195,7 +205,9 @@ describe("local", () => { describe("Linting", () => { // some lint commands may fail if packages are missing - beforeAll(async () => await ctx.runEask("install-deps")); + beforeAll(async () => { + await ctx.runEask("install-deps", { timeout: 40000 }, avoid11) + }); it.each([ "lint checkdoc", diff --git a/test/jest/local/Eask b/test/jest/local/Eask index 91d8bb6d..52ee0819 100644 --- a/test/jest/local/Eask +++ b/test/jest/local/Eask @@ -1,7 +1,7 @@ ;; -*- mode: eask; lexical-binding: t -*- (package "mini.pkg.1" - "9.9.10" + "11.11.12" "Minimal test package") (website-url "https://github.com/emacs-eask/cli/tree/master/test/fixtures/mini.pkg.1") diff --git a/test/jest/local/mini.pkg.1.el b/test/jest/local/mini.pkg.1.el index fd474bcc..ae5fbdca 100644 --- a/test/jest/local/mini.pkg.1.el +++ b/test/jest/local/mini.pkg.1.el @@ -5,7 +5,7 @@ ;; Author: Shen, Jen-Chieh ;; URL: https://github.com/emacs-eask/cli/tree/master/test/fixtures/mini.pkg.1 -;; Version: 9.9.10 +;; Version: 11.11.12 ;; Package-Requires: ((emacs "24.3") (s "1.12.0") (fringe-helper "1.0.1")) ;; Keywords: test local From 8476d8472170f953d646dd895c418ec466f0914b Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 18:19:11 +0800 Subject: [PATCH 05/13] test: split elisp lint --- test/jest/local.test.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/jest/local.test.js b/test/jest/local.test.js index d18533aa..767d20ad 100644 --- a/test/jest/local.test.js +++ b/test/jest/local.test.js @@ -213,7 +213,6 @@ describe("local", () => { "lint checkdoc", "lint declare", "lint elint", - "lint elisp-lint", "lint indent", "lint keywords", "lint license", @@ -222,17 +221,21 @@ describe("local", () => { await ctx.runEask(cmd); }); + // XXX: Elsa is not stable, ignore it for now + test.skip("lint elsa", async () => { + await ctx.runEask("lint elsa"); + }); + + it("lint elint", async () => { + await ctx.runEask("lint elisp-lint", avoid11); + }); + it("lint regexps", async () => { if ((await emacsVersion()) >= "27.1") { await ctx.runEask("lint regexps"); } }); - // XXX: Elsa is not stable, ignore it for now - test.skip("lint elsa", async () => { - await ctx.runEask("lint elsa"); - }); - it("lint org *.org", async () => { await ctx.runEask("lint org *.org"); }); From b9f3971a3f0a27fb7679bba638e4eebb1ce75d07 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 18:24:05 +0800 Subject: [PATCH 06/13] test: Take care of more exit status --- test/jest/exec.test.js | 7 ++++++- test/jest/install.test.js | 2 +- test/jest/outdated-upgrade.test.js | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test/jest/exec.test.js b/test/jest/exec.test.js index 2ff26bf3..d5609065 100644 --- a/test/jest/exec.test.js +++ b/test/jest/exec.test.js @@ -3,7 +3,12 @@ const { TestContext } = require("./helpers"); describe("exec", () => { const ctx = new TestContext("./test/jest/exec"); - beforeAll(async () => await ctx.runEask("install-deps")); + // See https://github.com/emacs-eask/cli/issues/11. + const avoid11 = (emacsVersion() < "28.1"); + + beforeAll(async () => { + await ctx.runEask("install-deps", { timeout: 40000 }, avoid11) + }); afterAll(() => ctx.cleanUp()); diff --git a/test/jest/install.test.js b/test/jest/install.test.js index 8bbb9ba0..e89d72e8 100644 --- a/test/jest/install.test.js +++ b/test/jest/install.test.js @@ -45,7 +45,7 @@ describe("install and uninstall", () => { }); it("installs dependencies", async () => { - const { stderr } = await ctx.runEask("install-deps"); + const { stderr } = await ctx.runEask("install-deps", { timeout: 40000 }, avoid11); expect(stderr).not.toMatch(packageName); }); diff --git a/test/jest/outdated-upgrade.test.js b/test/jest/outdated-upgrade.test.js index 660545ed..7d9b27b9 100644 --- a/test/jest/outdated-upgrade.test.js +++ b/test/jest/outdated-upgrade.test.js @@ -3,8 +3,11 @@ const { TestContext } = require("./helpers"); describe("outdated and upgrade", () => { const ctx = new TestContext("./test/jest/outdated-upgrade"); + // See https://github.com/emacs-eask/cli/issues/11. + const avoid11 = (emacsVersion() < "28.1"); + beforeAll(async () => { - await ctx.runEask("install-deps"); + await ctx.runEask("install-deps", { timeout: 40000 }, avoid11); await ctx.runEask("load make-outdate.el"); }); From 6b75bd40ef15a4cefeb49cafeed838ec4bfb58e9 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 18:25:51 +0800 Subject: [PATCH 07/13] fix: export --- test/jest/exec.test.js | 2 +- test/jest/outdated-upgrade.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jest/exec.test.js b/test/jest/exec.test.js index d5609065..fb3b5bf8 100644 --- a/test/jest/exec.test.js +++ b/test/jest/exec.test.js @@ -1,4 +1,4 @@ -const { TestContext } = require("./helpers"); +const { emacsVersion, TestContext } = require("./helpers"); describe("exec", () => { const ctx = new TestContext("./test/jest/exec"); diff --git a/test/jest/outdated-upgrade.test.js b/test/jest/outdated-upgrade.test.js index 7d9b27b9..f2448fa8 100644 --- a/test/jest/outdated-upgrade.test.js +++ b/test/jest/outdated-upgrade.test.js @@ -1,4 +1,4 @@ -const { TestContext } = require("./helpers"); +const { emacsVersion, TestContext } = require("./helpers"); describe("outdated and upgrade", () => { const ctx = new TestContext("./test/jest/outdated-upgrade"); From 043f94180ed42da368ceae67eb3fc01b1460c9fb Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 18:48:15 +0800 Subject: [PATCH 08/13] test: don't sync emacs version --- test/jest/local/Eask | 2 +- test/jest/local/mini.pkg.1.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jest/local/Eask b/test/jest/local/Eask index 52ee0819..10dde27f 100644 --- a/test/jest/local/Eask +++ b/test/jest/local/Eask @@ -1,7 +1,7 @@ ;; -*- mode: eask; lexical-binding: t -*- (package "mini.pkg.1" - "11.11.12" + "12.12.13" "Minimal test package") (website-url "https://github.com/emacs-eask/cli/tree/master/test/fixtures/mini.pkg.1") diff --git a/test/jest/local/mini.pkg.1.el b/test/jest/local/mini.pkg.1.el index ae5fbdca..3ee45d9d 100644 --- a/test/jest/local/mini.pkg.1.el +++ b/test/jest/local/mini.pkg.1.el @@ -5,7 +5,7 @@ ;; Author: Shen, Jen-Chieh ;; URL: https://github.com/emacs-eask/cli/tree/master/test/fixtures/mini.pkg.1 -;; Version: 11.11.12 +;; Version: 12.12.13 ;; Package-Requires: ((emacs "24.3") (s "1.12.0") (fringe-helper "1.0.1")) ;; Keywords: test local From ca7cfe98ec7e50c954f957294dca745f4ab9b79f Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 19:02:26 +0800 Subject: [PATCH 09/13] test: Try semver-compare --- package-lock.json | 10 +++++++++- package.json | 3 ++- test/jest/exec.test.js | 9 +++++---- test/jest/install.test.js | 21 ++++++++++++++------- test/jest/local.test.js | 14 +++++++++----- test/jest/outdated-upgrade.test.js | 9 +++++---- 6 files changed, 44 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 820d4748..d1091a22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,8 @@ }, "devDependencies": { "@yao-pkg/pkg": "^6.0.0", - "jest": "^29.7.0" + "jest": "^29.7.0", + "semver-compare": "^1.0.0" } }, "node_modules/@ampproject/remapping": { @@ -4200,6 +4201,13 @@ "node": ">=10" } }, + "node_modules/semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==", + "dev": true, + "license": "MIT" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", diff --git a/package.json b/package.json index b60de1c2..feb29fab 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ }, "devDependencies": { "@yao-pkg/pkg": "^6.0.0", - "jest": "^29.7.0" + "jest": "^29.7.0", + "semver-compare": "^1.0.0" }, "jest": { "rootDir": "./test/jest", diff --git a/test/jest/exec.test.js b/test/jest/exec.test.js index fb3b5bf8..abfac1c1 100644 --- a/test/jest/exec.test.js +++ b/test/jest/exec.test.js @@ -1,13 +1,14 @@ +const cmp = require('semver-compare'); const { emacsVersion, TestContext } = require("./helpers"); describe("exec", () => { const ctx = new TestContext("./test/jest/exec"); - // See https://github.com/emacs-eask/cli/issues/11. - const avoid11 = (emacsVersion() < "28.1"); - beforeAll(async () => { - await ctx.runEask("install-deps", { timeout: 40000 }, avoid11) + await ctx.runEask( + "install-deps", { timeout: 40000 }, + // See https://github.com/emacs-eask/cli/issues/11. + cmp(await emacsVersion(), "28.1") == -1)) }); afterAll(() => ctx.cleanUp()); diff --git a/test/jest/install.test.js b/test/jest/install.test.js index e89d72e8..7d7fe74e 100644 --- a/test/jest/install.test.js +++ b/test/jest/install.test.js @@ -1,3 +1,4 @@ +const cmp = require('semver-compare'); const { emacsVersion, TestContext } = require("./helpers"); describe("install and uninstall", () => { @@ -5,9 +6,6 @@ describe("install and uninstall", () => { const ctx = new TestContext("./test/jest/install/"); const packageName = "mini.pkg.1"; - // See https://github.com/emacs-eask/cli/issues/11. - const avoid11 = (emacsVersion() < "28.1"); - beforeAll(async () => { await ctx.runEask("clean all"); }); @@ -15,8 +13,12 @@ describe("install and uninstall", () => { afterAll(() => ctx.cleanUp()); it("installs project package", async () => { - await ctx.runEask("package", avoid11); // creates dist/.tar - await ctx.runEask("install"); // installs dependencies and generated package + // creates dist/.tar + await ctx.runEask("package", + // See https://github.com/emacs-eask/cli/issues/11. + cmp(await emacsVersion(), "28.1") == -1); + // installs dependencies and generated package + await ctx.runEask("install"); const { stderr } = await ctx.runEask("list"); expect(stderr).toMatch(packageName); }); @@ -39,13 +41,18 @@ describe("install and uninstall", () => { }); it("uninstalls project package", async () => { - await ctx.runEask("uninstall", avoid11); + await ctx.runEask("uninstall", + // See https://github.com/emacs-eask/cli/issues/11. + cmp(await emacsVersion(), "28.1") == -1); const { stderr } = await ctx.runEask("list"); expect(stderr).not.toMatch(packageName); }); it("installs dependencies", async () => { - const { stderr } = await ctx.runEask("install-deps", { timeout: 40000 }, avoid11); + const { stderr } = await ctx.runEask( + "install-deps", { timeout: 40000 }, + // See https://github.com/emacs-eask/cli/issues/11. + cmp(await emacsVersion(), "28.1") == -1); expect(stderr).not.toMatch(packageName); }); diff --git a/test/jest/local.test.js b/test/jest/local.test.js index 767d20ad..4e33fbd4 100644 --- a/test/jest/local.test.js +++ b/test/jest/local.test.js @@ -4,20 +4,21 @@ // Notice, below we clone a random package (repo) that uses Eask as the // dependencies management tool. +const cmp = require('semver-compare'); const { emacsVersion, TestContext } = require("./helpers"); describe("local", () => { const cwd = "./test/jest/local"; const ctx = new TestContext(cwd); - // See https://github.com/emacs-eask/cli/issues/11. - const avoid11 = (emacsVersion() < "28.1"); - // NOTE: `install-deps` takes a long time in this package // this is because of recipe dependencies triggering // "temporary archives" build. beforeAll(async () => { - await ctx.runEask("install-deps", { timeout: 40000 }, avoid11) + await ctx.runEask( + "install-deps", { timeout: 40000 }, + // See https://github.com/emacs-eask/cli/issues/11. + cmp(await emacsVersion(), "28.1") == -1); }); afterAll(() => ctx.cleanUp()); @@ -83,7 +84,10 @@ describe("local", () => { describe("Development", () => { beforeAll(async () => { - await ctx.runEask("install-deps", { timeout: 40000 }, avoid11) + await ctx.runEask( + "install-deps", { timeout: 40000 }, + // See https://github.com/emacs-eask/cli/issues/11. + ((await emacsVersion()) < "28.1")) }); // this requires install-deps diff --git a/test/jest/outdated-upgrade.test.js b/test/jest/outdated-upgrade.test.js index f2448fa8..985990ae 100644 --- a/test/jest/outdated-upgrade.test.js +++ b/test/jest/outdated-upgrade.test.js @@ -1,13 +1,14 @@ +const cmp = require('semver-compare'); const { emacsVersion, TestContext } = require("./helpers"); describe("outdated and upgrade", () => { const ctx = new TestContext("./test/jest/outdated-upgrade"); - // See https://github.com/emacs-eask/cli/issues/11. - const avoid11 = (emacsVersion() < "28.1"); - beforeAll(async () => { - await ctx.runEask("install-deps", { timeout: 40000 }, avoid11); + await ctx.runEask( + "install-deps", { timeout: 40000 }, + // See https://github.com/emacs-eask/cli/issues/11. + cmp(await emacsVersion(), "28.1") == -1); await ctx.runEask("load make-outdate.el"); }); From a6e8def9fb444158b96bb20359a0295749347505 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 19:04:55 +0800 Subject: [PATCH 10/13] test: fix syntax --- test/jest/exec.test.js | 2 +- test/jest/local.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jest/exec.test.js b/test/jest/exec.test.js index abfac1c1..4b1536d2 100644 --- a/test/jest/exec.test.js +++ b/test/jest/exec.test.js @@ -8,7 +8,7 @@ describe("exec", () => { await ctx.runEask( "install-deps", { timeout: 40000 }, // See https://github.com/emacs-eask/cli/issues/11. - cmp(await emacsVersion(), "28.1") == -1)) + cmp(await emacsVersion(), "28.1") == -1); }); afterAll(() => ctx.cleanUp()); diff --git a/test/jest/local.test.js b/test/jest/local.test.js index 4e33fbd4..90f7b344 100644 --- a/test/jest/local.test.js +++ b/test/jest/local.test.js @@ -87,7 +87,7 @@ describe("local", () => { await ctx.runEask( "install-deps", { timeout: 40000 }, // See https://github.com/emacs-eask/cli/issues/11. - ((await emacsVersion()) < "28.1")) + cmp(await emacsVersion(), "28.1") == -1) }); // this requires install-deps From ae32d72caa9fff4c601e0af70b3b703574e16b8e Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 19:09:24 +0800 Subject: [PATCH 11/13] test: fix param args --- 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 7d7fe74e..be0fd9a5 100644 --- a/test/jest/install.test.js +++ b/test/jest/install.test.js @@ -14,7 +14,7 @@ describe("install and uninstall", () => { it("installs project package", async () => { // creates dist/.tar - await ctx.runEask("package", + await ctx.runEask("package", { timeout: 40000 }, // See https://github.com/emacs-eask/cli/issues/11. cmp(await emacsVersion(), "28.1") == -1); // installs dependencies and generated package @@ -41,7 +41,7 @@ describe("install and uninstall", () => { }); it("uninstalls project package", async () => { - await ctx.runEask("uninstall", + await ctx.runEask("uninstall", { timeout: 40000 }, // See https://github.com/emacs-eask/cli/issues/11. cmp(await emacsVersion(), "28.1") == -1); const { stderr } = await ctx.runEask("list"); From 45754748800936c9b110ee566698e61999cadbdd Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 19:13:20 +0800 Subject: [PATCH 12/13] test: Remove old avoid11 var --- test/jest/local.test.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/jest/local.test.js b/test/jest/local.test.js index 90f7b344..38a09e88 100644 --- a/test/jest/local.test.js +++ b/test/jest/local.test.js @@ -123,7 +123,9 @@ describe("local", () => { describe("Execution", () => { beforeAll(async () => { - await ctx.runEask("install-deps", { timeout: 40000 }, avoid11) + await ctx.runEask("install-deps", { timeout: 40000 }, + // See https://github.com/emacs-eask/cli/issues/11. + cmp(await emacsVersion(), "28.1") == -1) }); test("eval", async () => { @@ -210,7 +212,9 @@ describe("local", () => { describe("Linting", () => { // some lint commands may fail if packages are missing beforeAll(async () => { - await ctx.runEask("install-deps", { timeout: 40000 }, avoid11) + await ctx.runEask("install-deps", { timeout: 40000 }, + // See https://github.com/emacs-eask/cli/issues/11. + cmp(await emacsVersion(), "28.1") == -1) }); it.each([ @@ -231,7 +235,9 @@ describe("local", () => { }); it("lint elint", async () => { - await ctx.runEask("lint elisp-lint", avoid11); + await ctx.runEask("lint elisp-lint", { }, + // See https://github.com/emacs-eask/cli/issues/11. + cmp(await emacsVersion(), "28.1") == -1); }); it("lint regexps", async () => { From 031a4cb0d70e867ab4833bb57e7dce21e2c866fa Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Sat, 15 Nov 2025 19:55:17 +0800 Subject: [PATCH 13/13] test: Use cmd version comparison instead --- test/jest/install.test.js | 2 +- test/jest/local.test.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/jest/install.test.js b/test/jest/install.test.js index be0fd9a5..9abd3816 100644 --- a/test/jest/install.test.js +++ b/test/jest/install.test.js @@ -107,7 +107,7 @@ describe("install and uninstall", () => { /* VC install */ test.skip("installs vc directly", async () => { - if ((await emacsVersion()) >= "29.1") { + if (cmp(await emacsVersion(), "29.1") == 1) { const { stderr } = await ctx.runEask( "install-vc https://github.com/jcs-elpa/msgu" ); diff --git a/test/jest/local.test.js b/test/jest/local.test.js index 38a09e88..a1054922 100644 --- a/test/jest/local.test.js +++ b/test/jest/local.test.js @@ -55,7 +55,7 @@ describe("local", () => { // NOTE: eask loc is a long running command it("loc", async () => { // installs markdown mode -- depends on emacs 28.1 - if ((await emacsVersion()) >= "28.1") { + if (cmp(await emacsVersion(), "28.1") == 1) { await ctx.runEask("loc"); await ctx.runEask("loc Eask"); } @@ -241,7 +241,7 @@ describe("local", () => { }); it("lint regexps", async () => { - if ((await emacsVersion()) >= "27.1") { + if (cmp(await emacsVersion(), "27.1") == 1) { await ctx.runEask("lint regexps"); } }); @@ -260,7 +260,7 @@ describe("local", () => { describe("Formatting", () => { // installs elisp-autofmt it("format elisp-autofmt", async () => { - if ((await emacsVersion()) >= "29.1") { + if (cmp(await emacsVersion(), "29.1") == 1) { await ctx.runEask("format elisp-autofmt"); } });