From e63f1ce9ccf30d57fa76addef32aa42a0db1c39e Mon Sep 17 00:00:00 2001 From: Max Regan Date: Wed, 23 Mar 2022 15:00:22 -0700 Subject: [PATCH] Add unit test for mgr-gitlab-clone, run in CI --- .doom.d/lisp/mgr-gitlab/mgr-gitlab.el | 6 +++++- .mgr_config/tests/gitlab-utils.sh | 10 ++++++++++ .mgr_config/tests/test-emacs.sh | 16 +++++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .mgr_config/tests/gitlab-utils.sh diff --git a/.doom.d/lisp/mgr-gitlab/mgr-gitlab.el b/.doom.d/lisp/mgr-gitlab/mgr-gitlab.el index de244b3..c80976f 100644 --- a/.doom.d/lisp/mgr-gitlab/mgr-gitlab.el +++ b/.doom.d/lisp/mgr-gitlab/mgr-gitlab.el @@ -45,12 +45,12 @@ (defun mgr-gitlab-clone (name) "Clone the project NAME." - ;; TODO: Automatically set remote.pushDefault so it does not prompt ;; TODO: Clone with API token, if there is one (interactive (list (completing-read "Project: " (mgr-gitlab-list-remote-project-names)))) (let* ((url (mgr-gitlab--get-url-by-name name)) (dest mgr-gitlab-project-path)) + (setf magit-clone-set-remote.pushDefault t) (magit-clone-regular url dest nil))) (defun mgr-gitlab-clone-all () @@ -92,4 +92,8 @@ gitlab so kindly removes." (add-to-list 'dashboard-item-generators '(mgr-gitlab-gitlab-projects . mgr-gitlab-dashboard-insert-gitlab-projects)) +(ert-deftest mgr-gitlab-clone-test () + "Tests that mgr-gitlab can clone a repo" + (mgr-gitlab-clone "IotButton")) + (provide 'mgr-gitlab) diff --git a/.mgr_config/tests/gitlab-utils.sh b/.mgr_config/tests/gitlab-utils.sh new file mode 100644 index 0000000..2016dac --- /dev/null +++ b/.mgr_config/tests/gitlab-utils.sh @@ -0,0 +1,10 @@ +gitlab_start_log_section() { + NAME="$1" + HEADER="2" + echo -e "\e[0Ksection_start:`date +%s`:${NAME}\r\e[0K${HEADER}" +} + +gitlab_end_log_section() { + NAME="$1" + echo -e "\e[0Ksection_start:`date +%s`:${NAME}\r\e[0K${HEADER}" +} diff --git a/.mgr_config/tests/test-emacs.sh b/.mgr_config/tests/test-emacs.sh index c85d693..66ac9fb 100755 --- a/.mgr_config/tests/test-emacs.sh +++ b/.mgr_config/tests/test-emacs.sh @@ -1,3 +1,17 @@ #!/bin/bash -emacs --batch --debug-init --load ./.emacs.d/init.el +set -e -o pipefail + +SRC_ROOT="$(dirname "${BASH_SOURCE}")" + +source "$SRC_ROOT/gitlab-utils.sh" + +# Load emacs +gitlab_start_log_section "test_init" "Running Emacs" +emacs --batch --debug-init -l ./.emacs.d/init.el +gitlab_end_log_section "test_init" + +# Run tests +gitlab_start_log_section "run_unit_tests" "Running Unit Tests" +emacs --batch --debug-init -l ert -l ./.emacs.d/init.el -f ert-run-tests-batch-and-exit +gitlab_end_log_section "run_unit_tests"