Rework initialize-instance for view-class-direct-slot-definition
[clsql/s11.git] / tests / utils.lisp
blobca7accbd0ede1b6ccfff2d29aefc21a450f71928
1 ;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name: utils.lisp
6 ;;;; Purpose: Classes and utilities for testing
7 ;;;; Author: Kevin M. Rosenberg
8 ;;;; Created: Mar 2002
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
13 ;;;;
14 ;;;; CLSQL users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
19 (in-package #:clsql-tests)
21 (defvar *config-pathname*
22 (make-pathname :defaults (user-homedir-pathname)
23 :name ".clsql-test"
24 :type "config"))
26 (defvar +all-db-types+
27 '(:postgresql :postgresql-socket :mysql :sqlite :sqlite3 :odbc :oracle
28 #+allegro :aodbc))
30 (defclass conn-specs ()
31 ((aodbc :accessor aodbc-spec :initform nil)
32 (mysql :accessor mysql-spec :initform nil)
33 (postgresql :accessor postgresql-spec :initform nil)
34 (postgresql-socket :accessor postgresql-socket-spec :initform nil)
35 (sqlite :accessor sqlite-spec :initform nil)
36 (sqlite3 :accessor sqlite3-spec :initform nil)
37 (odbc :accessor odbc-spec :initform nil)
38 (oracle :accessor oracle-spec :initform nil))
39 (:documentation "Connection specs for CLSQL testing"))
42 (defun read-specs (&optional (path *config-pathname*))
43 (if (probe-file path)
44 (with-open-file (stream path :direction :input)
45 (let ((specs (make-instance 'conn-specs)))
46 (dolist (spec (read stream) specs)
47 (push (second spec)
48 (slot-value specs (intern (symbol-name (first spec))
49 (find-package '#:clsql-tests)))))))
50 (progn
51 (warn "CLSQL test config file ~S not found" path)
52 nil)))
54 (defun spec-fn (db-type)
55 (intern (concatenate 'string (symbol-name db-type)
56 (symbol-name '#:-spec))
57 (find-package '#:clsql-tests)))
59 (defun db-type-spec (db-type specs)
60 (funcall (spec-fn db-type) specs))
63 (defun summarize-test-report (sexp &optional (output *standard-output*))
64 (flet ((db-title (db-type underlying-db-type)
65 (format nil "~A~A"
66 db-type
67 (if (eq db-type underlying-db-type)
69 (format nil "/~A" underlying-db-type)))))
70 (with-open-file (in sexp :direction :input)
71 (let ((eof (cons nil nil)))
72 (do ((form (read in nil eof) (read in nil eof)))
73 ((eq form eof))
74 (destructuring-bind (db-type
75 underlying-db-type
76 utime
77 total-tests
78 failed-tests
79 impl-type
80 impl-version
81 machine-type)
82 form
83 (declare (ignorable utime impl-version))
84 (if failed-tests
85 (format output "~&~A: ~D of ~D tests failed (~A, ~A).~&"
86 (db-title db-type underlying-db-type)
87 (length failed-tests)
88 total-tests
89 machine-type
90 impl-type)
91 (format output "~&~A: All ~D tests passed (~A, ~A).~%"
92 (db-title db-type underlying-db-type)
93 total-tests
94 machine-type
95 impl-type))))))))