Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asdf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hugo Ishimaru
asdf
Commits
b62a0b1e
Commit
b62a0b1e
authored
11 years ago
by
Francois-Rene Rideau
Browse files
Options
Downloads
Patches
Plain Diff
More Windows tweaks to test-run-program.
parent
14253178
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test-run-program.script
+35
-31
35 additions, 31 deletions
test/test-run-program.script
with
35 additions
and
31 deletions
test/test-run-program.script
+
35
−
31
View file @
b62a0b1e
;; -*- Lisp -*-
(declaim (optimize (debug 3) (safety 3)))
(DBG "Testing echo ok 1 via run-program as a list")
(assert-equal "ok 1" (run-program '("echo" "ok" "1") :output '(:string :stripped t)))
;; On Windows, normalize away CRLF into jut the unixy LF.
(defun dewindowize (x)
(block ()
(setf x (remove (code-char 13) x))
#+(and sbcl windows) ;; buggy implementations output extra space on Windows. Also old CCL.
(when (eql #\space (last-char x))
(return (subseq x 0 (1- (length x)))))
x))
(defun space-bugged (x) ;; some implementations are broken and output extra space on Windows
#.(or #+(and sbcl windows) '(strcat x " ") 'x))
(DBG "Testing echo ok 1 via run-program as a list")
(assert-equal "ok 1"
(dewindowize (run-program '("echo" "ok" "1") :output '(:string :stripped t))))
(DBG "Testing echo ok 1 via run-program as a string")
(assert-equal
(space-bugged
"ok 1"
)
(run-program "echo ok 1" :output '(:string :stripped t)))
(assert-equal "ok 1"
(dewindowize
(run-program "echo ok 1" :output '(:string :stripped t)))
)
;;; test asdf run-shell-command function
(setf *verbose-out* nil)
...
...
@@ -48,39 +55,37 @@
#+(and sbcl os-windows)
(leave-test "SBCL run-program is a big fail on windows")
;; On Windows, normalize away CRLF into jut the unixy LF.
(defun remove-cr (x) (remove (code-char 13) x))
(DBG "Testing awkward legacy output capture via run-shell-command")
(let ((ok1 (format nil "; $ echo ok 1~%
~A~%" (space-bugged "
ok 1")))
)
(let ((ok1 (format nil "; $ echo ok 1~%ok 1")))
(assert-equal
(remove-cr
(with-output-to-string (s)
(let ((*verbose-out* s))
(run-shell-command "echo ~A 1" "ok"))))
(dewindowize
(stripln
(with-output-to-string (s)
(let ((*verbose-out* s))
(run-shell-command "echo ~A 1" "ok")))))
ok1)
#-ecl
(assert-equal
(remove-cr
(with-output-to-string (s)
(let ((*verbose-out* t)
(*standard-output* s))
(let ((status (run-shell-command "echo ok ~D" 1)))
(unless (zerop status)
(error "Didn't get good exit status."))))))
(dewindowize
(stripln
(with-output-to-string (s)
(let ((*verbose-out* t)
(*standard-output* s))
(let ((status (run-shell-command "echo ok ~D" 1)))
(unless (zerop status)
(error "Didn't get good exit status.")))))))
ok1))
;; NB1: run-shell-command is deprecated. Use run-program instead.
;; NB2: we do NOT support stderr capture to *verbose-out* anymore in run-shell-command.
;; If you want 2>&1 redirection, you know where to find it.
(assert-equal (space-bugged "ok 1") (run-program '("echo" "ok 1") :output :line))
(assert-equal "ok 1" (dewindowize (run-program '("echo" "ok 1") :output :line)))
(assert-equal "ok 1" (dewindowize (run-program '("echo" "ok 1") :output '(:string :stripped t))))
(assert-equal '(:ok 1) (run-program '("echo" ":ok 1") :output :forms))
(assert-equal (format nil "~A~%" (space-bugged "ok 1"))
(remove-cr (run-program '("echo" "ok 1") :output :string)))
(assert-equal (format nil "~A~%" (space-bugged "ok"))
(remove-cr (with-output-to-string (*standard-output*)
(run-program "echo ok" :output t :error-output :output))))
(assert-equal "ok" (dewindowize (stripln
(with-output-to-string (*standard-output*)
(run-program "echo ok" :output t :error-output :output)))))
;;#+allegro (trace excl:run-shell-command sys:reap-os-subprocess)
;;#+lispworks (trace system:run-shell-command system:pid-exit-status)
...
...
@@ -199,7 +204,7 @@ Testing run-program
(defun unix-only-test/run-program ()
(assert-equal (
list (space-bugged
"ok 1")
)
(run-program "echo ok 1" :output :lines))
(assert-equal
'
("ok 1") (run-program "echo ok 1" :output :lines))
(assert-equal '(nil nil 0) (multiple-value-list (run-program "true")))
(signals subprocess-error (run-program "false"))
...
...
@@ -239,10 +244,9 @@ Testing run-program
(defun windows-only-test/run-program ()
;; a basic smoke test
(assert-equal (run-program '("cmd" "/c" "echo" "ok") :output :line
s
)
(list (space-bugged "ok"
)))
(assert-equal
"ok" (dewindowize
(run-program '("cmd" "/c" "echo" "ok") :output :line
))
)
(assert-equal "ok 1" (dewindowize (run-program "echo ok 1" :output :line
)))
(assert-equal (list (space-bugged "ok 1")) (run-program "echo ok 1" :output :lines))
t)
(deftest test/run-program ()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment