test-program.script 1.84 KB
Newer Older
1
;;; -*- Lisp -*-
2

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

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
5
6
7
8
9
(unless (or #+(or clisp clozure (and ecl (not ecl-bytecmp)) lispworks sbcl) t
            #+cmu nil ;; uncomment if you have 32-bit gcc support - or can autodetect
            #+clisp (version-satisfies
                     (first (split-string (lisp-implementation-version) :separator " "))
                     "2.48"))
10
11
12
  (DBG "Creating standalone programs is not supported on your CL implementation")
  (leave-test "Skipping test" 0))

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
13
14
15
(defparameter exe (output-file (make-operation 'program-op) (find-system :hello-world-example)))
(assert (absolute-pathname-p exe))

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
;; 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 (native-namestring (subpathname *test-directory* "make-hello-world.lisp"))))
(assert (probe-file* exe))

36
(assert-equal (run-program/ `(,(native-namestring exe)) :output :lines)
37
              '("hello, world"))
38
39
40
41
42
43
44

(assert-equal (run-program/ `(,(native-namestring exe) "a" "b c" "d") :output :lines)
              '("hello, world"
                "You passed 3 arguments:"
                "  \"a\""
                "  \"b c\""
                "  \"d\""))