r8954: check for any errors and report
[clsql.git] / tests / test-init.lisp
index 1a274d918ef108621617f2d5a7cded81973348f5..1d41ea78df83d46eeae17746f7701a62fac430d7 100644 (file)
   (clsql:update-records-from-instance employee10)
   (clsql:update-records-from-instance company1))
 
+(defvar *error-count* 0)
+
 (defun run-tests ()
-  (let ((specs (read-specs)))
+  (let ((specs (read-specs))
+       (*error-count* 0))
     (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+)
       (let ((spec (db-type-spec db-type specs)))
        (when spec
-         (format t 
-"~&
+         (do-tests-for-backend spec db-type))))
+    (zerop *error-count*)))
+
+(defun load-necessary-systems (specs)
+  (dolist (db-type +all-db-types+)
+    (when (db-type-spec db-type specs)
+      (db-type-ensure-system db-type))))
+
+(defun do-tests-for-backend (spec db-type)
+  (format t 
+         "~&
 *******************************************************************
 ***     Running CLSQL tests with ~A backend.
 *******************************************************************
 " db-type)
-         (db-type-ensure-system db-type)
-         (regression-test:rem-all-tests)
-         (ignore-errors (destroy-database spec :database-type db-type))
-         (ignore-errors (create-database spec :database-type db-type))
-         (dolist (test (append *rt-connection* *rt-fddl* *rt-fdml*
-                               *rt-ooddl* *rt-oodml* *rt-syntax*))
-           (eval test))
-         (test-connect-to-database db-type spec)
-         (test-initialise-database)
-         (rtest:do-tests))))))
+  (regression-test:rem-all-tests)
+  
+  ;; Tests of clsql-base
+  (ignore-errors (destroy-database spec :database-type db-type))
+  (ignore-errors (create-database spec :database-type db-type))
+  (with-tests (:name "CLSQL")
+    (test-basic spec db-type))
+  (incf *error-count* *test-errors*)
+
+  (ignore-errors (destroy-database spec :database-type db-type))
+  (ignore-errors (create-database spec :database-type db-type))
+  (dolist (test (append *rt-connection* *rt-fddl* *rt-fdml*
+                       *rt-ooddl* *rt-oodml* *rt-syntax*))
+    (eval test))
+  (test-connect-to-database db-type spec)
+  (test-initialise-database)
+  (let ((remaining (rtest:do-tests)))
+    (when (consp remaining)
+      (incf *error-count* (length remaining)))))
+