X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Frun-tests.lisp;h=68cc941a017277360f3e63ee9febec54733e1b9f;hb=062283b901155792f65775491aea51481c56faaa;hp=80eaf385a4ff8b3bec53fa9a9a381e7bd790db76;hpb=b8a2248d3193902592fb58c5ea74209dc1124f08;p=sbcl.git diff --git a/tests/run-tests.lisp b/tests/run-tests.lisp index 80eaf38..68cc941 100644 --- a/tests/run-tests.lisp +++ b/tests/run-tests.lisp @@ -1,10 +1,5 @@ -#+#.(cl:if (cl:find-package "ASDF") '(or) '(and)) -(load (merge-pathnames "../contrib/asdf/asdf.fasl")) - -#+#.(cl:if (cl:find-package "SB-POSIX") '(or) '(and)) -(let ((asdf:*central-registry* - (cons "../contrib/systems/" asdf:*central-registry*))) - (asdf:oos 'asdf:load-op 'sb-posix)) +(handler-bind (#+win32 (warning #'muffle-warning)) + (require :sb-posix)) (load "test-util.lisp") @@ -15,8 +10,11 @@ (in-package run-tests) +(load "colorize.lisp") + (defvar *all-failures* nil) (defvar *break-on-error* nil) +(defvar *report-skipped-tests* nil) (defvar *accept-files* nil) (defun run-all () @@ -26,6 +24,9 @@ (setf test-util:*break-on-failure* t)) ((string= arg "--break-on-expected-failure") (setf test-util:*break-on-expected-failure* t)) + ((string= arg "--report-skipped-tests") + (setf *report-skipped-tests* t)) + ((string= arg "--no-color")) (t (push (truename (parse-namestring arg)) *accept-files*)))) (pure-runner (pure-load-files) #'load-test) @@ -34,34 +35,53 @@ (impure-runner (impure-cload-files) #'cload-test) #-win32 (impure-runner (sh-files) #'sh-test) (report) - (sb-ext:quit :unix-status (if (unexpected-failures) - 1 - 104))) + (sb-ext:exit :code (if (unexpected-failures) + 1 + 104))) (defun report () (terpri) (format t "Finished running tests.~%") - (cond (*all-failures* - (format t "Status:~%") - (dolist (fail (reverse *all-failures*)) - (cond ((eq (car fail) :unhandled-error) - (format t " ~20a ~a~%" - "Unhandled error" - (enough-namestring (second fail)))) - ((eq (car fail) :invalid-exit-status) - (format t " ~20a ~a~%" - "Invalid exit status:" - (enough-namestring (second fail)))) - (t - (format t " ~20a ~a / ~a~%" - (ecase (first fail) - (:expected-failure "Expected failure:") - (:unexpected-failure "Failure:") - (:unexpected-success "Unexpected success:")) - (enough-namestring (second fail)) - (third fail)))))) - (t - (format t "All tests succeeded~%")))) + (let ((skipcount 0) + (*print-pretty* nil)) + (cond (*all-failures* + (format t "Status:~%") + (dolist (fail (reverse *all-failures*)) + (cond ((eq (car fail) :unhandled-error) + (output-colored-text (car fail) + " Unhandled Error") + (format t " ~a~%" + (enough-namestring (second fail)))) + ((eq (car fail) :invalid-exit-status) + (output-colored-text (car fail) + " Invalid exit status:") + (format t " ~a~%" + (enough-namestring (second fail)))) + ((eq (car fail) :skipped-disabled) + (when *report-skipped-tests* + (format t " ~20a ~a / ~a~%" + "Skipped (irrelevant):" + (enough-namestring (second fail)) + (third fail))) + (incf skipcount)) + (t + (output-colored-text + (first fail) + (ecase (first fail) + (:expected-failure " Expected failure:") + (:unexpected-failure " Failure:") + (:leftover-thread " Leftover thread (broken):") + (:unexpected-success " Unexpected success:") + (:skipped-broken " Skipped (broken):") + (:skipped-disabled " Skipped (irrelevant):"))) + (format t " ~a / ~a~%" + (enough-namestring (second fail)) + (third fail))))) + (when (> skipcount 0) + (format t " (~a tests skipped for this combination of platform and features)~%" + skipcount))) + (t + (format t "All tests succeeded~%"))))) (defun pure-runner (files test-fun) (format t "// Running pure tests (~a)~%" test-fun) @@ -78,32 +98,24 @@ (append-failures))) (defun run-in-child-sbcl (load-forms forms) - (declare (ignorable load-forms)) - #-win32 - (let ((pid (sb-posix:fork))) - (cond ((= pid 0) - (dolist (form forms) - (eval form))) - (t - (let ((status (make-array 1 :element-type '(signed-byte 32)))) - (sb-posix:waitpid pid 0 status) - (if (sb-posix:wifexited (aref status 0)) - (sb-posix:wexitstatus (aref status 0)) - 1))))) - #+win32 + ;; We used to fork() for POSIX platforms, and use this for Windows. + ;; However, it seems better to use the same solution everywhere. (process-exit-code - (sb-ext:run-program - (first *POSIX-ARGV*) - (append - (list "--core" SB-INT:*CORE-STRING* - "--noinform" - "--no-sysinit" - "--no-userinit") - (loop for form in (append load-forms forms) - collect "--eval" - collect (write-to-string form))) - :output sb-sys:*stdout* - :input sb-sys:*stdin*))) + (#-win32 with-open-file #-win32 (devnull "/dev/null") #+win32 progn + (sb-ext:run-program + (first *POSIX-ARGV*) + (append + (list "--core" SB-INT:*CORE-STRING* + "--noinform" + "--no-sysinit" + "--no-userinit" + "--noprint" + "--disable-debugger") + (loop for form in (append load-forms forms) + collect "--eval" + collect (write-to-string form))) + :output sb-sys:*stdout* + :input #-win32 devnull #+win32 sb-sys:*stdin*)))) (defun run-impure-in-child-sbcl (test-file test-code) (run-in-child-sbcl @@ -120,23 +132,25 @@ ,test-util:*break-on-expected-failure*) (let ((file ,test-file) (*break-on-error* ,run-tests::*break-on-error*)) + (declare (special *break-on-error*)) (format t "// Running ~a~%" file) (restart-case (handler-bind ((error (lambda (condition) - (push (list :unhandled-error cl-user::file) test-util::*failures*) + (push (list :unhandled-error file) + test-util::*failures*) (cond (*break-on-error* (test-util:really-invoke-debugger condition)) (t (format *error-output* "~&Unhandled ~a: ~a~%" (type-of condition) condition) - (funcall (symbol-function (intern "BACKTRACE" :sb-debug))))) + (sb-debug:print-backtrace))) (invoke-restart 'skip-file)))) ,test-code) (skip-file () (format t ">>>~a<<<~%" test-util::*failures*))) (test-util:report-test-status) - (sb-ext:quit :unix-status 104))))) + (sb-ext:exit :code 104))))) (defun impure-runner (files test-fun) (format t "// Running impure tests (~a)~%" test-fun) @@ -163,7 +177,7 @@ (t (format *error-output* "~&Unhandled ~a: ~a~%" (type-of condition) condition) - (sb-debug:backtrace))) + (sb-debug:print-backtrace))) (invoke-restart 'skip-file))) (defun append-failures (&optional (failures *failures*)) @@ -172,7 +186,9 @@ (defun unexpected-failures () (remove-if (lambda (x) (or (eq (car x) :expected-failure) - (eq (car x) :unexpected-success))) + (eq (car x) :unexpected-success) + (eq (car x) :skipped-broken) + (eq (car x) :skipped-disabled))) *all-failures*)) (defun setup-cl-user () @@ -194,9 +210,11 @@ (defun sh-test (file) ;; What? No SB-POSIX:EXECV? `(let ((process (sb-ext:run-program "/bin/sh" - (list (namestring ,file)) + (list (native-namestring ,file)) :output *error-output*))) - (sb-ext:quit :unix-status (process-exit-code process)))) + (let ((*failures* nil)) + (test-util:report-test-status)) + (sb-ext:exit :code (process-exit-code process)))) (defun accept-test-file (file) (if *accept-files*