Modify test running system
authorStrigoides <Strigoides@gmail.com>
Fri, 26 Apr 2013 12:16:42 +0000 (00:16 +1200)
committerStrigoides <Strigoides@gmail.com>
Fri, 26 Apr 2013 12:16:42 +0000 (00:16 +1200)
Rather than manually listing all tests to be run, every file with the
.lisp extension in the tests directory is automatically run

jscl.lisp
tests-report.lisp [new file with mode: 0644]
tests.lisp [new file with mode: 0644]
tests/tests-report.lisp [deleted file]
tests/tests.lisp [deleted file]

index 12b71cf..ef84f41 100644 (file)
--- a/jscl.lisp
+++ b/jscl.lisp
     ("print"     :target)
     ("read"      :both)
     ("compiler"  :both)
-    ("toplevel"  :target)
-    ;; Tests
-    ("tests"            :test)
-    ("setf"             :test)
-    ("eval"             :test)
-    ("tests-report"     :test)))
+    ("toplevel"  :target)))
 
 (defun source-pathname
     (filename &key (directory '(:relative "src")) (type nil) (defaults filename))
@@ -81,9 +76,7 @@
         (ls-compile-file (source-pathname (car input) :type "lisp") out))))
   ;; Tests
   (with-open-file (out "tests.js" :direction :output :if-exists :supersede)
-    (dolist (input *source*)
-      (when (member (cadr input) '(:test))
-        (ls-compile-file (source-pathname (car input)
-                                          :directory '(:relative "tests")
-                                          :type "lisp")
-                         out)))))
+    (dolist (input (append (directory "tests.lisp")
+                           (directory "tests/*.lisp")
+                           (directory "tests-report.lisp"))) 
+      (ls-compile-file input out))))
diff --git a/tests-report.lisp b/tests-report.lisp
new file mode 100644 (file)
index 0000000..b40da9e
--- /dev/null
@@ -0,0 +1,15 @@
+(write-line "")
+(write-string "Finished. The execution took ")
+(write-string (prin1-to-string (/ (- (get-internal-real-time) *timestamp*) internal-time-units-per-second)))
+(write-line " seconds.")
+
+(cond
+  ((zerop *failed-tets*)
+   (write-string "All tests (")
+   (write-string (prin1-to-string *passed-tets*))
+   (write-line ") passed successfully"))
+  (t
+   (write-string (prin1-to-string *failed-tets*))
+   (write-string "/")
+   (write-string (prin1-to-string (+ *passed-tets* *failed-tets*)))
+   (write-line " failed.")))
diff --git a/tests.lisp b/tests.lisp
new file mode 100644 (file)
index 0000000..b230068
--- /dev/null
@@ -0,0 +1,15 @@
+(defvar *passed-tets* 0)
+(defvar *failed-tets* 0)
+(defvar *timestamp* (get-internal-real-time))
+
+(defmacro test (condition)
+  `(cond
+     (,condition
+      (write-line ,(concat "Test `" (prin1-to-string condition) "' passed"))
+      (incf *passed-tets*))
+     (t
+      (write-line ,(concat "Test `" (prin1-to-string condition) "' failed."))
+      (incf *failed-tets*))))
+
+(write-line "Running tests...")
+(write-line "")
diff --git a/tests/tests-report.lisp b/tests/tests-report.lisp
deleted file mode 100644 (file)
index b40da9e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-(write-line "")
-(write-string "Finished. The execution took ")
-(write-string (prin1-to-string (/ (- (get-internal-real-time) *timestamp*) internal-time-units-per-second)))
-(write-line " seconds.")
-
-(cond
-  ((zerop *failed-tets*)
-   (write-string "All tests (")
-   (write-string (prin1-to-string *passed-tets*))
-   (write-line ") passed successfully"))
-  (t
-   (write-string (prin1-to-string *failed-tets*))
-   (write-string "/")
-   (write-string (prin1-to-string (+ *passed-tets* *failed-tets*)))
-   (write-line " failed.")))
diff --git a/tests/tests.lisp b/tests/tests.lisp
deleted file mode 100644 (file)
index b230068..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-(defvar *passed-tets* 0)
-(defvar *failed-tets* 0)
-(defvar *timestamp* (get-internal-real-time))
-
-(defmacro test (condition)
-  `(cond
-     (,condition
-      (write-line ,(concat "Test `" (prin1-to-string condition) "' passed"))
-      (incf *passed-tets*))
-     (t
-      (write-line ,(concat "Test `" (prin1-to-string condition) "' failed."))
-      (incf *failed-tets*))))
-
-(write-line "Running tests...")
-(write-line "")