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
57 changes: 46 additions & 11 deletions lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,14 @@ 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--resolve-exit-status)))))

(defun eask--resolve-exit-status ()
"Resolve current exit status."
(when (memq 'error (eask--error-status))
(eask--exit 'failure)))

;;
;;; Eask file
Expand Down Expand Up @@ -1988,35 +1995,63 @@ Argument ARGS are direct arguments for functions `eask-error' or `eask-warn'."
(declare (indent 0) (debug t))
`(eask-ignore-errors (eask--silent-error ,@body)))

(defun eask--trigger-error ()
"Trigger error event."
(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--trigger-error (args)
"Trigger error event.

The argument ARGS is passed from the function `eask--error'."
(cond ((< emacs-major-version 28)
;; Handle https://github.com/emacs-eask/cli/issues/11.
(unless (string-prefix-p "Can't find library " (car args))
(setq eask--has-error-p t)))
(t
(setq eask--has-error-p t))) ; Just a record.

(when (and (not eask--ignore-error-p)
(not (eask-checker-p))) ; Ignore when checking Eask-file.
(if (eask-allow-error-p) ; Trigger error at the right time.
(add-hook 'eask-after-command-hook #'eask--exit)
(eask--exit))))
(not (eask-allow-error-p))
;; Ignore when checking Eask-file.
(not (eask-checker-p)))
;; Stop immediately.
(eask--exit 'failure)))

(defun eask--error (fnc &rest args)
"On error.

Arguments FNC and ARGS are used for advice `:around'."
(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)))
(run-hook-with-args 'eask-on-error-hook 'error msg)
(eask--trigger-error))
(eask--trigger-error args))
(when debug-on-error (apply fnc args)))

(defun eask--trigger-warn ()
"Trigger warning event."
(setq eask--has-warn-p t)) ; Just a record.

(defun eask--warn (fnc &rest args)
"On warn.

Arguments FNC and ARGS are used for advice `:around'."
(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)))
(run-hook-with-args 'eask-on-warning-hook 'warn msg))
(run-hook-with-args 'eask-on-warning-hook 'warn msg)
(eask--trigger-warn))
(eask--silent (apply fnc args)))

;; Don't pollute outer exection.
Expand Down
5 changes: 1 addition & 4 deletions test/jest/exec.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
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", { timeout: 40000 },
// See https://github.com/emacs-eask/cli/issues/11.
cmp(await emacsVersion(), "28.1") == -1);
"install-deps", { timeout: 40000 });
});

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

/**
Expand All @@ -173,7 +173,7 @@ class TestContext {
* @param {any} config
* @returns {Promise.<CommandOutput>}
*/
run(command, config, safe = false) {
run(command, config) {
return exec(command, {
cwd: this.cwd,
signal: this.controller.signal,
Expand All @@ -191,9 +191,6 @@ class TestContext {
return new CommandOutput(obj, this.cwd);
})
.catch((err) => {
if (safe)
return this.errorToCommandOutput(err);

if (!err.code)
err.message += "\nexec: TIMEOUT";

Expand Down
13 changes: 3 additions & 10 deletions test/jest/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ describe("install and uninstall", () => {

it("installs project package", async () => {
// 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);
await ctx.runEask("package");
// installs dependencies and generated package
await ctx.runEask("install");
const { stderr } = await ctx.runEask("list");
Expand All @@ -41,18 +39,13 @@ describe("install and uninstall", () => {
});

it("uninstalls project package", async () => {
await ctx.runEask("uninstall", { timeout: 40000 },
// See https://github.com/emacs-eask/cli/issues/11.
cmp(await emacsVersion(), "28.1") == -1);
await ctx.runEask("uninstall");
const { stderr } = await ctx.runEask("list");
expect(stderr).not.toMatch(packageName);
});

it("installs dependencies", async () => {
const { stderr } = await ctx.runEask(
"install-deps", { timeout: 40000 },
// See https://github.com/emacs-eask/cli/issues/11.
cmp(await emacsVersion(), "28.1") == -1);
const { stderr } = await ctx.runEask("install-deps");
expect(stderr).not.toMatch(packageName);
});

Expand Down
25 changes: 5 additions & 20 deletions test/jest/local.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ describe("local", () => {
// this is because of recipe dependencies triggering
// "temporary archives" build.
beforeAll(async () => {
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("install-deps", { timeout: 40000 });
});

afterAll(() => ctx.cleanUp());
Expand Down Expand Up @@ -84,10 +81,7 @@ describe("local", () => {

describe("Development", () => {
beforeAll(async () => {
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("install-deps", { timeout: 40000 });
});

// this requires install-deps
Expand Down Expand Up @@ -123,9 +117,7 @@ describe("local", () => {

describe("Execution", () => {
beforeAll(async () => {
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("install-deps", { timeout: 40000 });
});

test("eval", async () => {
Expand Down Expand Up @@ -212,15 +204,14 @@ describe("local", () => {
describe("Linting", () => {
// some lint commands may fail if packages are missing
beforeAll(async () => {
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("install-deps", { timeout: 40000 });
});

it.each([
"lint checkdoc",
"lint declare",
"lint elint",
"lint elisp-lint",
"lint indent",
"lint keywords",
"lint license",
Expand All @@ -234,12 +225,6 @@ describe("local", () => {
await ctx.runEask("lint elsa");
});

it("lint elint", async () => {
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 () => {
if (cmp(await emacsVersion(), "27.1") == 1) {
await ctx.runEask("lint regexps");
Expand Down
6 changes: 1 addition & 5 deletions test/jest/outdated-upgrade.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
const cmp = require('semver-compare');
const { emacsVersion, TestContext } = require("./helpers");

describe("outdated and upgrade", () => {
const ctx = new TestContext("./test/jest/outdated-upgrade");

beforeAll(async () => {
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("install-deps", { timeout: 40000 });
await ctx.runEask("load make-outdate.el");
});

Expand Down
Loading