branch: externals/csharp-mode
commit 775fafd22d9f9140bde7befcee832c8294b3da18
Author: Jostein Kjønigsen <jost...@kjonigsen.net>
Commit: Jostein Kjønigsen <jost...@kjonigsen.net>

    Make assess-package available for testing.
    
    Should enable better fontification tests with technique outlined in the
    followining blogpost:
    
    http://www.wilfred.me.uk/blog/2016/04/28/effortless-major-mode-development/
---
 csharp-mode-tests.el | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/csharp-mode-tests.el b/csharp-mode-tests.el
index 1a8ac1a..f679d46 100644
--- a/csharp-mode-tests.el
+++ b/csharp-mode-tests.el
@@ -1,6 +1,8 @@
 (require 'ert)
 (require 'cl-lib)
 (require 'csharp-mode)
+(require 'cl)
+(require 'package)
 
 ;;; test-helper functions
 
@@ -18,6 +20,29 @@
     (setq end (point))
     (buffer-substring start end)))
 
+(add-to-list 'package-archives '("melpa"        . 
"https://melpa.org/packages/";))
+(package-initialize)
+(setq csharp-test-packages '(assess))
+
+(defun csharp-test-packages-installed-p ()
+  "Return nil if there are packages that are not installed."
+  (loop for p in csharp-test-packages
+        when (not (package-installed-p p)) do (return nil)
+        finally (return t)))
+
+(defun csharp-test-packages-install-packages ()
+  "Install missing packages."
+  (unless (csharp-test-packages-installed-p)
+    ;; Referesh package lists
+    (package-refresh-contents)
+    ;; Install missing
+    (dolist (p csharp-test-packages)
+      (when (not (package-installed-p p))
+        (ignore-errors
+          (package-install p))))))
+(csharp-test-packages-install-packages)
+
+
 ;;; actual tests
 
 (ert-deftest activating-mode-doesnt-cause-failure ()

Reply via email to