emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 7a9bd8d 07/28: Add async mode startup test.


From: Jackson Ray Hamilton
Subject: [elpa] master 7a9bd8d 07/28: Add async mode startup test.
Date: Tue, 05 May 2015 11:10:16 +0000

branch: master
commit 7a9bd8d82cee14afacf7d402bc89595c7afb9286
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Add async mode startup test.
---
 context-coloring.el           |    8 +++++++-
 test/context-coloring-test.el |   15 +++++++++++++++
 2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index 5ef09ab..31eb133 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -470,12 +470,18 @@ elisp tracks, and asynchronously for shell command 
tracks."
 
 ;;; Colorization
 
+(defvar context-coloring-colorize-hook nil
+  "Hooks to run after coloring a buffer.")
+
 (defun context-coloring-colorize (&optional callback)
   "Color the current buffer by function context.
 
 Invoke CALLBACK when complete; see `context-coloring-dispatch'."
   (interactive)
-  (context-coloring-dispatch callback))
+  (context-coloring-dispatch
+   (lambda ()
+     (when callback (funcall callback))
+     (run-hooks 'context-coloring-colorize-hook))))
 
 (defvar-local context-coloring-changed nil
   "Indication that the buffer has changed recently, which implies
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 333a3f3..ede72aa 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -55,6 +55,7 @@
   (setq context-coloring-syntactic-comments nil)
   (setq context-coloring-syntactic-strings nil)
   (setq context-coloring-js-block-scopes nil)
+  (setq context-coloring-colorize-hook nil)
   (setq context-coloring-check-scopifier-version-hook nil))
 
 (defmacro context-coloring-test-with-fixture (fixture &rest body)
@@ -303,6 +304,20 @@ FOREGROUND.  Apply ARGUMENTS to
 
 ;;; The tests
 
+(ert-deftest-async context-coloring-test-async-mode-startup (done)
+  (context-coloring-test-with-fixture-async
+   "./fixtures/function-scopes.js"
+   (lambda (teardown)
+     (js-mode)
+     (add-hook
+      'context-coloring-colorize-hook
+      (lambda ()
+        ;; If this runs we are implicitly successful; this test only confirms
+        ;; that colorization occurs on mode startup.
+        (funcall teardown)
+        (funcall done)))
+     (context-coloring-mode))))
+
 (ert-deftest context-coloring-test-check-version ()
   (when (not (context-coloring-check-version "2.1.3" "3.0.1"))
     (ert-fail "Expected version 3.0.1 to satisfy 2.1.3, but it didn't."))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]