X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tests%2Ftest-init.lisp;h=0584762d725f87b01df3f307c4069a8b80cb3cd9;hb=23b76563b25a517ad20f29d6dc5a65c8b958a042;hp=0f4180ab4d3d301a459e8f2bc57ac78851f5e017;hpb=cd64aa8907160d3a2c2d0e531c831f1db44c7a61;p=clsql.git diff --git a/tests/test-init.lisp b/tests/test-init.lisp index 0f4180a..0584762 100644 --- a/tests/test-init.lisp +++ b/tests/test-init.lisp @@ -7,6 +7,11 @@ ;;;; ;;;; Initialisation utilities for running regression tests on CLSQL. ;;;; +;;;; This file is part of CLSQL. +;;;; +;;;; CLSQL users are granted the rights to distribute and use this software +;;;; as governed by the terms of the Lisp Lesser GNU Public License +;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ====================================================================== (in-package #:clsql-tests) @@ -17,8 +22,10 @@ (defvar *rt-ooddl*) (defvar *rt-oodml*) (defvar *rt-syntax*) +(defvar *rt-time*) (defvar *test-database-type* nil) +(defvar *test-database-underlying-type* nil) (defvar *test-database-user* nil) (defclass thing () @@ -122,13 +129,12 @@ (clsql:connect spec :database-type database-type :make-default t - :if-exists :old)) + :if-exists :old) + + (setf *test-database-underlying-type* + (clsql-sys:database-underlying-type *default-database*)) -(defmacro with-ignore-errors (&rest forms) - `(progn - ,@(mapcar - (lambda (x) (list 'ignore-errors x)) - forms))) + *default-database*) (defparameter company1 nil) (defparameter employee1 nil) @@ -143,10 +149,10 @@ (defparameter employee10 nil) (defun test-initialise-database () - ;; Create the tables for our view classes - (ignore-errors - (clsql:drop-view-from-class 'employee) - (clsql:drop-view-from-class 'company)) + ;; Remove the tables to support cases when destroy-database isn't supported, like odbc + (ignore-errors (clsql:drop-table "EMPLOYEE")) + (ignore-errors (clsql:drop-table "COMPANY")) + (ignore-errors (clsql:drop-table "FOO")) (clsql:create-view-from-class 'employee) (clsql:create-view-from-class 'company) @@ -319,12 +325,39 @@ (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)) + (when (db-backend-has-create/destroy-db? db-type) + (ignore-errors (destroy-database spec :database-type db-type)) + (ignore-errors (create-database spec :database-type db-type))) + (test-connect-to-database db-type spec) + + (dolist (test-form (append *rt-connection* *rt-fddl* *rt-fdml* + *rt-ooddl* *rt-oodml* *rt-syntax*)) + (let ((test (second test-form))) + (cond + ((and (null (db-type-has-views? *test-database-underlying-type*)) + (clsql-base-sys::in test :fddl/view/1 :fddl/view/2 :fddl/view/3 :fddl/view/4)) + ;; skip test + ) + ((and (null (db-type-has-boolean-where? *test-database-underlying-type*)) + (clsql-base-sys::in test :fdml/select/11 :oodml/select/5)) + ;; skip tests + ) + ((and (null (db-type-has-subqueries? *test-database-underlying-type*)) + (clsql-base-sys::in test :fdml/select/5 :fdml/select/10)) + ;; skip tests + ) + ((and (null (db-type-transaction-capable? *test-database-underlying-type* *default-database*)) + (clsql-base-sys::in test :fdml/transaction/1 :fdml/transaction/2 :fdml/transaction/3 :fdml/transaction/4)) + ;; skip tests + ) + ((and (eql *test-database-type* :sqlite) + (clsql-base-sys::in test :fddl/view/4 :fdml/select/10)) + ;; skip tests + ) + (t + (eval test-form))))) + (test-initialise-database) (let ((remaining (rtest:do-tests))) (when (consp remaining)