Skip to content

Commit 3837eaf

Browse files
committed
test: Avoid reporting error on incompat versions
1 parent 9d33b9d commit 3837eaf

File tree

5 files changed

+33
-13
lines changed

5 files changed

+33
-13
lines changed

test/jest/helpers.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ class TestContext {
157157
* @param {any} config
158158
* @returns {Promise.<CommandOutput>}
159159
*/
160-
runEask(command, config) {
161-
return this.run(this.easkCommand + " " + command, config);
160+
runEask(command, config, safe = false) {
161+
return this.run(this.easkCommand + " " + command, config, safe);
162162
}
163163

164164
/**
@@ -170,7 +170,7 @@ class TestContext {
170170
* @param {any} config
171171
* @returns {Promise.<CommandOutput>}
172172
*/
173-
run(command, config) {
173+
run(command, config, safe = false) {
174174
return exec(command, {
175175
cwd: this.cwd,
176176
signal: this.controller.signal,
@@ -188,7 +188,12 @@ class TestContext {
188188
return new CommandOutput(obj, this.cwd);
189189
})
190190
.catch((err) => {
191-
if (!err.code) err.message += "\nexec: TIMEOUT";
191+
if (safe)
192+
return this.errorToCommandOutput(err);
193+
194+
if (!err.code)
195+
err.message += "\nexec: TIMEOUT";
196+
192197
throw err;
193198
});
194199
}

test/jest/install.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ describe("install and uninstall", () => {
55
const ctx = new TestContext("./test/jest/install/");
66
const packageName = "mini.pkg.1";
77

8+
// See https://github.com/emacs-eask/cli/issues/11.
9+
const avoid11 = (emacsVersion() < "28.1");
10+
811
beforeAll(async () => {
912
await ctx.runEask("clean all");
1013
});
1114

1215
afterAll(() => ctx.cleanUp());
1316

1417
it("installs project package", async () => {
15-
await ctx.runEask("package"); // creates dist/<pkg>.tar
18+
await ctx.runEask("package", avoid11); // creates dist/<pkg>.tar
1619
await ctx.runEask("install"); // installs dependencies and generated package
1720
const { stderr } = await ctx.runEask("list");
1821
expect(stderr).toMatch(packageName);
@@ -36,7 +39,7 @@ describe("install and uninstall", () => {
3639
});
3740

3841
it("uninstalls project package", async () => {
39-
await ctx.runEask("uninstall");
42+
await ctx.runEask("uninstall", avoid11);
4043
const { stderr } = await ctx.runEask("list");
4144
expect(stderr).not.toMatch(packageName);
4245
});

test/jest/local.test.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ describe("local", () => {
1010
const cwd = "./test/jest/local";
1111
const ctx = new TestContext(cwd);
1212

13-
// NOTE: install-deps takes a long time in this package
13+
// See https://github.com/emacs-eask/cli/issues/11.
14+
const avoid11 = (emacsVersion() < "28.1");
15+
16+
// NOTE: `install-deps` takes a long time in this package
1417
// this is because of recipe dependencies triggering
1518
// "temporary archives" build.
16-
beforeAll(async () => await ctx.runEask("install-deps", { timeout: 40000 }));
19+
beforeAll(async () => {
20+
await ctx.runEask("install-deps", { timeout: 40000 }, avoid11)
21+
});
1722

1823
afterAll(() => ctx.cleanUp());
1924

@@ -77,7 +82,10 @@ describe("local", () => {
7782
});
7883

7984
describe("Development", () => {
80-
beforeAll(async () => await ctx.runEask("install-deps"));
85+
beforeAll(async () => {
86+
await ctx.runEask("install-deps", { timeout: 40000 }, avoid11)
87+
});
88+
8189
// this requires install-deps
8290
it("compile", async () => {
8391
await ctx.runEask("compile");
@@ -110,7 +118,9 @@ describe("local", () => {
110118
});
111119

112120
describe("Execution", () => {
113-
beforeAll(async () => await ctx.runEask("install-deps"));
121+
beforeAll(async () => {
122+
await ctx.runEask("install-deps", { timeout: 40000 }, avoid11)
123+
});
114124

115125
test("eval", async () => {
116126
await ctx.runEask('eval "(progn (require \'mini.pkg.1))"');
@@ -195,7 +205,9 @@ describe("local", () => {
195205

196206
describe("Linting", () => {
197207
// some lint commands may fail if packages are missing
198-
beforeAll(async () => await ctx.runEask("install-deps"));
208+
beforeAll(async () => {
209+
await ctx.runEask("install-deps", { timeout: 40000 }, avoid11)
210+
});
199211

200212
it.each([
201213
"lint checkdoc",

test/jest/local/Eask

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;; -*- mode: eask; lexical-binding: t -*-
22

33
(package "mini.pkg.1"
4-
"9.9.10"
4+
"11.11.12"
55
"Minimal test package")
66

77
(website-url "https://github.com/emacs-eask/cli/tree/master/test/fixtures/mini.pkg.1")

test/jest/local/mini.pkg.1.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
;; Author: Shen, Jen-Chieh <jcs090218@gmail.com>
77
;; URL: https://github.com/emacs-eask/cli/tree/master/test/fixtures/mini.pkg.1
8-
;; Version: 9.9.10
8+
;; Version: 11.11.12
99
;; Package-Requires: ((emacs "24.3") (s "1.12.0") (fringe-helper "1.0.1"))
1010
;; Keywords: test local
1111

0 commit comments

Comments
 (0)