Skip to content

Add exit code tests #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9fe9bc0
Add exit code tests for analyze command
joshbax189 Nov 4, 2024
3768981
Moved test to test/exit-status
joshbax189 Nov 6, 2024
6afcac4
Test create command
joshbax189 Nov 6, 2024
db0fa00
Test errors in clean command
joshbax189 Nov 6, 2024
7ee79b3
Test errors in eval command
joshbax189 Nov 6, 2024
90de7e9
Test compile command
joshbax189 Nov 6, 2024
7ae4207
Test format command
joshbax189 Nov 6, 2024
ed03823
Add generate tests
joshbax189 Nov 12, 2024
20406b7
Fix order of args in should_match
joshbax189 Nov 12, 2024
62c27fd
Test install-deps command
joshbax189 Nov 12, 2024
17f914c
test install package
joshbax189 Nov 12, 2024
f391f42
Add valid package fixture
joshbax189 Nov 13, 2024
d1efb01
Test link command
joshbax189 Nov 13, 2024
4d36006
Test lint command
joshbax189 Nov 13, 2024
d640a95
Test load command
joshbax189 Nov 13, 2024
bca2d1c
Test package command
joshbax189 Nov 13, 2024
91da7eb
Test command refresh
joshbax189 Nov 13, 2024
e4fba3c
Test uninstall command
joshbax189 Nov 13, 2024
8b2c071
Test reinstall command
joshbax189 Nov 13, 2024
af4ca28
Test run command
joshbax189 Nov 13, 2024
432fa11
fix: typo in ert help
joshbax189 Nov 19, 2024
0751e97
Tests for testing subcommands
joshbax189 Dec 11, 2024
818034f
Add an extra workflow for exit-status tests
joshbax189 Dec 12, 2024
5246888
Merge branch 'master' into feat/exit-code-tests
joshbax189 Mar 31, 2025
7302d9d
Update exit-status fixmes after (#307)
joshbax189 Mar 31, 2025
c83402a
Move analyze test files to a single directory
joshbax189 Mar 31, 2025
1eddbb3
Port analyze exit-status tests to jest
joshbax189 Mar 31, 2025
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
54 changes: 54 additions & 0 deletions .github/workflows/test_exit-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test Exit Status of Commands

on:
push:
branches:
- master
paths:
- 'eask'
- '**.yml'
- lisp/**
- cmds/**
- src/**
- test/**
pull_request:
branches:
- master
paths-ignore:
- '**.md'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
emacs-version:
- 29.4

steps:
- uses: jcs090218/setup-emacs@master
with:
version: ${{ matrix.emacs-version }}

- uses: actions/checkout@v4

- name: Prepare Eask (Unix)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: |
chmod -R 777 ./
.github/scripts/setup-eask

- name: Prepare Eask (Windows)
if: matrix.os == 'windows-latest'
run: .github/scripts/setup-eask.ps1

- name: Testing...
run: |
make test-exit-status
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,22 @@ color:

error:
./test/error/run.sh

test-exit-status:
./test/exit-status/clean/run.sh
./test/exit-status/compile/run.sh
./test/exit-status/create/run.sh
./test/exit-status/eval/run.sh
./test/exit-status/format/run.sh
./test/exit-status/generate/run.sh
./test/exit-status/install/run.sh
./test/exit-status/install-deps/run.sh
./test/exit-status/link/run.sh
./test/exit-status/lint/run.sh
./test/exit-status/load/run.sh
./test/exit-status/package/run.sh
./test/exit-status/refresh/run.sh
./test/exit-status/reinstall/run.sh
./test/exit-status/run/run.sh
./test/exit-status/test/run.sh
./test/exit-status/uninstall/run.sh
1 change: 1 addition & 0 deletions test/exit-status/clean/Eask
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(package "check-clean" "0.0.1" "mock package")
5 changes: 5 additions & 0 deletions test/exit-status/clean/mock.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
;;;###autoload
(defun my-ignore-fn ()
"Mock for testing"
(interactive)
(message "foo"))
57 changes: 57 additions & 0 deletions test/exit-status/clean/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash

# Copyright (C) 2022-2024 the Eask authors.

# 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, 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 <https://www.gnu.org/licenses/>.

## Commentary:
#
# Tests "clean" command's option handling and error behaviour.

set -e

source ./test/fixtures/home/scripts/testing.sh
cd $(dirname "$0")

echo "Preparing test"
# clean elc should work
eask compile mock.el
if [ ! -f ./mock.elc ]; then
echo "failed to create .elc files"
exit 1
fi

echo "Test clean command"

# partial input
should_error eask clean

should_run eask clean elc

# dist is write protected
# FIXME either or both of these should error
# should_error eask clean dist
# should_error eask clean dist --strict

# recompile to use for --allow-error
eask compile mock.el

# FIXME
# expect that clean dist fails and clean elc succeeds
# should_error eask clean all --allow-error

# if [ -f ./mock.elc ]; then
# echo "expected .elc files to be removed by eask clean all"
# exit 1
# fi
1 change: 1 addition & 0 deletions test/exit-status/compile/Eask
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(package "check" "0.0.1" "mock package")
Empty file.
3 changes: 3 additions & 0 deletions test/exit-status/compile/fail.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
;; -*- lexical-binding: t -*-
;; this must fail to compile
(fail "" (
5 changes: 5 additions & 0 deletions test/exit-status/compile/mock.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
;;;###autoload
(defun my-ignore-fn ()
"Mock for testing"
(interactive)
(message "foo"))
47 changes: 47 additions & 0 deletions test/exit-status/compile/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

# Copyright (C) 2022-2024 the Eask authors.

# 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, 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 <https://www.gnu.org/licenses/>.

## Commentary:
#
# Tests "compile" command's option handling and error behaviour.

set -e

source ./test/fixtures/home/scripts/testing.sh
cd $(dirname "$0")

# partial input errors when there are no files
cd empty
should_error eask compile
cd ../

# compiles with a warning
should_run eask compile mock.el

should_error eask compile --strict mock.el

# --allow-error
# rest state
eask clean elc -v 0
should_error eask compile fail.el
should_error eask compile --allow-error fail.el mock.el

# ensure mock.el is still compiled
if [ ! -f mock.elc ]; then
echo "fail: expected to see mock.elc"
exit 1
fi
Empty file.
35 changes: 35 additions & 0 deletions test/exit-status/create/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

# Copyright (C) 2022-2024 the Eask authors.

# 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, 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 <https://www.gnu.org/licenses/>.

## Commentary:
#
# Tests "complete" command's error behaviour.

set -e

source ./test/fixtures/home/scripts/testing.sh
cd $(dirname "$0")

# partial input errors
should_error eask create
should_error eask create elpa
should_error eask create package

# FIXME
# existing file errors
# should_error eask create elpa foo
# should_error eask create package foo
1 change: 1 addition & 0 deletions test/exit-status/eval/Eask
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(package "check" "0.0.1" "mock package")
40 changes: 40 additions & 0 deletions test/exit-status/eval/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

# Copyright (C) 2022-2024 the Eask authors.

# 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, 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 <https://www.gnu.org/licenses/>.

## Commentary:
#
# Tests "eval" command's option handling and error behaviour.

set -e

source ./test/fixtures/home/scripts/testing.sh
cd $(dirname "$0")

# partial input
should_error eask eval

should_run eask eval '(message "hello")'

should_run eask eval '(warn "hello")'

# FIXME
# should_error eask eval '(warn "hello")' --strict

should_error eask eval '(error "hello")'
should_error eask eval "(signal 'error \"hello\")"
# --allow-error doesn't really change anything here
should_error eask eval '(error "hello")' --allow-error
6 changes: 6 additions & 0 deletions test/exit-status/fixtures/valid/Eask
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(package "valid-package" "0.0.1" "mock package that installs cleanly")

(source 'gnu)
(source 'melpa)

(depends-on "emacs" "28.3")
6 changes: 6 additions & 0 deletions test/exit-status/fixtures/valid/foo.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(defun foo-nothing (args)
"docstring"
(interactive "P")
)

(provide 'foo)
2 changes: 2 additions & 0 deletions test/exit-status/fixtures/valid/valid-package-pkg.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(define-package "valid-package" "0.0.1"
"mock package that installs cleanly" '((emacs "28.3")))
1 change: 1 addition & 0 deletions test/exit-status/format/Eask
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(package "check" "0.0.1" "mock package")
Empty file.
3 changes: 3 additions & 0 deletions test/exit-status/format/fail.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
;; -*- lexical-binding: t -*-
;; this must fail to compile
(fail "" (
5 changes: 5 additions & 0 deletions test/exit-status/format/mock.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
;;;###autoload
(defun my-ignore-fn ()
"Mock for testing"
(interactive)
(message "foo"))
48 changes: 48 additions & 0 deletions test/exit-status/format/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

# Copyright (C) 2022-2024 the Eask authors.

# 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, 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 <https://www.gnu.org/licenses/>.

## Commentary:
#
# Tests "format" command's option handling and error behaviour.

set -e

source ./test/fixtures/home/scripts/testing.sh
cd $(dirname "$0")

# partial input
should_error eask format

# other commands default to apply to everything
should_run eask format elfmt mock.el
should_run eask format elisp-autofmt mock.el

# does anything create elfmt warnings?

should_error eask format elfmt fail.el
# FIXME
# should_error eask format elisp-autofmt fail.el

# FIXME throws
# OUTPUT=$(should_error eask format elfmt --allow-error fail.el mock.el)
# echo "$OUTPUT"
# should_match "Total of 1 .*" "$OUTPUT"

# FIXME
# OUTPUT=$(should_error eask format elisp-autofmt --allow-error fail.el mock.el)
# echo "$OUTPUT"
# should_match "Total of 1 .* formatted" "$OUTPUT"
1 change: 1 addition & 0 deletions test/exit-status/generate/Eask
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(package "check-clean" "0.0.1" "mock package")
3 changes: 3 additions & 0 deletions test/exit-status/generate/fail.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
;; -*- lexical-binding: t -*-
;; this must fail to compile
(fail "" (
7 changes: 7 additions & 0 deletions test/exit-status/generate/mock.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
;;;###autoload
(defun my-ignore-fn ()
"Mock for testing"
(interactive)
(message "foo"))

(provide 'foo)
Loading
Loading