From a043bfadd3724e18384f694e7e587a23e7c96e73 Mon Sep 17 00:00:00 2001 From: Gian Piero Carrubba Date: Tue, 8 Sep 2020 15:09:37 +0200 Subject: [PATCH 1/2] Set up a simple test package for checking the output stream --- scriptl-test.asd | 10 ++++++++++ t/io.lisp | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 scriptl-test.asd create mode 100644 t/io.lisp diff --git a/scriptl-test.asd b/scriptl-test.asd new file mode 100644 index 0000000..2174f07 --- /dev/null +++ b/scriptl-test.asd @@ -0,0 +1,10 @@ +(defsystem scriptl-test + :author "Gian Piero Carrubba " + :license "LLGPL" + :depends-on (:scriptl + :FiveAM + :inferior-shell) + :components ((:module "t" + :serial t + :components + ((:file "io"))))) diff --git a/t/io.lisp b/t/io.lisp new file mode 100644 index 0000000..2bf777a --- /dev/null +++ b/t/io.lisp @@ -0,0 +1,38 @@ +(defpackage #:scriptl-test.io + (:use #:cl + #:FiveAM)) + +(in-package :scriptl-test.io) + +(scriptl:start) +; there's a way for checking the server has started? +(sleep 1) + +(defun eval-string (string) + (eval (read-from-string string))) + +(defun run-test (string) + (uiop:call-with-temporary-file + (lambda (tmp) + (let ((tmpfile (namestring tmp))) + (scriptl:make-script tmpfile 'eval-string) + (inferior-shell:run/i `(,tmpfile ,string)))) + :want-stream-p nil + :want-pathname-p t)) + +(defmacro test-finishes (name form) + `(test ,name (finishes (run-test (prin1-to-string ',form))))) + +(def-suite output-io-suite + :description "The output I/O test suite.") + +(in-suite output-io-suite) + +(test-finishes format-t + (format t "ok~%")) +(test-finishes inferior-shell-echo + (inferior-shell:run '(/bin/echo ok))) +(test-finishes uiop-echo + (uiop:run-program '("/bin/echo" "ok") :output t)) + +(run! 'output-io-suite) From e1e7f60ee5e2fbb7f401d253f9f4eabedf857b30 Mon Sep 17 00:00:00 2001 From: Gian Piero Carrubba Date: Tue, 8 Sep 2020 15:13:40 +0200 Subject: [PATCH 2/2] Use character-based io stream This way it can be used as standard output by uiop:run-program --- src/packet-io-stream.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packet-io-stream.lisp b/src/packet-io-stream.lisp index 3ff8c86..c0a57d3 100644 --- a/src/packet-io-stream.lisp +++ b/src/packet-io-stream.lisp @@ -1,7 +1,7 @@ (in-package :scriptl) (defclass packet-io-stream - (trivial-gray-streams:fundamental-stream) + (trivial-gray-streams:fundamental-character-stream) ((stream :initarg :stream :initform nil))) (defmethod trivial-gray-streams:stream-write-sequence