Skip to content

Commit

Permalink
Fix warnings and add test for target that fails
Browse files Browse the repository at this point in the history
  • Loading branch information
psibi committed Jun 25, 2022
1 parent 01e1a1f commit c068e2f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ jobs:
- uses: purcell/setup-emacs@master
with:
version: ${{ matrix.emacs_version }}
- uses: leotaku/elisp-check@master
- uses: leotaku/elisp-check@v1.3
with:
file: '*.el'
file: "justl.el"
check: melpa
ignore_warnings: ${{ matrix.ignore_warnings }}
warnings_as_errors: true
warnings_as_errors: false
- name: ERT tests
uses: leotaku/elisp-check@master
with:
Expand Down
13 changes: 3 additions & 10 deletions justl.el
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
(require 'esh-mode)
(require 's)
(require 'f)
(require 'compile)

(defgroup justl nil
"Justfile customization group."
Expand Down Expand Up @@ -314,8 +315,7 @@ controls if we are going to display the process status on mode line."
(force-mode-line-update)
(if (or compilation-auto-jump-to-first-error
(eq compilation-scroll-output 'first-error))
(set (make-local-variable 'compilation-auto-jump-to-next) t))
)))
(set (make-local-variable 'compilation-auto-jump-to-next) t)))))

(defvar justl--compile-command nil
"Last shell command used to do a compilation; default for next compilation.")
Expand All @@ -334,7 +334,6 @@ ARGS is a plist that affects how the process is run.
(or (plist-get args :buffer) justl--output-process-buffer)))
(process-name (or (plist-get args :process) justl--compilation-process-name))
(mode (or (plist-get args :mode) 'justl-compile-mode))
(justfile justl--justfile)
(directory (or (plist-get args :directory) (f-dirname justl--justfile)))
(sentinel (or (plist-get args :sentinel) #'justl--sentinel))
(inhibit-read-only t))
Expand Down Expand Up @@ -369,12 +368,6 @@ ARGS is a plist that affects how the process is run.
:process "just"
:mode 'justl-compile-mode)))

(defconst justl-mode-compilation-finished "^Target execution \\(finished\\).*")

(defvar sibi-test
'(justl-mode-compilation-finished (0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)
()) )

(defvar justl-mode-font-lock-keywords
'(
("^Target execution \\(finished\\).*"
Expand Down Expand Up @@ -607,7 +600,7 @@ tweaked further by the user."
:choices '("auto" "always" "never"))

(transient-define-prefix justl-help-popup ()
"Justl Menu"
"Justl Menu."
[["Arguments"
("-s" "Clear shell arguments" "--clear-shell-args")
("-d" "Dry run" "--dry-run")
Expand Down
4 changes: 4 additions & 0 deletions test/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ plan:

push2 version1 version2:
echo {{version1}} {{version2}}

# A target that will fail
fail:
exit 1
18 changes: 15 additions & 3 deletions test/justl-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

(ert-deftest justl--get-recipies-test ()
(should (equal
(list "default" "build-cmd" "plan" "push" "push2")
(list "default" "build-cmd" "plan" "push" "push2" "fail")
(justl--get-recipies))))

(ert-deftest justl--list-to-recipe-test ()
Expand Down Expand Up @@ -185,7 +185,19 @@
(justl--wait-till-exit justl--output-process-buffer))
(with-current-buffer justl--output-process-buffer
(let ((buf-string (buffer-substring-no-properties (point-min) (point-max))))
(should (s-contains? "Finished execution: exit-code 0" buf-string))))
(should (s-contains? "Target execution finished" buf-string))))
(kill-buffer (justl--buffer-name))
(kill-buffer justl--output-process-buffer))

(ert-deftest justl--fail-recipe ()
(justl)
(with-current-buffer (justl--buffer-name)
(search-forward "fail")
(justl-exec-recipe)
(justl--wait-till-exit justl--output-process-buffer))
(with-current-buffer justl--output-process-buffer
(let ((buf-string (buffer-substring-no-properties (point-min) (point-max))))
(should (s-contains? "exited abnormally" buf-string))))
(kill-buffer (justl--buffer-name))
(kill-buffer justl--output-process-buffer))

Expand All @@ -199,7 +211,7 @@
(should (member (list "push" nil) recipies))
(should (member (list "push2" nil) recipies))))

;; (ert "justl--**")
(ert "justl--**")

(provide 'justl-test)
;;; justl-test.el ends here

0 comments on commit c068e2f

Please sign in to comment.