Skip to content
Snippets Groups Projects
Commit b48c2352 authored by Raymond Toy's avatar Raymond Toy
Browse files

Add function to run selected tests. Makes it a bit easier to run a

selected set instead of all tests.
parent 074f4d0b
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
;;;; ;;;;
;;;; lisp -noinit -load tests/run-tests.lisp -eval '(cmucl-test-runner:run-all-tests)' ;;;; lisp -noinit -load tests/run-tests.lisp -eval '(cmucl-test-runner:run-all-tests)'
;;;; ;;;;
;;;;
;;;; To run selected tests:
;;;;
;;;; lisp -noinit -load tests/run-tests.lisp -eval '(progn (cmucl-test-runner:load-test-files) (cmucl-test-runner:run-test <list>))'
;;;;
;;;; Note that you cannot run these tests from a binary created during ;;;; Note that you cannot run these tests from a binary created during
;;;; a build process. You must run ;;;; a build process. You must run
;;;; ;;;;
...@@ -25,6 +30,7 @@ ...@@ -25,6 +30,7 @@
#:load-test-files #:load-test-files
#:run-loaded-tests #:run-loaded-tests
#:run-all-tests #:run-all-tests
#:run-test
#:print-test-results)) #:print-test-results))
(in-package :cmucl-test-runner) (in-package :cmucl-test-runner)
...@@ -65,8 +71,16 @@ ...@@ -65,8 +71,16 @@
test-results)) test-results))
(nreverse test-results))) (nreverse test-results)))
;; Run selected tests
(defun run-test (&rest tests)
(let (test-results)
(dolist (test tests)
(push (lisp-unit:run-tests :all test)
test-results))
(print-test-results (nreverse test-results) :verbose t)))
;; Print out a summary of test results produced from RUN-LOADED-TESTS. ;; Print out a summary of test results produced from RUN-LOADED-TESTS.
(defun print-test-results (results &key verbose) (defun print-test-results (results &key verbose exitp)
(let ((passed 0) (let ((passed 0)
(failed 0) (failed 0)
(execute-errors 0) (execute-errors 0)
...@@ -106,9 +120,11 @@ ...@@ -106,9 +120,11 @@
(format t "~2&Execute failures: ~S~%" execute-error-tests) (format t "~2&Execute failures: ~S~%" execute-error-tests)
(dolist (result results) (dolist (result results)
(lisp-unit:print-errors result))) (lisp-unit:print-errors result)))
(unix:unix-exit 1)) (when exitp
(unix:unix-exit 1)))
(t (t
(unix:unix-exit 0))))) (when exitp
(unix:unix-exit 0))))))
;; Look through all the files in the TEST-DIRECTORY and load them. ;; Look through all the files in the TEST-DIRECTORY and load them.
;; Then run all of the tests. For each file, it ia assumed that a ;; Then run all of the tests. For each file, it ia assumed that a
...@@ -116,7 +132,7 @@ ...@@ -116,7 +132,7 @@
;; pathname-name of the file. ;; pathname-name of the file.
(defun run-all-tests (&key (test-directory #P"tests/") (verbose t)) (defun run-all-tests (&key (test-directory #P"tests/") (verbose t))
(load-test-files test-directory) (load-test-files test-directory)
(print-test-results (run-loaded-tests) :verbose t)) (print-test-results (run-loaded-tests) :verbose t :exitp t))
;;(run-all-tests) ;;(run-all-tests)
;;(quit) ;;(quit)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment