Changeset 13297


Ignore:
Timestamp:
05/25/11 14:32:07 (10 years ago)
Author:
Mark Evenson
Message:

Add LOAD-TESTS to load ANSI tests without actually executing them.

Refactor code into separate CLEAN-TEST and VERIFY-ANSI-TEST which
facilitates interactive use of the package.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/test/lisp/ansi/package.lisp

    r12811 r13297  
    1 (defpackage :abcl.test.ansi
    2   (:use :cl :asdf)
    3   (:nicknames "ansi-tests" "abcl-ansi-tests" "gcl-ansi")
    4   (:export :run :report :parse))
     1(defpackage #:abcl.test.ansi
     2  (:use :cl :cl-user)
     3  (:nicknames #:ansi-tests #:abcl-ansi-tests #:gcl-ansi)
     4  (:export #:run
     5     #:verify-ansi-tests
     6     #:load-tests
     7     #:clean-tests
     8     #:report #:parse))
    59
    610(in-package :abcl.test.ansi)
     
    1115(defparameter *ansi-tests-directory*
    1216  (if (find :asdf2 *features*)
    13       (asdf:system-relative-pathname
    14        :ansi-compiled "../ansi-tests/")
    15       (merge-pathnames
    16        #p"../ansi-tests/"
    17        (asdf:component-pathname (asdf:find-system :ansi-compiled)))))
     17      (asdf:system-relative-pathname :ansi-compiled "../ansi-tests/")
     18      (merge-pathnames #p"../ansi-tests/"
     19           (asdf:component-pathname
     20      (asdf:find-system :ansi-compiled)))))
    1821
    1922(defun run (&key (compile-tests nil))
    2023  "Run the ANSI-TESTS suite, to be found in *ANSI-TESTS-DIRECTORY*.
    2124Possibly running the compiled version of the tests if COMPILE-TESTS is non-NIL."
     25  (verify-ansi-tests)
    2226  (let* ((ansi-tests-directory
    2327    *ansi-tests-directory*)
     
    2529    (if compile-tests "compileit.lsp" "doit.lsp"))
    2630   (message
    27     (format nil "Invocation of '~A' in ~A" boot-file ansi-tests-directory)))
    28     (handler-case
    29   (progv
    30       '(*default-pathname-defaults*)
    31       `(,(merge-pathnames *ansi-tests-directory* *default-pathname-defaults*))
     31    (format nil "Invocation of '~A' in ~A"
     32      boot-file ansi-tests-directory)))
     33    (progv
     34  '(*default-pathname-defaults*)
     35  `(,(merge-pathnames *ansi-tests-directory*
     36          *default-pathname-defaults*))
    3237    (format t "--->  ~A begins.~%" message)
    3338    (format t "Invoking ABCL hosted on ~A ~A.~%"
    3439      (software-type) (software-version))
    35           ;; Do what 'make clean' would do from the GCL ANSI tests,
    36           ;; so we don't have to hunt for 'make' on win32.
    37           (mapcar #'delete-file
    38                   (append (directory (format nil "~A/*.cls" *default-pathname-defaults*))
    39                           (directory (format nil "~A/*.abcl" *default-pathname-defaults*))
    40                           (directory (format nil "~A/scratch/*" *default-pathname-defaults*))
    41                           (mapcar (lambda(x) (format nil "~A/~A" *default-pathname-defaults* x))
    42                                   '("scratch/"
    43                                     "scratch.txt" "foo.txt" "foo.lsp"
    44                                     "foo.dat"
    45                                     "tmp.txt" "tmp.dat" "tmp2.dat"
    46                                     "temp.dat" "out.class"
    47                                     "file-that-was-renamed.txt"
    48                                     "compile-file-test-lp.lsp"
    49                                     "compile-file-test-lp.out"
    50                                     "ldtest.lsp"))))
    5140    (time (load boot-file))
    52     (format t "<--- ~A ends.~%" message))
    53       (file-error (e)
    54     (error
    55      (format nil
    56        "Failed to find the GCL ANSI tests in '~A'.
    57 Because ~A.
    58 To resolve, please locally obtain ~A,
    59 and set the value of *ANSI-TESTS-DIRECTORY* to that location."
    60      ansi-tests-directory e
    61      *ansi-tests-master-source-location*))))))
     41    (format t "<--- ~A ends.~%" message))))
     42
     43(defun verify-ansi-tests ()
     44  (unless
     45      (probe-file *ansi-tests-directory*)
     46    (error 'file-error
     47     "Failed to find the GCL ANSI tests in '~A'. Please
     48locally obtain ~A, and set the value of *ANSI-TESTS-DIRECTORY* to that
     49location." 
     50       *ansi-tests-directory*
     51       *ansi-tests-master-source-location*)))
     52
     53(defvar *ansi-tests-loaded-p* nil)
     54(defun load-tests ()
     55  "Load the ANSI tests but do not execute them."
     56  (verify-ansi-tests)
     57  (let ((*default-pathname-defaults* *ansi-tests-directory*)
     58  (package *package*))
     59    (setf *package* (find-package :cl-user))
     60    (load "gclload1.lsp")
     61    (load "gclload2.lsp")
     62    (setf *package* package))
     63  (setf *ansi-tests-loaded-p* t))
     64 
     65(defun clean-tests ()
     66  "Do what 'make clean' would do from the GCL ANSI tests,"
     67  ;; so we don't have to hunt for 'make' in the PATH on win32.
     68  (verify-ansi-tests)
     69
     70  (mapcar #'delete-file
     71    (append (directory (format nil "~A/*.cls" *ansi-tests-directory*))
     72      (directory (format nil "~A/*.abcl" *ansi-tests-directory*))
     73      (directory (format nil "~A/scratch/*" *ansi-tests-directory*))
     74      (mapcar (lambda(x)
     75          (format nil "~A/~A" *ansi-tests-directory* x))
     76        '("scratch/"
     77          "scratch.txt" "foo.txt" "foo.lsp"
     78          "foo.dat"
     79          "tmp.txt" "tmp.dat" "tmp2.dat"
     80          "temp.dat" "out.class"
     81          "file-that-was-renamed.txt"
     82          "compile-file-test-lp.lsp"
     83          "compile-file-test-lp.out"
     84          "ldtest.lsp")))))
    6285
    6386       
Note: See TracChangeset for help on using the changeset viewer.