From: Strigoides Date: Fri, 26 Apr 2013 12:16:42 +0000 (+1200) Subject: Modify test running system X-Git-Url: http://repo.macrolet.net/gitweb/?p=jscl.git;a=commitdiff_plain;h=ad091133b3c6e27c105f6631076cb408df386d42 Modify test running system Rather than manually listing all tests to be run, every file with the .lisp extension in the tests directory is automatically run --- diff --git a/jscl.lisp b/jscl.lisp index 12b71cf..ef84f41 100644 --- a/jscl.lisp +++ b/jscl.lisp @@ -23,12 +23,7 @@ ("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 index 0000000..b40da9e --- /dev/null +++ b/tests-report.lisp @@ -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 index 0000000..b230068 --- /dev/null +++ b/tests.lisp @@ -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 index b40da9e..0000000 --- a/tests/tests-report.lisp +++ /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 index b230068..0000000 --- a/tests/tests.lisp +++ /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 "")