Variable to enable/disable color in test output
authorOwen Rodley <Strigoides@gmail.com>
Wed, 1 May 2013 02:39:16 +0000 (14:39 +1200)
committerOwen Rodley <Strigoides@gmail.com>
Wed, 1 May 2013 02:39:16 +0000 (14:39 +1200)
tests.lisp

index 6fce25e..8c57af4 100644 (file)
@@ -5,6 +5,9 @@
 (defvar *expected-failures* 0)
 (defvar *unexpected-passes* 0)
 
+(defvar *use-html-output-p* t)
+(defun if-html (string) (if *use-html-output-p* string ""))
+
 (defvar *timestamp* nil)
 
 (defmacro test (condition)
         (write-line ,(concat "Test `" (prin1-to-string condition) "' passed"))
         (incf *passed-tests*))
        (t
-        (write-line ,(concat "<font color=red>Test `"
-                             (prin1-to-string condition) 
-                             "' failed.</font>"))
+        (write-line (concat (if-html "<font color=red>")
+                            "Test `"
+                            ,(prin1-to-string condition) 
+                            "' failed."
+                            (if-html "</font>")))
         (incf *failed-tests*)))
      (incf *total-tests*)))
 
   `(progn
      (cond
        (,condition
-        (write-line ,(concat "<font color=orange>Test `"
-                             (prin1-to-string condition)
-                             "' passed unexpectedly!</font>"))
+         (write-line (concat (if-html "<font color=orange>")
+                             "Test `"
+                             ,(prin1-to-string condition)
+                             "' passed unexpectedly!"
+                             (if-html "</font>")))
         (incf *unexpected-passes*))
        (t
         (write-line ,(concat "Test `" (prin1-to-string condition) "' failed expectedly."))