Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)))
Expand All @@ -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)))
Expand Down
10 changes: 1 addition & 9 deletions lisp/lint/elint.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)"
Expand Down
11 changes: 1 addition & 10 deletions lisp/lint/elsa.el
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 "")
Expand Down
10 changes: 1 addition & 9 deletions lisp/lint/package.el
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 "")
Expand Down
10 changes: 1 addition & 9 deletions lisp/lint/regexps.el
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 "")
Expand Down
10 changes: 9 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 8 additions & 2 deletions test/jest/exec.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
const { TestContext } = require("./helpers");
const cmp = require('semver-compare');
const { emacsVersion, TestContext } = require("./helpers");

describe("exec", () => {
const ctx = new TestContext("./test/jest/exec");

beforeAll(async () => await ctx.runEask("install-deps"));
beforeAll(async () => {
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());

Expand Down
13 changes: 9 additions & 4 deletions test/jest/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class TestContext {
* @param {any} config
* @returns {Promise.<CommandOutput>}
*/
runEask(command, config) {
return this.run(this.easkCommand + " " + command, config);
runEask(command, config, safe = false) {
return this.run(this.easkCommand + " " + command, config, safe);
}

/**
Expand All @@ -170,7 +170,7 @@ class TestContext {
* @param {any} config
* @returns {Promise.<CommandOutput>}
*/
run(command, config) {
run(command, config, safe = false) {
return exec(command, {
cwd: this.cwd,
signal: this.controller.signal,
Expand All @@ -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;
});
}
Expand Down
20 changes: 15 additions & 5 deletions test/jest/install.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const cmp = require('semver-compare');
const { emacsVersion, TestContext } = require("./helpers");

describe("install and uninstall", () => {
Expand All @@ -12,8 +13,12 @@ describe("install and uninstall", () => {
afterAll(() => ctx.cleanUp());

it("installs project package", async () => {
await ctx.runEask("package"); // creates dist/<pkg>.tar
await ctx.runEask("install"); // installs dependencies and generated package
// creates dist/<pkg>.tar
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
await ctx.runEask("install");
const { stderr } = await ctx.runEask("list");
expect(stderr).toMatch(packageName);
});
Expand All @@ -36,13 +41,18 @@ 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");
expect(stderr).not.toMatch(packageName);
});

it("installs dependencies", async () => {
const { stderr } = await ctx.runEask("install-deps");
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);
});

Expand Down Expand Up @@ -97,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"
);
Expand Down
4 changes: 2 additions & 2 deletions test/jest/lint/checkdoc-fail.el
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -26,4 +26,4 @@

in this " ignore)

;;; declare-ok.el ends here
;;; checkdoc-fail.el ends here
2 changes: 1 addition & 1 deletion test/jest/lint/declare-fail.el
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion test/jest/lint/declare-ok.el
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion test/jest/lint/elisp-lint-ok.el
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion test/jest/lint/elsa-warn.el
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion test/jest/lint/indent-warn.el
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion test/jest/lint/regexp-warn.el
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
Loading
Loading