+ (clsql:update-records-from-instance company1)
+ (clsql:update-records-from-instance address1)
+ (clsql:update-records-from-instance address2)
+ ||#
+ )
+
+(defvar *error-count* 0)
+(defvar *error-list* nil)
+
+(defun run-function-append-report-file (function report-file)
+ (let* ((report-path (etypecase report-file
+ (pathname report-file)
+ (string (parse-namestring report-file))))
+ (sexp-report-path (make-pathname :defaults report-path
+ :type "sexp")))
+ (with-open-file (rs report-path :direction :output
+ :if-exists :append
+ :if-does-not-exist :create)
+ (with-open-file (srs sexp-report-path :direction :output
+ :if-exists :append
+ :if-does-not-exist :create)
+ (funcall function :report-stream rs :sexp-report-stream srs)))))
+
+(defun run-tests-append-report-file (report-file)
+ (run-function-append-report-file 'run-tests report-file))
+
+
+(defun run-tests (&key (report-stream *standard-output*) (sexp-report-stream nil))
+ (let ((specs (read-specs))
+ (*report-stream* report-stream)
+ (*sexp-report-stream* sexp-report-stream)
+ (*error-count* 0)
+ (*error-list* nil))
+ (unless specs
+ (warn "Not running tests because test configuration file is missing")
+ (return-from run-tests :skipped))
+ (load-necessary-systems specs)
+ (dolist (db-type +all-db-types+)
+ (dolist (spec (db-type-spec db-type specs))
+ (do-tests-for-backend db-type spec))))
+ (zerop *error-count*))
+
+(defun load-necessary-systems (specs)
+ (dolist (db-type +all-db-types+)
+ (when (db-type-spec db-type specs)
+ (clsql:initialize-database-type :database-type db-type))))
+
+(defun write-report-banner (report-type db-type stream)
+ (format stream
+ "~&
+******************************************************************************
+*** CLSQL ~A begun at ~A
+*** ~A
+*** ~A on ~A
+*** Database ~A backend~A.
+******************************************************************************
+"
+ report-type
+ (clsql:format-time
+ nil
+ (clsql:utime->time (get-universal-time)))
+ (lisp-implementation-type)
+ (lisp-implementation-version)
+ (machine-type)
+ db-type
+ (if (not (eq db-type *test-database-underlying-type*))
+ (format nil " with underlying type ~A"
+ *test-database-underlying-type*)
+ "")
+ ))
+
+(defun do-tests-for-backend (db-type spec)
+ (test-connect-to-database db-type spec)
+
+ (unwind-protect
+ (multiple-value-bind (test-forms skip-tests)
+ (compute-tests-for-backend db-type *test-database-underlying-type*)
+
+ (write-report-banner "Test Suite" db-type *report-stream*)
+
+ (test-initialise-database)
+
+ (regression-test:rem-all-tests)
+ (dolist (test-form test-forms)
+ (eval test-form))
+
+ (let ((remaining (regression-test:do-tests *report-stream*)))
+ (when (regression-test:pending-tests)
+ (incf *error-count* (length remaining))))
+
+ (let ((sexp-error (list db-type
+ *test-database-underlying-type*
+ (get-universal-time)
+ (length test-forms)
+ (regression-test:pending-tests)
+ (lisp-implementation-type)
+ (lisp-implementation-version)
+ (machine-type))))
+ (when *sexp-report-stream*
+ (write sexp-error :stream *sexp-report-stream*))
+ (push sexp-error *error-list*))
+
+ (format *report-stream* "~&Tests skipped:")
+ (if skip-tests
+ (dolist (skipped skip-tests)
+ (format *report-stream*
+ "~& ~20A ~A~%" (car skipped) (cdr skipped)))
+ (format *report-stream* " None~%")))
+ (disconnect)))
+