Skip to content

Commit 81bf8d5

Browse files
authored
Test exit status of compile command (#366)
1 parent f7d8a90 commit 81bf8d5

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

test/jest/compile.test.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const { TestContext } = require("./helpers");
2+
3+
describe("compile", () => {
4+
const ctx = new TestContext("./test/jest/compile");
5+
6+
afterAll(() => {
7+
ctx.cleanUp();
8+
});
9+
10+
describe("in an empty project", () => {
11+
const ctxEmpty = new TestContext("./test/jest/empty");
12+
13+
it("should error on partial input", async () => {
14+
await expect(ctxEmpty.runEask("compile")).rejects.toThrow();
15+
});
16+
});
17+
18+
describe("for compile/mock.el", () => {
19+
it("should compile with a warning", async () => {
20+
await ctx.runEask("compile mock.el");
21+
});
22+
23+
it("should escalate warnings given --strict", async () => {
24+
await expect(
25+
ctx.runEask("compile --strict mock.el"),
26+
).rejects.toMatchObject({ code: 1 });
27+
});
28+
});
29+
30+
describe("for compile/fail.el", () => {
31+
beforeEach(async () => {
32+
await ctx.runEask("clean elc");
33+
});
34+
35+
it("should error", async () => {
36+
await expect(ctx.runEask("compile fail.el")).rejects.toMatchObject({
37+
code: 1,
38+
});
39+
});
40+
41+
it("should compile mock.el given --allow-error", async () => {
42+
await expect(
43+
ctx.runEask("compile --allow-error fail.el mock.el"),
44+
).rejects.toMatchObject({
45+
code: 1,
46+
stderr: expect.stringContaining("1 file compiled, 1 skipped"),
47+
});
48+
expect(ctx.fileExists("./mock.elc"));
49+
});
50+
});
51+
});

test/jest/compile/Eask

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
;; -*- mode: eask; lexical-binding: t -*-
2+
(package "check" "0.0.1" "mock package")

test/jest/compile/fail.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
;; -*- lexical-binding: t -*-
2+
;; this must fail to compile
3+
(fail "" (

test/jest/compile/mock.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
;;;###autoload
2+
(defun my-ignore-fn ()
3+
"Mock for testing"
4+
(interactive)
5+
(message "foo"))

0 commit comments

Comments
 (0)