From 72c5d9d0555b01290409dc2607935db823fa1f10 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sun, 11 Apr 2004 01:34:00 +0000 Subject: [PATCH] r8930: add database-create for pg socket, documentation improvements --- ChangeLog | 13 +++++- classic-tests/README | 24 +++-------- clsql-tests.asd | 3 +- .../postgresql-socket-sql.lisp | 20 +++++---- debian/rules | 2 +- {doc => examples}/clsql-tutorial.lisp | 0 examples/dot.clsql-test.config | 14 ++++++ examples/run-tests.sh | 43 +++++++++++++++++++ tests/README | 10 ++++- tests/test-connection.lisp | 9 ++-- tests/test-fddl.lisp | 11 ++--- tests/test-fdml.lisp | 11 ++--- tests/test-init.lisp | 17 -------- tests/test-ooddl.lisp | 9 ++-- tests/test-oodml.lisp | 9 ++-- 15 files changed, 123 insertions(+), 72 deletions(-) rename {doc => examples}/clsql-tutorial.lisp (100%) create mode 100644 examples/dot.clsql-test.config create mode 100755 examples/run-tests.sh diff --git a/ChangeLog b/ChangeLog index e4f8290..248570e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,8 +6,9 @@ * base/conditions.lisp: Added CLSQL-ACCESS-ERROR * base/utils.lisp: Fix use of position-char. Add COMMAND-OUTPUT used by backends for running - shell commands. - * base/loop-extension.lisp: Rework packages + external programs. Fix parsing of SQL*NET-compatible + connection-specs. + * base/loop-extension.lisp: Simplify package use for Lispworks and Allegro * db-*/*-sql.lisp: Added DATABASE-CREATE, DATABASE-DESTORY, PROBE-DATABASE methods @@ -16,6 +17,14 @@ testing with empty database * tests/test-connection.lisp: Add tests for parsing of string connection-specs + * examples/run-tests.sh: New file for running + test suite on all installed CL implementations + * examples/clsql-tutorial.lisp: moved from + doc directory + * examples/dot.clsql-tests.config: New file + giving an example test configuration + * test/README: Add notes about rtest/ptester + downloads and link to sample test configuration file. 10 Apr 2004 Kevin Rosenberg (kevin@rosenberg.net) * Version 2.5.1 released: diff --git a/classic-tests/README b/classic-tests/README index 3e1b561..4fb0437 100644 --- a/classic-tests/README +++ b/classic-tests/README @@ -1,20 +1,8 @@ -These tests require the setup of a configuration file with account -information for MySQL and PostgreSQL SQL servers. Additionally, the -Debian package acl-installer must be installed and a license -downloaded to use the AODBC tests. - -Furthermore, if you are not using the Debian package of CLSQL, these -tests require the downloading of the rtest and ptester packages from -http://files.b9.com/. - This test suite looks for a configuration file named -".clsql-test.config" located in the users home directory. - -This file contains a single a-list that specifies the connection - specs for each database type to be tested. For example, to test all -platforms, a sample file might look like this: +".clsql-test.config" located in the users home directory. This file +contains a single assoc-list that specifies the connection specs for +each database type to be tested. There is an example file in contained +in CLSQL's examples directory. -((:mysql ("localhost" "a-mysql-db" "user1" "secret")) - (:aodbc ("my-dsn" "a-user" "pass")) - (:postgresql ("localhost" "another-db" "user2" "dont-tell")) - (:postgresql-socket ("pg-server" "a-db-name" "user" "secret-password"))) +These tests require the downloading of the rtest and ptester packages +from http://files.b9.com/. diff --git a/clsql-tests.asd b/clsql-tests.asd index 274e69b..b4cbdb9 100644 --- a/clsql-tests.asd +++ b/clsql-tests.asd @@ -7,13 +7,12 @@ ;;;; Created: 30/03/2004 ;;;; Updated: $Id$ ;;;; -;;;; $Id$ +;;;; 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 #:cl-user) (defpackage #:clsql-tests-system (:use #:asdf #:cl)) diff --git a/db-postgresql-socket/postgresql-socket-sql.lisp b/db-postgresql-socket/postgresql-socket-sql.lisp index 9a2f02d..c304db0 100644 --- a/db-postgresql-socket/postgresql-socket-sql.lisp +++ b/db-postgresql-socket/postgresql-socket-sql.lisp @@ -430,16 +430,20 @@ doesn't depend on UFFI." (defmethod database-create (connection-spec (type (eql :postgresql-socket))) - (error 'clsql-access-error - :connection-spec connection-spec - :database-type type - :error "Unable to create databases on a socket connection.")) + (destructuring-bind (host name user password) connection-spec + (let ((database (database-connect (list host "template1" user password) + type))) + (unwind-protect + (execute-command (format nil "create database ~A" name)) + (database-disconnect database))))) (defmethod database-destroy (connection-spec (type (eql :postgresql-socket))) - (error 'clsql-access-error - :connection-spec connection-spec - :database-type type - :error "Unable to create databases on a socket connection.")) + (destructuring-bind (host name user password) connection-spec + (let ((database (database-connect (list host "template1" user password) + type))) + (unwind-protect + (execute-command (format nil "drop database ~A" name)) + (database-disconnect database))))) (defmethod database-probe (connection-spec (type (eql :postgresql-socket))) (destructuring-bind (host name user password) connection-spec diff --git a/debian/rules b/debian/rules index 81bb0af..ac7c764 100755 --- a/debian/rules +++ b/debian/rules @@ -189,7 +189,7 @@ binary-indep: build install dh_testroot -i # dh_installdebconf -i dh_installdocs -i - dh_installexamples -i + dh_installexamples -i examples dh_installmenu -i # dh_installlogrotate -i # dh_installemacsen -i diff --git a/doc/clsql-tutorial.lisp b/examples/clsql-tutorial.lisp similarity index 100% rename from doc/clsql-tutorial.lisp rename to examples/clsql-tutorial.lisp diff --git a/examples/dot.clsql-test.config b/examples/dot.clsql-test.config new file mode 100644 index 0000000..c6308a1 --- /dev/null +++ b/examples/dot.clsql-test.config @@ -0,0 +1,14 @@ +;; -*- Mode: Lisp -*- ;; Emacs mode line +;; +;; Example CLSQL test configuration file +;; Since this file is read by Lisp, it is okay to use +;; comments in this file +;; This file should be named .clsql-test.config and +;; placed in your home directory + +((:mysql ("localhost" "a-mysql-db" "user1" "secret")) + (:aodbc ("my-dsn" "a-user" "pass")) + (:postgresql ("localhost" "another-db" "user2" "dont-tell")) + (:postgresql-socket ("pg-server" "a-db-name" "user" "secret-password")) + (:sqlite ("path-to-sqlite-db"))) + diff --git a/examples/run-tests.sh b/examples/run-tests.sh new file mode 100755 index 0000000..83a2fc4 --- /dev/null +++ b/examples/run-tests.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# +# Run CLSQL tests on all installed CL implementations +# Need to setup ~/.clsql-tests.config as show in +# tests/test-init.lisp + +CMD='(asdf:operate (quote asdf:test-op) :clsql-classic) + (asdf:operate (quote asdf:test-op) :clsql) + #+allegro (excl:exit :quiet t) + #+clisp (#+lisp=cl ext:quit #-lisp=cl lisp:quit) + #+cmu (ext:quit) + #+lispworks (lw:quit) + #+openmcl (ccl:quit) + #+sbcl (sb-ext:quit)) + #+scl (ext:quit)' + + + +ALLEGRO=alisp +if [ "`which $ALLEGRO`" ]; then + echo "$CMD" | $ALLEGRO +fi + +CMUCL=lisp +if [ "`which $CMUCL`" ]; then + echo "$CMD" | $CMUCL +fi + +LISPWORKS=lw-console +#LISPWORKS=lispworks-4300 +if [ "`which $LISPWORKS`" ]; then + echo "$CMD" | $LISPWORKS +fi + +OPENCML=openmcl +if [ "`which $OPENMCL`" ]; then + echo "$CMD" | $OPENMCL +fi + +SBCL=sbcl +if [ "`which $SBCL`" ]; then + echo "$CMD" | $SBCL +fi diff --git a/tests/README b/tests/README index f93cfa9..aa5bae1 100644 --- a/tests/README +++ b/tests/README @@ -1,7 +1,13 @@ * RUNNING THE REGRESSION SUITE -Create a .clsql-tests.config file in your home directory. -See test-init.lisp for the structure of the data. +This test suite looks for a configuration file named +".clsql-test.config" located in the users home directory. This file +contains a single assoc-list that specifies the connection specs for +each database type to be tested. There is an example file in +contained in CLSQL's examples directory. + +These tests require the downloading of the rtest and ptester packages +from http://files.b9.com/. Load clsql.asd or put it somewhere where ASDF can find it and call: diff --git a/tests/test-connection.lisp b/tests/test-connection.lisp index df91957..f35261e 100644 --- a/tests/test-connection.lisp +++ b/tests/test-connection.lisp @@ -4,13 +4,14 @@ ;;;; Authors: Marcus Pearce , Kevin Rosenberg ;;;; Created: 30/03/2004 ;;;; Updated: $Id$ -;;;; ====================================================================== -;;;; -;;;; Description ========================================================== -;;;; ====================================================================== ;;;; ;;;; Tests for CLSQL database connections. ;;;; +;;;; 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) diff --git a/tests/test-fddl.lisp b/tests/test-fddl.lisp index 918c56f..53fd5c7 100644 --- a/tests/test-fddl.lisp +++ b/tests/test-fddl.lisp @@ -4,14 +4,15 @@ ;;;; Author: Marcus Pearce ;;;; Created: 30/03/2004 ;;;; Updated: $Id$ -;;;; ====================================================================== -;;;; -;;;; Description ========================================================== -;;;; ====================================================================== ;;;; ;;;; Tests for the CLSQL Functional Data Definition Language ;;;; (FDDL). -;;;; +;;;; +;;;; 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) diff --git a/tests/test-fdml.lisp b/tests/test-fdml.lisp index ef364ba..1e2a92b 100644 --- a/tests/test-fdml.lisp +++ b/tests/test-fdml.lisp @@ -4,14 +4,15 @@ ;;;; Author: Marcus Pearce ;;;; Created: 30/03/2004 ;;;; Updated: $Id$ -;;;; ====================================================================== -;;;; -;;;; Description ========================================================== -;;;; ====================================================================== ;;;; ;;;; Tests for the CLSQL Functional Data Manipulation Language ;;;; (FDML). -;;;; +;;;; +;;;; 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) diff --git a/tests/test-init.lisp b/tests/test-init.lisp index 005c247..1a274d9 100644 --- a/tests/test-init.lisp +++ b/tests/test-init.lisp @@ -4,28 +4,11 @@ ;;;; Authors: Marcus Pearce , Kevin Rosenberg ;;;; Created: 30/03/2004 ;;;; Updated: $Id$ -;;;; ====================================================================== -;;;; -;;;; Description ========================================================== -;;;; ====================================================================== ;;;; ;;;; Initialisation utilities for running regression tests on CLSQL. ;;;; ;;;; ====================================================================== -;;; This test suite looks for a configuration file named ".clsql-test.config" -;;; located in the users home directory. -;;; -;;; This file contains a single a-list that specifies the connection -;;; specs for each database type to be tested. For example, to test all -;;; platforms, a sample "test.config" may look like: -;;; -;;; ((:mysql ("localhost" "a-mysql-db" "user1" "secret")) -;;; (:aodbc ("my-dsn" "a-user" "pass")) -;;; (:postgresql ("localhost" "another-db" "user2" "dont-tell")) -;;; (:postgresql-socket ("pg-server" "a-db-name" "user" "secret-password")) -;;; (:sqlite ("path-to-sqlite-db"))) - (in-package #:clsql-tests) (defvar *rt-connection*) diff --git a/tests/test-ooddl.lisp b/tests/test-ooddl.lisp index 7089eba..9883b7a 100644 --- a/tests/test-ooddl.lisp +++ b/tests/test-ooddl.lisp @@ -4,14 +4,15 @@ ;;;; Author: Marcus Pearce ;;;; Created: 30/03/2004 ;;;; Updated: $Id$ -;;;; ====================================================================== -;;;; -;;;; Description ========================================================== -;;;; ====================================================================== ;;;; ;;;; Tests for the CLSQL Object Oriented Data Definition Language ;;;; (OODDL). ;;;; +;;;; 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. ;;;; ====================================================================== diff --git a/tests/test-oodml.lisp b/tests/test-oodml.lisp index cf9eda7..c586726 100644 --- a/tests/test-oodml.lisp +++ b/tests/test-oodml.lisp @@ -4,14 +4,15 @@ ;;;; Author: Marcus Pearce ;;;; Created: 01/04/2004 ;;;; Updated: $Id$ -;;;; ====================================================================== -;;;; -;;;; Description ========================================================== -;;;; ====================================================================== ;;;; ;;;; Tests for the CLSQL Object Oriented Data Definition Language ;;;; (OODML). ;;;; +;;;; 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) -- 2.34.1