Skip to content

Commit

Permalink
WIP - run tests against clojure-ts-mode
Browse files Browse the repository at this point in the history
Includes top level "main" tests, plus an additional
clojure-ts-mode-test. When the clojure-ts-mode one is pulled in
clojure-ts-mode should then be "required" and all calls to clojure-mode
should redirect to clojure-ts-mode via major-mode-remap-alist.
  • Loading branch information
dannyfreeman committed Sep 29, 2023
1 parent ecabc30 commit e4b1f08
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,8 @@ jobs:
# be GH connectivity runner issues. We attempt to address this
# problem by rerunning the tests more than once.
eldev -p -dtTC test --test-type integration || eldev -p -dtTC test --test-type integration
- name: Test clojure-ts-mode integration
if: startsWith (matrix.emacs_version, '29')
run: |
eldev -p -dtTC test --test-type clojure-ts-mode || eldev -p -dtTC test --test-type clojure-ts-mode
25 changes: 18 additions & 7 deletions Eldev
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,44 @@

(eldev-add-loading-roots 'test "test/utils")
(eldev-add-extra-dependencies 'runtime '(:package logview :optional t))
(eldev-add-extra-dependencies 'runtime '(:package clojure-ts-mode :optional t))

(defvar cider-test-type 'main)
(setf eldev-standard-excludes `(:or ,eldev-standard-excludes
;; Avoid including files in test "projects".
(eldev-pcase-exhaustive cider-test-type
(`main "./test/*/")
(`integration '("./test/" "!./test/integration"))
(`all '("./test/*/" "!./test/integration")))
(`main "./test/*/")
(`integration '("./test/" "!./test/integration"))
(`clojure-ts-mode '("./test/*/" "!./test/clojure-ts-mode"))
(`all '("./test/*/" "!./test/integration")))
"test/integration/projects"
;; This file is _supposed_ to be excluded
;; from automated testing.
"test/cider-tests--no-auto.el"))

(eldev-defoption cider-test-selection (type)
"Select tests to run; type can be `main', `integration' or `all'"
"Select tests to run; type can be `main', `integration', `clojure-ts-mode' or `all'"
:options (-T --test-type)
:for-command test
:value TYPE
:default-value cider-test-type
(unless (memq (intern type) '(main integration all))
(unless (memq (intern type) '(main integration clojure-ts-mode all))
(signal 'eldev-wrong-option-usage `("unknown test type `%s'" ,type)))
(setf cider-test-type (intern type)))

(defun use-clojure-ts-mode ()
"Set clojure-ts-mode as a eldev dependency.
Only require it when running `clojure-ts-mode' test type,
otherwise during regular test runs all calls to clojure-mode would be
redirected to execute clojure-ts-mode thanks to entries it adds in the
`major-mode-remap-alist'."
(let ((need-clojure-ts-mode (eq cider-test-type 'clojure-ts-mode)))
(eldev-add-extra-dependencies
'runtime '(:package clojure-ts-mode :optional (not need-clojure-ts-mode)))))

(add-hook 'eldev-test-hook
(lambda ()
(eldev-verbose "Using cider tests of type `%s'" cider-test-type)))
(eldev-verbose "Using cider tests of type `%s'" cider-test-type)
(use-clojure-ts-mode)))
(add-hook 'eldev-executing-command-hook
(lambda (command)
(unless (eq command 'test)
Expand Down
16 changes: 16 additions & 0 deletions test/clojure-ts-mode/clojure-ts-mode-tests.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
;;; Commentary:

;; This file is part of CIDER

;;; Code:

(require 'buttercup)
(require 'clojure-ts-mode)

(describe "clojure-ts-mode"
(it "passes"
(expect (= 1 1))))

(provide 'clojure-ts-mode-tests)

;;; clojure-ts-mode-tests.el ends here

0 comments on commit e4b1f08

Please sign in to comment.