Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
psibi committed Dec 8, 2024
1 parent 1d2ccb1 commit 638ae6c
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions test/justl-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

(ert-deftest justl--lists-recipe ()
(justl)
(with-current-buffer (justl--buffer-name)
(with-current-buffer (justl--buffer-name nil)
(let ((buf-string (buffer-string)))
(should (search-forward "plan" nil t))))
(kill-buffer (justl--buffer-name)))
(kill-buffer (justl--buffer-name nil)))

(defun justl--wait-till-exit (buffer)
"Wait till the BUFFER has exited."
Expand All @@ -47,38 +47,38 @@

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

(ert-deftest justl--execute-test-exit-status ()
(justl)
(with-current-buffer (justl--buffer-name)
(with-current-buffer (justl--buffer-name nil)
(search-forward "plan")
(justl-exec-recipe)
(justl--wait-till-exit (justl--recipe-output-buffer "plan")))
(with-current-buffer (justl--recipe-output-buffer "plan")
(let ((buf-string (buffer-substring-no-properties (point-min) (point-max))))
(should (s-contains? "Target execution finished" buf-string))))
(kill-buffer (justl--buffer-name))
(kill-buffer (justl--buffer-name nil))
(kill-buffer (justl--recipe-output-buffer "plan")))

(ert-deftest justl--fail-recipe ()
(justl)
(with-current-buffer (justl--buffer-name)
(with-current-buffer (justl--buffer-name nil)
(search-forward "fail")
(justl-exec-recipe)
(justl--wait-till-exit (justl--recipe-output-buffer "fail"))
(with-current-buffer (justl--recipe-output-buffer "fail")
(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--buffer-name nil))
(kill-buffer (justl--recipe-output-buffer "fail"))))

(ert-deftest justl--find-justfile-check ()
Expand All @@ -87,28 +87,28 @@
(ert-deftest justl--execute-recipe-which-prints-carriage-return ()
"Carriage return should be handled in a way that allows overwriting lines."
(justl)
(with-current-buffer (justl--buffer-name)
(with-current-buffer (justl--buffer-name nil)
(search-forward "carriage-return")
(justl-exec-recipe)
(justl--wait-till-exit (justl--recipe-output-buffer "carriage-return")))
(with-current-buffer (justl--recipe-output-buffer "carriage-return")
(let ((buf-string (buffer-substring-no-properties (point-min) (point-max))))
(should (s-contains? "DONE\n" buf-string))
(should-not (s-contains? "1/3\r2/3\r3/3\rDONE\n" buf-string))))
(kill-buffer (justl--buffer-name))
(kill-buffer (justl--buffer-name nil))
(kill-buffer (justl--recipe-output-buffer "carriage-return")))

(ert-deftest justl--execute-recipe-with-color ()
"A target printing color is handled properly."
(justl)
(with-current-buffer (justl--buffer-name)
(with-current-buffer (justl--buffer-name nil)
(search-forward "color")
(justl-exec-recipe)
(justl--wait-till-exit (justl--recipe-output-buffer "color")))
(with-current-buffer (justl--recipe-output-buffer "color")
(let ((buf-string (buffer-substring-no-properties (point-min) (point-max))))
(should (s-contains? "This is red text\n" buf-string))))
(kill-buffer (justl--buffer-name))
(kill-buffer (justl--buffer-name nil))
(kill-buffer (justl--recipe-output-buffer "color")))

(ert-deftest justl--execute-default-recipe ()
Expand Down Expand Up @@ -152,27 +152,27 @@
(let ((current justl-per-recipe-buffer))
(customize-set-variable 'justl-per-recipe-buffer 't)
(justl)
(with-current-buffer (justl--buffer-name)
(with-current-buffer (justl--buffer-name nil)
(search-forward "plan")
(justl-exec-recipe)
(justl--wait-till-exit "*just-plan*"))
(with-current-buffer "*just-plan*"
(let ((buf-string (buffer-substring-no-properties (point-min) (point-max))))
(should (s-contains? "Target execution finished" buf-string))))
(kill-buffer (justl--buffer-name))
(kill-buffer (justl--buffer-name nil))
(kill-buffer "*just-plan*")
(customize-set-variable 'justl-per-recipe-buffer current)))

(ert-deftest justl--no-private-recipe-by-default ()
(justl)
(with-current-buffer (justl--buffer-name)
(with-current-buffer (justl--buffer-name nil)
(let ((buf-string (buffer-substring-no-properties (point-min) (point-max))))
(should-not (s-contains? "_private" buf-string)))))

(ert-deftest justl--private-recipe-visible ()
(let ((justl-include-private-recipes t))
(justl))
(with-current-buffer (justl--buffer-name)
(with-current-buffer (justl--buffer-name nil)
(let ((buf-string (buffer-substring-no-properties (point-min) (point-max))))
(should (s-contains? "_private" buf-string)))))

Expand Down

0 comments on commit 638ae6c

Please sign in to comment.