Recently Written · git

clic

MIRROR ONLY Gopher client with pretty colours in Common Lisp

git clone https://github.com/equwal/clic

Log | Files | Refs


commit c2c3178142a5fec87b71d7e4f4b8b2d8fc5446c0
Solene Rapenne <solene@perso.pw>
2017-11-16 12:08:14 +0000

Add support for running interactive test with expect

 interactive-test.exp | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++
 run-test.sh          |   2 +
 2 files changed, 108 insertions(+)
diff --git a/interactive-test.exp b/interactive-test.exp
new file mode 100644
index 0000000..1cc0192
--- /dev/null
+++ b/interactive-test.exp
@@ -0,0 +1,106 @@
+proc user_input {} {
+
+    expect "clic => "
+
+    send "garbage\n"
+    expect "clic => "
+    send ". . ~. ~ .\n"
+    expect "clic => "
+
+    send "r\n"
+    expect "clic => "
+
+    send "help\n"
+    expect "clic => "
+    
+    send "5\n"
+    expect "clic => "
+    
+    send "p\n"
+    expect "clic => "
+
+    send "19\n"
+    expect " : "
+
+    send "p\n"
+    expect "clic => "
+    
+    send "h\n"
+    expect "clic => "
+    
+    send "a\n"
+    expect "clic => "
+    
+    send "b\n"
+    expect "clic => "
+}
+
+spawn ./clic gopher://bitreich.org
+set running [user_input]
+send "x\n"
+expect eof
+
+
+spawn sbcl
+expect "* "
+
+send "(require :sb-cover) (require :sb-bsd-sockets)\n"
+expect "* "
+
+send "(declaim (optimize sb-cover:store-coverage-data))\n"
+expect "* "
+
+send "(compile-file \"clic.lisp\")\n"
+expect "* "
+
+send "(load \"clic.fasl\")\n"
+expect "* "
+
+send "(setf *offline* t)\n"
+expect "* "
+
+send "(main)\n"
+set running [user_input]
+send "quit\n"
+expect "* "
+
+send "(main)\n"
+expect "clic => "
+
+send "q\n"
+expect "* "
+
+send "(pop *history*) (p) (r)\n"
+expect "* "
+
+
+# add an argv to test argv parsing
+send "(setf *posix-argv* '(\"sbcl\" \"gopher://bitreich.org/0/usr/\"))\n"
+expect "* "
+
+send "(main)\n"
+expect "* "
+
+
+# add an argv to test argv parsing
+send "(setf *posix-argv* '(\"sbcl\" \"bitreich.org/0/usr/\"))\n"
+expect "* "
+send "(main)\n"
+expect "* "
+
+
+
+# add an argv to test argv parsing
+send "(setf *posix-argv* '(\"sbcl\" \"bitreich.org:70/\"))\n"
+expect "* "
+send "(main)\n"
+expect "clic => "
+send "q\n"
+expect "* "
+
+
+send "(sb-cover:report \"report/\")\n"
+expect "* "
+
+send "(quit)\n"
+expect eof
diff --git a/run-test.sh b/run-test.sh
index 57fef52..d3aac3a 100644
--- a/run-test.sh
+++ b/run-test.sh
@@ -2,6 +2,8 @@
 
 LISP=$1
 
+expect -f interactive-test.exp
+
 ${LISP} --load clic.lisp --load test.lisp
 
 ./clic gopher://bitreich.org:70/0/  | md5sum -