| 1 |
;;;; -*- Mode: Lisp; Syntax: Common-Lisp; indent-tabs-mode: nil -*- |
| 2 |
;;;; vim: set filetype=lisp tabstop=8 shiftwidth=2 expandtab: |
| 3 |
|
| 4 |
;;; |
| 5 |
;;; (c) 2011, Juan Jose Garcia-Ripoll |
| 6 |
;;; (c) 2016, Daniel Kochmański |
| 7 |
;;; |
| 8 |
;;; Set up the test environment. |
| 9 |
;;; |
| 10 |
|
| 11 |
(defpackage :ecl-tests |
| 12 |
(:use :cl)) |
| 13 |
|
| 14 |
(in-package :ecl-tests) |
| 15 |
|
| 16 |
(setf *load-verbose* nil *load-print* nil) |
| 17 |
|
| 18 |
(defvar *ecl-sources* |
| 19 |
(loop for *default-pathname-defaults* in |
| 20 |
'(#p"@true_srcdir@/" #p"../../" #p"../../src/") |
| 21 |
when (probe-file "configure.ac") |
| 22 |
return *default-pathname-defaults*)) |
| 23 |
|
| 24 |
(setf *ecl-sources* (truename *ecl-sources*)) |
| 25 |
|
| 26 |
(defvar *here* (merge-pathnames "@builddir@/")) |
| 27 |
(defvar *cache* (merge-pathnames "./cache/" *here*)) |
| 28 |
|
| 29 |
(defvar *test-image* |
| 30 |
(or (ext:getenv "TEST_IMAGE") |
| 31 |
#+windows (namestring (truename "sys:ecl.exe")) |
| 32 |
#-windows "@prefix@/bin/ecl")) |
| 33 |
|
| 34 |
#+ecl |
| 35 |
(ext:setenv "ECLDIR" (namestring (truename "SYS:"))) |
| 36 |
|
| 37 |
(defvar *test-name* (or (ext:getenv "TEST_NAME") "ecl")) |
| 38 |
(defvar *sandbox* (merge-pathnames "temporary/" *here*)) |
| 39 |
|
| 40 |
(defun lisp-system-directory () |
| 41 |
(loop with root = (si::get-library-pathname) |
| 42 |
with lib-name = (format nil "../lib/ecl-~A/" (lisp-implementation-version)) |
| 43 |
for base in (list root (merge-pathnames lib-name root)) |
| 44 |
when (or (probe-file (merge-pathnames "./BUILD-STAMP" base)) |
| 45 |
(probe-file (merge-pathnames "./COPYING" base))) |
| 46 |
do (return base))) |
| 47 |
|
| 48 |
(setf (logical-pathname-translations "SYS") |
| 49 |
(list (list #p"sys:**;*.*" |
| 50 |
(merge-pathnames "**/*.*" |
| 51 |
(lisp-system-directory))))) |
| 52 |
|
| 53 |
;;; |
| 54 |
;;; PREPARATION OF DIRECTORIES AND FILES |
| 55 |
;;; |
| 56 |
(defun delete-everything (path) |
| 57 |
;; Recursively run through children |
| 58 |
(labels ((recursive-deletion (path) |
| 59 |
(mapc #'delete-everything |
| 60 |
(directory (merge-pathnames |
| 61 |
(make-pathname :name nil |
| 62 |
:type nil |
| 63 |
:directory '(:relative :wild) |
| 64 |
:defaults path) |
| 65 |
path))) |
| 66 |
;; Delete files |
| 67 |
(loop for f in (directory (make-pathname :name :wild |
| 68 |
:type :wild |
| 69 |
:defaults path)) |
| 70 |
do (delete-file f) |
| 71 |
finally (delete-file path)))) |
| 72 |
(and (probe-file path) |
| 73 |
(recursive-deletion path)))) |
| 74 |
|
| 75 |
;;; |
| 76 |
;;; RUNNING TESTS |
| 77 |
;;; |
| 78 |
(defun run-tests (suites |
| 79 |
&aux (suites (cond |
| 80 |
((null suites) "make-check") |
| 81 |
((null (cdr suites)) (car suites)) |
| 82 |
(T suites)))) |
| 83 |
;; Cleanup stray files |
| 84 |
(delete-everything *sandbox*) |
| 85 |
(ensure-directories-exist *sandbox*) |
| 86 |
(unwind-protect |
| 87 |
(progn |
| 88 |
(ext:chdir *sandbox*) |
| 89 |
(ext:setenv "TEST_IMAGE" *test-image*) |
| 90 |
(ext:run-program |
| 91 |
*test-image* |
| 92 |
`("-norc" |
| 93 |
"-eval" "(print (ext:getenv \"ECLDIR\"))" |
| 94 |
"-eval" "(ext:install-bytecodes-compiler)" |
| 95 |
"-eval" ,(if (ext:getenv "BYTECMP") |
| 96 |
"t" |
| 97 |
"(ignore-errors (ext:install-c-compiler))") |
| 98 |
"-load" ,(namestring |
| 99 |
(merge-pathnames |
| 100 |
"tests/doit.lsp" *ecl-sources*)) |
| 101 |
"-eval" "(in-package cl-test)" |
| 102 |
"-eval" ,(format nil "(2am-ecl:run '~a)" suites) |
| 103 |
"-eval" "(ext:exit)") |
| 104 |
:input nil |
| 105 |
:output t |
| 106 |
:error :output)) |
| 107 |
(ext:chdir *here*) |
| 108 |
#+ (or) |
| 109 |
(format t "~%Known fails: ~%~{~a~%~}~%" |
| 110 |
'(SEM-SIGNAL-N-PROCESSES |
| 111 |
SEM-SIGNAL-ONLY-N-PROCESSES)))) |
| 112 |
|
| 113 |
;;; |
| 114 |
;;; RUNNING ANSI-TEST |
| 115 |
;;; |
| 116 |
(defun run-ansi-test (&optional (suite (ext:getenv "ANSI_TEST_SUITE"))) |
| 117 |
(ext:setenv "TEST_IMAGE" *test-image*) |
| 118 |
(zerop |
| 119 |
(nth-value |
| 120 |
1 |
| 121 |
(ext:run-program |
| 122 |
*test-image* |
| 123 |
`("-norc" |
| 124 |
"-eval" "(print (ext:getenv \"ECLDIR\"))" |
| 125 |
"-eval" "(ext:install-bytecodes-compiler)" |
| 126 |
"-eval" ,(if (ext:getenv "BYTECMP") |
| 127 |
"t" |
| 128 |
"(ignore-errors (ext:install-c-compiler))") |
| 129 |
,@(cond (suite |
| 130 |
`("-eval" ,(format nil "(setf *default-pathname-defaults* ~s)" |
| 131 |
(truename #P"ansi-test/")) |
| 132 |
"-load" "gclload1.lsp" |
| 133 |
"-load" ,(namestring (make-pathname |
| 134 |
:directory (list :relative suite) |
| 135 |
:name "load" |
| 136 |
:type "lsp")))) |
| 137 |
(t |
| 138 |
`("-load" "ansi-test/init.lsp"))) |
| 139 |
"-eval" ,(format nil "(rt:do-tests :exit t :expected-failures ~s)" |
| 140 |
(merge-pathnames #P"tests/ansi-test-expected-failures.sexp" |
| 141 |
*ecl-sources*))) |
| 142 |
:input nil |
| 143 |
:output t |
| 144 |
:error :output)))) |