Commit 077a87fe authored by Francois-Rene Rideau's avatar Francois-Rene Rideau

test-run-program: more debugging

parent 31e21864
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#-(and sbcl os-windows) #-(and sbcl os-windows)
(let ((ok1 (format nil "; $ echo ok 1~%ok 1"))) (let ((ok1 (format nil "; $ echo ok 1~%ok 1")))
(untrace)
(DBG "Testing awkward legacy output capture via run-shell-command") (DBG "Testing awkward legacy output capture via run-shell-command")
(assert-equal (assert-equal
(dewindowize (dewindowize
...@@ -166,29 +167,27 @@ Testing run-program ...@@ -166,29 +167,27 @@ Testing run-program
t) t)
(defun common-test/run-program () (defun common-test/run-program ()
;; Can we echo a simple string? (DBG "Can we echo a simple string?")
(assert-equal '("abcde") (run-program '("echo" "abcde") :output :lines)) (assert-equal '("abcde") (run-program '("echo" "abcde") :output :lines))
(assert-equal (nl "fghij") (run-program '("echo" "fghij") :output :string)) (assert-equal (nl "fghij") (run-program '("echo" "fghij") :output :string))
;; Are spaces handled properly? (DBG "Are spaces handled properly?")
(assert-equal '("Hello World") (run-program '("echo" "Hello World") :output :lines)) (assert-equal '("Hello World") (run-program '("echo" "Hello World") :output :lines))
(assert-equal (nl "Hello World") (run-program '("echo" "Hello World") :output :string)) (assert-equal (nl "Hello World") (run-program '("echo" "Hello World") :output :string))
(assert-equal (nl "Hello World") (run-program "echo Hello World" :output :string)) (assert-equal (nl "Hello World") (run-program "echo Hello World" :output :string))
;; Test that run-program fails properly with an empty program string (DBG "Test that run-program fails properly with an empty program string")
#+(or clozure (and allegro os-unix) cmu (and lispworks os-unix) sbcl scl) #+(or clozure (and allegro os-unix) cmu (and lispworks os-unix) sbcl scl)
(signals error (run-program '("") :output :lines)) (signals error (run-program '("") :output :lines))
;; An empty string itself is ok since it is passed to the shell. (DBG "An empty string itself is ok since it is passed to the shell.")
(assert-equal "" (run-program "" :output :string)) (assert-equal "" (run-program "" :output :string))
;; Test that run-program fails properly with a (DBG "Test that run-program fails properly with a nil program list")
;; nil program list
#+(or clozure (and allegro os-unix) cmu sbcl scl) #+(or clozure (and allegro os-unix) cmu sbcl scl)
(signals error (run-program nil :output :lines)) (signals error (run-program nil :output :lines))
;; Test that run-program fails properly when the (DBG "Test that run-program fails properly when the executable doesn't exist.")
;; executable doesn't exist.
(signals error (run-program '("does-not-exist") :output :lines)) (signals error (run-program '("does-not-exist") :output :lines))
(signals error (run-program "does-not-exist" :output :lines)) (signals error (run-program "does-not-exist" :output :lines))
...@@ -199,14 +198,17 @@ Testing run-program ...@@ -199,14 +198,17 @@ Testing run-program
(defun unix-only-test/run-program () (defun unix-only-test/run-program ()
(DBG "Checking that spaces between arguments are collapsed by shell when and only when unquoted")
(assert-equal '("ok 1") (run-program "echo ok 1" :output :lines)) (assert-equal '("ok 1") (run-program "echo ok 1" :output :lines))
(assert-equal '("ok 1") (run-program '("echo" "ok 1") :output :lines)) (assert-equal '("ok 1") (run-program '("echo" "ok 1") :output :lines))
(assert-equal "ok 1" (run-program '("echo" "ok 1") :output '(:string :stripped t))) (assert-equal "ok 1" (run-program '("echo" "ok 1") :output '(:string :stripped t)))
(DBG "Checking behavior on program success or failure")
(assert-equal '(nil nil 0) (multiple-value-list (run-program "true"))) (assert-equal '(nil nil 0) (multiple-value-list (run-program "true")))
(signals subprocess-error (run-program "false")) (signals subprocess-error (run-program "false"))
(assert-equal '(nil nil 1) (multiple-value-list (run-program "false" :ignore-error-status t))) (assert-equal '(nil nil 1) (multiple-value-list (run-program "false" :ignore-error-status t)))
(DBG "Tests with test-file")
(let ((tf (native-namestring (test-source "test-file")))) (let ((tf (native-namestring (test-source "test-file"))))
;; a basic smoke test ;; a basic smoke test
...@@ -254,5 +256,4 @@ Testing run-program ...@@ -254,5 +256,4 @@ Testing run-program
(terpri) (terpri)
t) t)
(test/run-program) (test/run-program)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment