1 ;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: Classes and utilities for testing
7 ;;;; Author: Kevin M. Rosenberg
10 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2010 by Kevin M. Rosenberg
12 ;;;; CLSQL users are granted the rights to distribute and use this software
13 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
14 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
15 ;;;; *************************************************************************
17 (in-package #:clsql-tests)
19 (defvar *config-pathname*
20 (make-pathname :defaults (user-homedir-pathname)
24 (defvar +all-db-types+
25 '(:postgresql :postgresql-socket :mysql :sqlite :sqlite3 :odbc :oracle
28 (defclass conn-specs ()
29 ((aodbc :accessor aodbc-spec :initform nil)
30 (mysql :accessor mysql-spec :initform nil)
31 (postgresql :accessor postgresql-spec :initform nil)
32 (postgresql-socket :accessor postgresql-socket-spec :initform nil)
33 (sqlite :accessor sqlite-spec :initform nil)
34 (sqlite3 :accessor sqlite3-spec :initform nil)
35 (odbc :accessor odbc-spec :initform nil)
36 (oracle :accessor oracle-spec :initform nil))
37 (:documentation "Connection specs for CLSQL testing"))
40 (defun read-specs (&optional (path *config-pathname*))
42 (with-open-file (stream path :direction :input)
43 (let ((specs (make-instance 'conn-specs)))
44 (dolist (spec (read stream) specs)
46 (slot-value specs (intern (symbol-name (first spec))
47 (find-package '#:clsql-tests)))))))
49 (warn "CLSQL test config file ~S not found" path)
52 (defun spec-fn (db-type)
53 (intern (concatenate 'string (symbol-name db-type)
54 (symbol-name '#:-spec))
55 (find-package '#:clsql-tests)))
57 (defun db-type-spec (db-type specs)
58 (funcall (spec-fn db-type) specs))
61 (defun summarize-test-report (sexp &optional (output *standard-output*))
62 (flet ((db-title (db-type underlying-db-type)
65 (if (eq db-type underlying-db-type)
67 (format nil "/~A" underlying-db-type)))))
68 (with-open-file (in sexp :direction :input)
69 (let ((eof (cons nil nil)))
70 (do ((form (read in nil eof) (read in nil eof)))
72 (destructuring-bind (db-type
81 (declare (ignorable utime impl-version))
83 (format output "~&~A: ~D of ~D tests failed (~A, ~A).~&"
84 (db-title db-type underlying-db-type)
89 (format output "~&~A: All ~D tests passed (~A, ~A).~%"
90 (db-title db-type underlying-db-type)