From 33458112ae3701a82a02a4b88dd52baef48ababe Mon Sep 17 00:00:00 2001 From: Gregor Grigorjan Date: Mon, 20 May 2024 04:31:17 +0300 Subject: [PATCH] feat(test): add tests that run outside of a Git repo --- nix/packages.nix | 5 +++-- test/magit-file-icons-git-repo-tests.el | 29 +++++++++++++++++++++++++ test/magit-file-icons-tests.el | 18 +-------------- 3 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 test/magit-file-icons-git-repo-tests.el diff --git a/nix/packages.nix b/nix/packages.nix index aa9c589b..c8764d90 100644 --- a/nix/packages.nix +++ b/nix/packages.nix @@ -14,6 +14,7 @@ _: { packageRequires = [ pkgs.emacsPackages.el-patch pkgs.emacsPackages.nerd-icons + pkgs.emacsPackages.magit ]; doCheck = true; @@ -21,12 +22,12 @@ _: { nativeCheckInputs = [ pkgs.git pkgs.emacs - pkgs.emacsPackages.magit ] ++ packageRequires; checkPhase = '' - git init # need to be in repository for Magit tests to not fail emacs --batch -l ert -l magit-file-icons.el -l ./test/magit-file-icons-tests.el -f ert-run-tests-batch-and-exit + git init + emacs --batch -l ert -l magit-file-icons.el -l ./test/magit-file-icons-git-repo-tests.el -f ert-run-tests-batch-and-exit ''; meta = { diff --git a/test/magit-file-icons-git-repo-tests.el b/test/magit-file-icons-git-repo-tests.el new file mode 100644 index 00000000..9585cd8a --- /dev/null +++ b/test/magit-file-icons-git-repo-tests.el @@ -0,0 +1,29 @@ +;; -*- lexical-binding: t; -*- + +(require 'ert) +(require 'el-patch) +(require 'magit-file-icons) + +(ert-deftest magit-file-icons-test-can-open-magit-status-buffer-while-in-minor-mode () + (magit-file-icons-mode +1) + (magit-status-setup-buffer)) + +(ert-deftest magit-file-icons-test-can-enable-minor-mode-in-magit-status-buffer () + (magit-status-setup-buffer) + (magit-file-icons-mode +1)) + +(ert-deftest magit-file-icons-test-can-disable-minor-mode-in-magit-status-buffer () + (magit-file-icons-mode +1) + (magit-status-setup-buffer) + (magit-file-icons-mode -1)) + +(ert-deftest magit-file-icons-test-can-toggle-minor-mode-in-magit-status-buffer () + (magit-file-icons-mode +1) + (magit-status-setup-buffer) + (magit-file-icons-mode 'toggle) + (magit-file-icons-mode 'toggle)) + +;; Local Variables: +;; flycheck-disabled-checkers: (emacs-lisp-checkdoc) +;; End: + diff --git a/test/magit-file-icons-tests.el b/test/magit-file-icons-tests.el index 57acde05..dbc06d9e 100644 --- a/test/magit-file-icons-tests.el +++ b/test/magit-file-icons-tests.el @@ -7,25 +7,9 @@ (ert-deftest magit-file-icons-test-has-no-invalid-templates () (el-patch-validate-all-templates)) -(ert-deftest magit-file-icons-test-can-open-magit-status-buffer-while-in-minor-mode () - (magit-file-icons-mode +1) - (magit-status-setup-buffer)) - -(ert-deftest magit-file-icons-test-can-enable-minor-mode-in-magit-status-buffer () - (magit-status-setup-buffer) +(ert-deftest magit-file-icons-test-can-load-minor-mode-outside-of-git-repo () (magit-file-icons-mode +1)) -(ert-deftest magit-file-icons-test-can-disable-minor-mode-in-magit-status-buffer () - (magit-file-icons-mode +1) - (magit-status-setup-buffer) - (magit-file-icons-mode -1)) - -(ert-deftest magit-file-icons-test-can-toggle-minor-mode-in-magit-status-buffer () - (magit-file-icons-mode +1) - (magit-status-setup-buffer) - (magit-file-icons-mode 'toggle) - (magit-file-icons-mode 'toggle)) - ;; Local Variables: ;; flycheck-disabled-checkers: (emacs-lisp-checkdoc) ;; End: