;;; Code:
-(defconst directory (file-name-directory (or load-file-name buffer-file-name))
+(defconst download-dependencies-directory
+ (file-name-directory (or load-file-name buffer-file-name))
"This file's directory.")
-(defun resolve-path (path)
+(defun download-dependencies-resolve-path (path)
"Resolve a path relative to this file's directory."
- (expand-file-name path directory))
+ (expand-file-name path download-dependencies-directory))
-(defun strip-headers ()
+(defun download-dependencies-strip-headers ()
"Remove the http headers included in the output of
`url-retrieve-synchronously'."
(goto-char 1)
- (kill-paragraph 1) ; The headers are 1 paragraph. I hope.
+ (kill-paragraph 1) ; The headers are 1 paragraph. I hope.
(kill-line) ; A line separates the headers from the file's content.
)
;; Download any missing dependencies.
(let ((files '("https://raw.githubusercontent.com/mooz/js2-mode/master/js2-mode.el"
"https://raw.githubusercontent.com/rejeep/ert-async.el/master/ert-async.el")))
- (make-directory (resolve-path "../libraries") t)
+ (make-directory (download-dependencies-resolve-path "../libraries") t)
(dolist (file files)
(let* ((basename (file-name-nondirectory file))
- (destination (resolve-path (concat "../libraries/" basename))))
+ (destination (download-dependencies-resolve-path
+ (concat "../libraries/" basename))))
(when (null (file-exists-p destination))
(with-current-buffer (url-retrieve-synchronously file)
- (strip-headers)
+ (download-dependencies-strip-headers)
(write-file destination))))))
;;; download-dependencies.el ends here
;;; Code:
+(require 'context-coloring)
(require 'ert-async)
+(require 'js2-mode)
;;; Test running utilities
(defun context-coloring-test-cleanup ()
"Cleanup after all tests."
(setq context-coloring-comments-and-strings t)
- (setq context-coloring-after-colorize-hook nil)
(setq context-coloring-js-block-scopes nil))
(defmacro context-coloring-test-with-fixture (fixture &rest body)
"Create a temporary buffer, and evaluate CALLBACK there. A
teardown callback is passed to CALLBACK for it to invoke when it
is done."
- (let ((temp-buffer (make-symbol "temp-buffer")))
- (let ((previous-buffer (current-buffer))
- (temp-buffer (generate-new-buffer " *temp*")))
- (set-buffer temp-buffer)
- (funcall
- callback
- (lambda ()
- (and (buffer-name temp-buffer)
- (kill-buffer temp-buffer))
- (set-buffer previous-buffer))))))
+ (let ((previous-buffer (current-buffer))
+ (temp-buffer (generate-new-buffer " *temp*")))
+ (set-buffer temp-buffer)
+ (funcall
+ callback
+ (lambda ()
+ (and (buffer-name temp-buffer)
+ (kill-buffer temp-buffer))
+ (set-buffer previous-buffer)))))
(defun context-coloring-test-with-fixture-async
(fixture callback &optional setup)
(length (- end start)))
(while (< i length)
(let* ((point (+ i start))
- (face (get-text-property point 'face))
- actual-level)
+ (face (get-text-property point 'face)))
,@body)
(setq i (+ i 1)))))
"Assert that all points in the range [START, END) are of level
LEVEL."
(context-coloring-test-assert-region
- (when (not (when face
- (let* ((face-string (symbol-name face))
- (matches (string-match
- context-coloring-level-face-regexp
- face-string)))
- (when matches
- (setq actual-level (string-to-number
- (substring face-string
- (match-beginning 1)
- (match-end 1))))
- (= level actual-level)))))
- (ert-fail (format (concat "Expected level in region [%s, %s), "
- "which is \"%s\", to be %s; "
- "but at point %s, it was %s")
- start end
- (buffer-substring-no-properties start end) level
- point actual-level)))))
+ (let (actual-level)
+ (when (not (when face
+ (let* ((face-string (symbol-name face))
+ (matches (string-match
+ context-coloring-level-face-regexp
+ face-string)))
+ (when matches
+ (setq actual-level (string-to-number
+ (substring face-string
+ (match-beginning 1)
+ (match-end 1))))
+ (= level actual-level)))))
+ (ert-fail (format (concat "Expected level in region [%s, %s), "
+ "which is \"%s\", to be %s; "
+ "but at point %s, it was %s")
+ start end
+ (buffer-substring-no-properties start end) level
+ point actual-level))))))
(defun context-coloring-test-assert-region-face (start end expected-face)
"Assert that all points in the range [START, END) have the face