test-program.script 1.74 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
;;; -*- Lisp -*-
(load "script-support.lisp")
(load-asdf)

(with-test ()

  (DBG :foo (current-lisp-file-pathname))

  (let ((exe (output-file (make-operation 'program-op) (find-system :hello-world-example))))
    (assert (absolute-pathname-p exe))

    (unless (and #-(or clisp clozure cmu ecl lispworks sbcl) nil
13
                 #+cmu nil ;; uncomment if you have 32-bit gcc support - or can autodetect
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
                 #+clisp (version-satisfies
                          (first (split-string (lisp-implementation-version) :separator " "))
                          "2.48"))
      (DBG "Creating standalone programs is not supported on your CL implementation")
      (leave-test "Skipping test" 0))

    ;; Try to load lisp-invocation from xcvb
    (setf *central-registry*
          (list *asdf-directory* ;; be sure that *OUR* asdf is first of any possible ASDF
                ;; try finding xcvb's lisp-invocation right next to asdf.
                (subpathname *asdf-directory* "../xcvb/")))
    (unless (find-system :lisp-invocation nil)
      ;; try harder by enabling the user's source-registry
      (initialize-source-registry ""))
    (unless (find-system :lisp-invocation nil)
      (leave-test "Couldn't find lisp-invocation. Skipping the rest the test." 0))
    (load-system :lisp-invocation)
    ;; Disable any user source registry.
    (initialize-source-registry `(:source-registry :ignore-inherited-configuration))

    (delete-file-if-exists exe)
    (run-program/
     (symbol-call :lisp-invocation :lisp-invocation-arglist
                  :load (subpathname *test-directory* "make-hello-world.lisp")))
    (assert (probe-file* exe))

    (assert-equal (run-program/ (unix-namestring exe) :output :lines)
                  '("hello, world"))

    t))