make it possible to run tests on an installed SBCL
authorFrancois-Rene Rideau <fare@tunes.org>
Sat, 14 Apr 2012 16:09:46 +0000 (12:09 -0400)
committerNikodemus Siivola <nikodemus@random-state.net>
Sun, 7 Oct 2012 12:15:25 +0000 (15:15 +0300)
 Allow override of SBCL location via TEST_SBCL_HOME,
 TEST_SBCL_RUNTIME, and TEST_SBCL_CORE.

 Allow override of temporary file location via TEST_DIRECTORY. (Some
 tests still write to /tmp, though -- so user beware!)

 Small unrelated whitespace / style-warning fixes.

tests/load.impure.lisp
tests/run-tests.lisp
tests/subr.sh

index bdc4116..6219374 100644 (file)
 
 ;;; As reported by David Tolpin *LOAD-PATHNAME* was not merged.
 (progn
-  (defvar *saved-load-pathname*)
+  (defparameter *saved-load-pathname* nil)
   (with-open-file (s *tmp-filename*
                      :direction :output
                      :if-exists :supersede
                      :if-does-not-exist :create)
     (print '(setq *saved-load-pathname* *load-pathname*) s))
-  (let (tmp-fasl)
-    (unwind-protect
-         (progn
-           (load *tmp-filename*)
-           (assert (equal (merge-pathnames *tmp-filename*) *saved-load-pathname*)))
-      (delete-file *tmp-filename*))))
+  (unwind-protect
+       (progn
+         (load *tmp-filename*)
+         (assert (equal (merge-pathnames *tmp-filename*) *saved-load-pathname*)))
+    (delete-file *tmp-filename*)))
 \f
 ;;; Test many, many variations on LOAD.
 (defparameter *counter* 0)
                                        :if-exists :append)
       (write-line ";;comment"))
     (handler-bind ((error (lambda (error)
-                                   (declare (ignore error))
-                                   (when (find-restart 'sb-fasl::source)
-                                     (invoke-restart 'sb-fasl::source)))))
+                            (declare (ignore error))
+                            (when (find-restart 'sb-fasl::source)
+                              (invoke-restart 'sb-fasl::source)))))
       (load-and-assert spec source source))))
 
 ;; Ensure that we can invoke the restart OBJECT in the above case.
                                        :if-exists :append)
       (write-line ";;comment"))
     (handler-bind ((error (lambda (error)
-                                   (declare (ignore error))
-                                   (when (find-restart 'sb-fasl::object)
-                                     (invoke-restart 'sb-fasl::object)))))
+                            (declare (ignore error))
+                            (when (find-restart 'sb-fasl::object)
+                              (invoke-restart 'sb-fasl::object)))))
       (load-and-assert spec fasl fasl))))
 
 (with-test (:name :bug-332 :fails-on :win32)
   (flet ((stimulate-sbcl ()
-           (let ((filename (format nil "/tmp/~A.lisp" (gensym))))
+           (let ((filename
+                  (format nil "~A/~A.lisp"
+                          (or (posix-getenv "TEST_DIRECTORY")
+                              (posix-getenv "TMPDIR")
+                              "/tmp")
+                          (gensym))))
+             (ensure-directories-exist filename)
              ;; create a file which redefines a structure incompatibly
              (with-open-file (f filename :direction :output :if-exists :supersede)
                (print '(defstruct bug-332 foo) f)
index 5b27987..b67497e 100644 (file)
@@ -1,11 +1,9 @@
 #+#.(cl:if (cl:find-package "ASDF") '(or) '(and))
-(load (merge-pathnames "../contrib/asdf/asdf.fasl"))
+(require :asdf)
 
 #+#.(cl:if (cl:find-package "SB-POSIX") '(or) '(and))
-(let ((asdf:*central-registry*
-       (cons "../contrib/systems/" asdf:*central-registry*)))
-  (handler-bind (#+win32 (warning #'muffle-warning))
-    (asdf:oos 'asdf:load-op 'sb-posix)))
+(handler-bind (#+win32 (warning #'muffle-warning))
+  (require :sb-posix))
 
 (load "test-util.lisp")
 
index 84ee1a4..8980035 100644 (file)
@@ -26,16 +26,17 @@ set -u
 set -a # export all variables at assignment-time.
 # Note: any script that uses the variables that name files should
 # quote them (with double quotes), to contend with whitespace.
-SBCL_HOME="$SBCL_PWD/../contrib"
-SBCL_CORE="$SBCL_PWD/../output/sbcl.core"
-SBCL_RUNTIME="$SBCL_PWD/../src/runtime/sbcl"
-SBCL_ARGS="--noinform --no-sysinit --no-userinit --noprint --disable-debugger"
+SBCL_HOME="${TEST_SBCL_HOME:-$SBCL_PWD/../contrib}"
+SBCL_CORE="${TEST_SBCL_CORE:-$SBCL_PWD/../output/sbcl.core}"
+SBCL_RUNTIME="${TEST_SBCL_RUNTIME:-$SBCL_PWD/../src/runtime/sbcl}"
+SBCL_ARGS="${TEST_SBCL_ARGS:---noinform --no-sysinit --no-userinit --noprint --disable-debugger}"
 
 # Scripts that use these variables should quote them.
 TEST_BASENAME="`basename $0`"
-TEST_FILESTEM="`basename "${TEST_BASENAME}" | sed 's/\.sh$//'`"
-TEST_FILESTEM="`echo "${TEST_FILESTEM}" | sed 's/\./-/g'`"
-TEST_DIRECTORY="$SBCL_PWD/$TEST_FILESTEM-$$"
+TEST_FILESTEM="$(basename "${TEST_BASENAME}" | sed 's/\.sh$// ; s/\./-/g')"
+: ${TEST_BASEDIR:="$SBCL_PWD"}
+TEST_DIRECTORY="${TEST_BASEDIR}/${TEST_FILESTEM}-$$"
+export TEST_DIRECTORY
 
 # "Ten four" is the closest numerical slang I can find to "OK", so
 # it's the Unix status value that we expect from a successful test.