File: tests.lisp

package info (click to toggle)
acl2 7.2dfsg-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 198,968 kB
  • ctags: 182,300
  • sloc: lisp: 2,415,261; ansic: 5,675; perl: 5,577; xml: 3,576; sh: 3,255; cpp: 2,835; makefile: 2,440; ruby: 2,402; python: 778; ml: 763; yacc: 709; csh: 355; php: 171; lex: 162; tcl: 44; java: 24; asm: 23; haskell: 17
file content (72 lines) | stat: -rw-r--r-- 2,366 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(defpackage external-program-tests
  (:use #:cl #:external-program #:fiveam)
  (:shadow #:run))

(in-package #:external-program-tests)

(def-suite tests)

(in-suite tests)

;;; FIXME: should probably signal a condition if program isn't found
;;; ... but can't guarantee that 71 isn't returned by the program
;;; itself ...
(test should-have-access-to-shell-builtins
  (multiple-value-bind (status code)
      (external-program:run "cd" '())
    (is (eq :exited status))
    (is (= 0 code))))

(test should-discover-programs-in-path
  (multiple-value-bind (status code)
      (external-program:run "which" '("ls"))
    (is (eq :exited status))
    (is (= 0 code))))

(test should-be-able-to-use-pathname-as-program
  (multiple-value-bind (status code)
      (external-program:run (make-pathname :name "ls") '("."))
    (is (eq :exited status))
    (is (= 0 code))))

(test should-be-able-to-use-pathnames-as-args
  (multiple-value-bind (status code)
      (external-program:run "ls"
                            (list (merge-pathnames (make-pathname :name nil)
                                                   #.*compile-file-truename*)))
    (is (eq :exited status))
    (is (= 0 code))))

(test should-be-able-to-use-numbers-as-args
  (multiple-value-bind (status code)
      (external-program:run "grep"
                            '("-C" 3 "should" #.*compile-file-truename*))
    (is (eq :exited status))
    (is (= 0 code))))

(test should-allow-spaces-in-args
  (multiple-value-bind (status code)
      (external-program:run "grep"
                            '("should probably" #.*compile-file-truename*))
    (is (eq :exited status))
    (is (= 0 code))))

(test environment-vars-should-override-existing
  (multiple-value-bind (status code)
      (external-program:run "which" '("which") :environment '(("PATH" . "")))
    (is (eq :exited status))
    (is (/= 0 code))))

(test empty-env-should-erase-all
  (multiple-value-bind (status code)
      (external-program:run "ls" '(".") :replace-environment-p t)
    (is (eq :exited status))
    (is (/= 0 code))))

(test run-async
  (let ((process (external-program:start "sleep" '("3"))))
    (let ((status-1 (external-program:process-status process)))
      (is (eq :running status-1))
      (sleep 5)
      (let ((status-2 (external-program:process-status process)))
        (is (eq :exited status-2))))))