|
9 | 9 | (expand-file-name default-directory) |
10 | 10 | ".melpa-cache/")) |
11 | 11 |
|
| 12 | +(setq quicklintjs-test-dir (file-name-directory (or load-file-name buffer-file-name))) |
| 13 | + |
12 | 14 | (defun quicklintjs-install-deps (deps) |
13 | 15 | (mapcar (lambda (pkg) (unless (package-installed-p pkg) |
14 | 16 | (if (> emacs-major-version 24) |
|
39 | 41 |
|
40 | 42 | (defun def-flymake-tests () |
41 | 43 | (require 'flymake-quicklintjs) |
| 44 | + |
| 45 | + ; Disable warning which causes tests to fail when run non-interactively: |
| 46 | + ; "Disabling backend flymake-proc-legacy-flymake because (error Can’t find a suitable init function)" |
| 47 | + (remove-hook 'flymake-diagnostic-functions 'flymake-proc-legacy-flymake) |
| 48 | + |
42 | 49 | (ert-deftest quicklintjs-flymake-parse-errors-and-warnings () |
43 | 50 | (skip-unless (>= emacs-major-version 26)) |
44 | 51 | (let ((js-buf (generate-new-buffer "*js-buf*"))) |
@@ -89,7 +96,21 @@ foobar\")((16 . 22) 2 \"E0057\" \"use of undeclared variable: foobar\")(\ |
89 | 96 | (point-min) (point-max) |
90 | 97 | flymake-quicklintjs-program nil |
91 | 98 | out-buf nil "--stdin" |
92 | | - "--output-format=emacs-lisp") 0)))))) |
| 99 | + "--output-format=emacs-lisp") 0))))) |
| 100 | + |
| 101 | + (ert-deftest quicklintjs-flymake-check-errors-js () |
| 102 | + (with-temp-buffer |
| 103 | + (javascript-mode) |
| 104 | + (insert-file-contents-literally (expand-file-name "error.js" quicklintjs-test-dir) nil nil nil t) |
| 105 | + (flymake-mode 1) |
| 106 | + (add-hook 'flymake-diagnostic-functions #'flymake-quicklintjs nil t) |
| 107 | + (flymake-start) |
| 108 | + |
| 109 | + (with-timeout (5 |
| 110 | + (ert-fail "Test timed out waiting for diagnostics.")) |
| 111 | + ;; TODO(strager): Assert specific diagnostics |
| 112 | + (while (not (flymake-diagnostics)) |
| 113 | + (accept-process-output nil 0.01)))))) |
93 | 114 |
|
94 | 115 | (defun def-eglot-tests () |
95 | 116 | (ert-deftest quicklintjs-is-in-eglot-servers () |
|
0 commit comments