1.1--- a/lisp/lib/cli/tests.lisp Sun Sep 08 21:14:30 2024 -0400
1.2+++ b/lisp/lib/cli/tests.lisp Tue Sep 10 21:26:30 2024 -0400
1.3@@ -4,7 +4,7 @@
1.4
1.5 ;;; Code:
1.6 (defpackage :cli/tests
1.7- (:use :cl :std :rt :cli :cli/shell :cli/progress :cli/spark :cli/repl :cli/ansi :cli/prompt :cli/clap :cli/tools/sbcl))
1.8+ (:use :cl :std :rt :cli :cli/shell :cli/progress :cli/spark :cli/repl :cli/ansi :cli/prompt :cli/clap :cli/tools/sbcl :dat/sxp))
1.9
1.10 (in-package :cli/tests)
1.11 (declaim (optimize (debug 3) (safety 3)))
1.12@@ -60,7 +60,7 @@
1.13 (princ "X"))
1.14 (.sgr 0)
1.15 (force-output)
1.16- (sleep 3)
1.17+ ;; (sleep 3)
1.18 (.ris)
1.19 (force-output))
1.20
1.21@@ -68,34 +68,36 @@
1.22 "Hide and show the cursor."
1.23 (princ "Cursor visible:")
1.24 (force-output)
1.25- (sleep 2)
1.26+ ;; (sleep 2)
1.27 (terpri)
1.28 (princ "Cursor invisible:")
1.29 (hide-cursor)
1.30 (force-output)
1.31- (sleep 2)
1.32+ ;; (sleep 2)
1.33 (terpri)
1.34 (princ "Cursor visible:")
1.35 (show-cursor)
1.36 (force-output)
1.37- (sleep 2))
1.38+ ;; (sleep 2)
1.39+ )
1.40
1.41 (defun ansi-t05 ()
1.42 "Switch to and back from the alternate screen buffer."
1.43 (princ "Normal screen buffer. ")
1.44 (force-output)
1.45- (sleep 2)
1.46+ ;; (sleep 2)
1.47 (save-cursor-position)
1.48 (use-alternate-screen-buffer)
1.49 (clear)
1.50 (princ "Alternate screen buffer.")
1.51 (force-output)
1.52- (sleep 2)
1.53+ ;; (sleep 2)
1.54 (use-normal-screen-buffer)
1.55 (restore-cursor-position)
1.56 (princ "Back to Normal screen buffer.")
1.57 (force-output)
1.58- (sleep 1))
1.59+ ;; (sleep 1)
1.60+ )
1.61
1.62 (defun ansi-t06 ()
1.63 "Set individual termios flags to enable raw and disable echo mode.
1.64@@ -205,7 +207,7 @@
1.65 ;; fixture API
1.66 (defprompt tpfoo :prompt "testing:")
1.67
1.68-(deftest cli-prompt ()
1.69+(deftest cli-prompt (:skip t)
1.70 "Test CLI prompts"
1.71 (defvar tcoll nil)
1.72 (defvar thist nil)
1.73@@ -220,8 +222,8 @@
1.74 (:name "bar" :description "foo")))
1.75
1.76 (defparameter *cmd1* (make-cli :cmd :name "holla" :opts *opts* :description "cmd1 description"))
1.77-(defparameter *cmd2* (make-cli :cmd :name "ayo" :cmds #(*cmd1*) :opts *opts* :description "cmd1 description"))
1.78-(defparameter *cmds* (make-cmds '(:name "baz" :description "baz" :opts *opts*)))
1.79+(defparameter *cmd2* (make-cli :cmd :name "ayo" :cmds (vector *cmd1*) :opts *opts* :description "cmd1 description"))
1.80+(defparameter *cmds* (make-cmds `(:name "baz" :description "baz" :opts ,*opts*) *cmd1* *cmd2*))
1.81
1.82 (defparameter *cli* (make-cli :cli :opts *opts* :cmds *cmds* :description "test cli"))
1.83
1.84@@ -230,7 +232,7 @@
1.85 "test basic CLAP functionality."
1.86 (let ((cli *cli*))
1.87 (is (eq (make-shorty "test") #\t))
1.88- (is (equalp (proc-args cli '("-f" "baz" "--bar" "fax")) ;; not eql
1.89+ (is (equalp (proc-args cli '("-f" "baz" "--bar=fax")) ;; not eql
1.90 (make-cli-ast
1.91 (list (make-cli-node 'opt (find-short-opts cli #\f))
1.92 (make-cli-node 'cmd (find-cmd cli "baz"))
1.93@@ -242,7 +244,7 @@
1.94 (print-version cli s)
1.95 (print-usage cli s)
1.96 (print-help cli s))))
1.97- (is (string= "foobar" (cli/clap::parse-string-opt "foobar")))))
1.98+ (is (string= "foobar" (cli/clap:parse-string-opt "foobar")))))
1.99
1.100 (make-opt-parser thing *arg*)
1.101
1.102@@ -676,10 +678,14 @@
1.103
1.104 (deftest cli-ast ()
1.105 "Validate the CLI/CLAP/AST parser."
1.106- (with-cli () *cli*))
1.107+ (with-cli () *cli*
1.108+ (is (string= (cli-opt-name (cli-node-form (car (ast (proc-args *cli* '("--foo" "1"))))))
1.109+ "foo"))
1.110+ (is (string=
1.111+ (cli-opt-name (cli-node-form (car (ast (proc-args *cli* '("--foo=11"))))))
1.112+ "foo"))))
1.113
1.114 (defmain (:exit nil :export nil)
1.115- (proc-args *cli* '("--foo 1"))
1.116 (with-cli () *cli*
1.117 (log:trace! "defmain is OK")
1.118 t))