Commit 881b14ad authored by Juergen Nickelsen's avatar Juergen Nickelsen
Browse files

fixed the test runner, which still assumed dynamic scope

So that was the thing that broke proper error handling in the test runner:
a test fail file triggered a (real) error in the test runner, because
the variable test-file, assumed to contain the name of the file under
test, was undefined. Fixed by making that a global defvar'ed variable,
which then can be accessed -- through the lexical environment, yay! --
by the testcmp function.
parent 28a17f34
......@@ -4,6 +4,7 @@
(defvar out t)
(defvar fails nil)
(defvar ntests 0)
(defvar *current-test-file* nil "the test file currently running")
(defun testcmp (name form value)
"Run the test called NAME and print the result.
......@@ -17,13 +18,13 @@ the evaluation of FORM and VALUE are equal."
(if (atom result)
(progn (format out "Test FAIL: %s RAISED ERROR: %s\n"
name *last-error*)
(setq fails (cons (cons name test-file) fails)))
(setq fails (cons (cons name *current-test-file*) fails)))
(let ((resultvalue (princs (car result))))
(if (eq resultvalue target)
(format out "Test pass: %s\t%s\n" name resultvalue)
(format out "Test FAIL: %s\n calculated: %s\n expected: %s\n"
name resultvalue target)
(setq fails (cons (cons name test-file) fails)))))))
(setq fails (cons (cons name *current-test-file*) fails)))))))
(testcmp 'testcmp ''lala "lala") ;check if the *testing* works
......@@ -31,10 +32,10 @@ the evaluation of FORM and VALUE are equal."
"/[0-9]*.lisp")))))
(format t "load files: %s\n" (princs files))
(while files
(let ((test-file (car files)))
(setq files (cdr files))
(format out "\nloading %s\n" test-file)
(load test-file))))
(setq *current-test-file* (car files))
(setq files (cdr files))
(format out "\nloading %s\n" *current-test-file*)
(load *current-test-file*)))
(format t "%d tests, %d FAILS" ntests (length fails))
(let ((rfails (reverse fails)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment