### -*-autotest-*- ### ### Test script for `runlisp' ### ### (c) 2020 Mark Wooding ### ###----- Licensing notice --------------------------------------------------- ### ### This file is part of Runlisp, a tool for invoking Common Lisp scripts. ### ### Runlisp is free software: you can redistribute it and/or modify it ### under the terms of the GNU General Public License as published by the ### Free Software Foundation; either version 3 of the License, or (at your ### option) any later version. ### ### Runlisp is distributed in the hope that it will be useful, but WITHOUT ### ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ### FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ### for more details. ### ### You should have received a copy of the GNU General Public License ### along with Runlisp. If not, see . m4_define([RUNLISP_PATH], [$abs_top_builddir/runlisp]) m4_define([_FOREACH], [dnl m4_if([$#], [1], [_foreach_func($1)], [_foreach_func($1)[]_FOREACH(m4_shift($@))])]) m4_define([FOREACH], [dnl m4_pushdef([_foreach_func], [$2])dnl _FOREACH($1)[]dnl m4_popdef([_foreach_func])]) m4_define([LISP_SYSTEMS], [sbcl, sbcl/noimage, ccl, ccl/noimage, clisp, clisp/noimage, ecl, ecl/noimage, cmucl, cmucl/noimage, abcl, abcl/noimage]) m4_define([SETUP_RUNLISP_ENV], [RUNLISP_SYSCONFIG=$abs_top_srcdir/runlisp-base.conf; export RUNLISP_SYSCONFIG RUNLISP_SYSCONFIG_DIR=/notexist; export RUNLISP_SYSCONFIG_DIR RUNLISP_IMAGEDIR=$abs_top_builddir; export RUNLISP_IMAGEDIR RUNLISP_EVAL=$abs_top_srcdir/eval.lisp; export RUNLISP_EVAL unset RUNLISP_USERCONFIG ]) m4_define([PREPARE_LISP_TEST], [SETUP_RUNLISP_ENV lisp=$1 LISP=$m4_translit(m4_bregexp([$1], [/.*$], []), [a-z], [A-Z]) AT_SKIP_IF([test "x$LISP" = x]) case $lisp in */*) opt=${lisp#*/} lisp=${lisp%%/*} ;; *) opt="" ;; esac case /$opt/ in */noimage/*) RUNLISP_IMAGEDIR=./notexist ;; esac]) m4_define([WHICH_LISP], [(or #+sbcl "sbcl" #+ccl "ccl" #+clisp "clisp" #+ecl "ecl" #+cmu "cmucl" #+abcl "abcl" "unknown")]) m4_define([NL], [ ]) ###-------------------------------------------------------------------------- ### A basic smoke test. ## Check that the system basically works, by running a trivial test program. ## Also try to verify that we're not running user or site startup code, ## though this is hard to do in general. FOREACH([LISP_SYSTEMS], [AT_SETUP([$1 smoke]) AT_KEYWORDS([script smoke $1]) PREPARE_LISP_TEST([$1]) ## Prepare a user-init file which will break the test if it's run by printing ## something unexpected. mkdir HOME case $lisp in sbcl) initfile=.sbclrc ;; ccl) initfile=.ccl-init.lisp ;; clisp) initfile=.clisprc.lisp ;; ecl) initfile=.eclrc ;; cmucl) initfile=.cmucl-init.lisp ;; abcl) initfile=.abclrc ;; esac cat >HOME/$initfile <test-script <stdin ## Prepare the reference stdout and stderr. cat >stdout.ref <stderr.ref <test <out >err; rc=$? AT_FAIL_IF([test $rc = 0]) AT_CLEANUP]) ###-------------------------------------------------------------------------- ### Check eval mode. ### Eval mode is implemented centrally through a script, so we don't need to ### test it separately for each Lisp implementation. AT_SETUP([eval mode]) AT_KEYWORDS([eval common]) SETUP_RUNLISP_ENV ## A very basic smoke test. AT_CHECK([RUNLISP_PATH -e '(format t "Just another Lisp hacker!~%")'],, [Just another Lisp hacker! ]) ## The `:runlisp-script' keyword should /not/ be in `*features*'. traceon AT_CHECK([RUNLISP_PATH -p '(find :runlisp-script *features*)'],, [NIL ]) ## Check a mixture of all the kinds of evaluation. We'll need a stunt script ## to make this work. Also check that the individual forms are read and ## evaluated one at a time, so that each one can affect the way the reader ## interprets the next. cat >script.lisp </dev/null; then good=t; else good=nil; fi case ${lisp0+t},${badlisp+t},$good in ,*,t) lisp0=$lisp ;; t,*,t) lisp1=$lisp win=t; break ;; *,,nil) badlisp=$lisp ;; esac done AT_CHECK([case $win in nil) exit 77 ;; esac]) case ${badlisp+t} in t) ;; *) badlisp=$1 ;; esac BADLISP=$(echo $badlisp | tr a-z A-Z) eval $BADLISP=/notexist/definitely-wrong export $BADLISP echo Primary Lisp = $lisp0 echo Secondary Lisp = $lisp1 echo Bad Lisp = $badlisp ## Check that our selection worked. AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp0 -p 'WHICH_LISP'],, ["$lisp0"NL]) AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp1 -p 'WHICH_LISP'],, ["$lisp1"NL]) AT_CHECK([RUNLISP_PATH -L$badlisp -p 'WHICH_LISP'], [127],, [runlisp: no acceptable Lisp systems found[]NL]) ## Unset all of the user preference mechanisms. here=$(pwd) mkdir HOME config HOME=$here/HOME XDG_CONFIG_HOME=$here/config; export HOME XDG_CONFIG_HOME ## We generally take the first one listed that exists. AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp0,$lisp1 -p 'WHICH_LISP'],, ["$lisp0"NL]) AT_CHECK_UNQUOTED([RUNLISP_PATH -L$lisp1,$lisp0 -p 'WHICH_LISP'],, ["$lisp1"NL]) AT_CHECK_UNQUOTED([RUNLISP_PATH -L$badlisp,$lisp0,$lisp1 -p 'WHICH_LISP'],, ["$lisp0"NL]) ## Check parsing of embedded options. for i in 0 1; do j=$(( 1 - $i )); eval lisp=\$lisp$i olisp=\$lisp$j cat >script$i <$conf <