1;;; alchemist-mix-test.el --- -*- lexical-binding: t; -*-
2
3;; Copyright © 2015 Samuel Tonini
4;;
5;; Author: Samuel Tonini <tonini.samuel@gmail.com>
6
7;; This file is not part of GNU Emacs.
8
9;; This program is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; This program is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22;;; Commentary:
23
24;;; Code:
25
26(require 'test-helper)
27
28(defun prepare-test-report-buffer ()
29  (when (process-live-p (get-buffer-process (get-buffer alchemist-test-report-buffer-name)))
30    (set-process-query-on-exit-flag (get-buffer-process (get-buffer alchemist-test-report-buffer-name)) nil)))
31
32(ert-deftest test-mix/run-mix-test ()
33  (prepare-test-report-buffer)
34  (cd "test/dummy_elixir/test/")
35  (shut-up
36    (alchemist-mix-test))
37  (should (equal "" alchemist-last-run-test))
38  (delay 2.0 (lambda ()
39               (should (alchemist-report--last-run-successful-p))))
40  (wait 2.1))
41
42(ert-deftest test-mix/run-mix-test-file ()
43  (prepare-test-report-buffer)
44  (cd "test/dummy_elixir/test/")
45  (shut-up
46    (alchemist-mix-test-file "dummy_elixir_test.exs"))
47  (should (equal (expand-file-name "dummy_elixir_test.exs") alchemist-last-run-test))
48  (delay 2.0 (lambda ()
49               (should (alchemist-report--last-run-successful-p))))
50  (wait 2.1))
51
52(ert-deftest test-mix/run-mix-test-stale ()
53  (prepare-test-report-buffer)
54  (cd "test/dummy_elixir/test/")
55  (shut-up
56   (alchemist-mix-test-stale))
57  ;; CI runs multiple elixir versions so check correct version here
58  (if (alchemist-utils-elixir-version-check-p 1 3 0)
59      (should (equal "--stale" alchemist-last-run-test))
60    (should (equal "" alchemist-last-run-test)))
61  (delay 2.1 (lambda ()
62               (should (alchemist-report--last-run-successful-p))))
63  (wait 2.1))
64
65(provide 'alchemist-mix-test)
66
67;;; alchemist-goto-test.el ends here
68