]> git.kaiwu.me - njs.git/commitdiff
Improved expect tests.
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 7 May 2019 16:50:35 +0000 (19:50 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Tue, 7 May 2019 16:50:35 +0000 (19:50 +0300)
auto/expect
njs/test/inputrc [new file with mode: 0644]
njs/test/njs_expect_test.exp

index 5b4dc7b4ea6038269a083754ecbc8bd972ad0073..134e48d273b347a9d79ae805d6524b6907d2632e 100644 (file)
@@ -21,7 +21,8 @@ if [ $nxt_found = yes -a $NXT_HAVE_READLINE = YES ]; then
     cat << END >> $NXT_MAKEFILE
 
 njs_expect_test:       njs njs/test/njs_expect_test.exp
-       PATH=$NXT_BUILD_DIR:\$(PATH) expect -f njs/test/njs_expect_test.exp
+       INPUTRC=njs/test/inputrc PATH=$NXT_BUILD_DIR:\$(PATH) \
+            expect -f njs/test/njs_expect_test.exp
 END
 
 else
diff --git a/njs/test/inputrc b/njs/test/inputrc
new file mode 100644 (file)
index 0000000..2835ff1
--- /dev/null
@@ -0,0 +1,5 @@
+set bell-style audible
+set print-completions-horizontally on
+set completion-display-width 0
+set completion-ignore-case on
+set page-completions off
index c1d9ad22effc710920e5c655907f9a874c0e6a79..1b6861a83df81ae9c9aa45c4157117df24c35286 100644 (file)
@@ -12,6 +12,18 @@ proc njs_test {body {opts ""}} {
         eval spawn  -nottycopy njs $opts
     }
 
+    # TODO:
+    # SIGINT handling race condition
+    #   deb9-amd64-generic-njs-try
+    #   ub1404-armv7-generic-njs-try
+    #   ub1804-arm64-generic-njs-try
+    # UTF8 terminal support issue
+    #   sol11-amd64-sunpro-njs-try
+    #   ub1604-arm64-generic-njs-try
+
+    # set timeout 30
+    # expect_before timeout { exit 1 }
+
     expect -re "interactive njs \\d+\.\\d+\.\\d+\r\n\r"
     expect "v.<Tab> -> the properties and prototype methods of v.\r
 type console.help() for more information\r
@@ -33,7 +45,6 @@ type console.help() for more information\r
 proc njs_run {opts output} {
     eval spawn  -nottycopy njs $opts
     expect -re $output
-    expect eof
 }
 
 njs_test {
@@ -41,7 +52,7 @@ njs_test {
      "njs.version\r\n\*\.\*\.\*"}
 }
 
-# simple multi line interation
+# simple multi line interaction
 njs_test {
     {"var a = 1\r\n"
      "var a = 1\r\nundefined\r\n>> "}
@@ -62,30 +73,33 @@ njs_test {
 }
 
 # Global completions, single partial match
+
+# \a* is WORKAROUND for libedit-20170329.3.1-r3
+# which inserts '\rESC[6G' after '\a'.
 njs_test {
     {"O\t"
-     "O\abject"}
+     "O\a*bject"}
 }
 
 njs_test {
     {"Ma\t"
-     "Ma\ath"}
+     "Ma\a*th"}
 }
 
 njs_test {
     {"conso\t"
-     "conso\ale"}
+     "conso\a*le"}
 }
 
 # Global completions, multiple partial match
 njs_test {
     {"cons\t\t"
-     "console*console.help*console.time*const"}
+     "console*const"}
 }
 
 njs_test {
     {"O\t"
-     "O\abject"}
+     "O\a*bject"}
     {".\t\t"
      "Object.create*Object.isSealed"}
 }
@@ -97,16 +111,16 @@ njs_test {
 
 njs_test {
     {"Object.g\t"
-     "Object.g\aet"}
-    {"\t"
+     "Object.g\a*et"}
+    {"\t\t"
      "Object.getOwnPropertyDescriptor*Object.getPrototypeOf"}
 }
 
 njs_test {
     {"Ma\t"
-     "Ma\ath"}
+     "Ma\a*th"}
     {".\t\t"
-     "Math.__proto__*Math.cbrt*Math.fround*Math.log2"}
+     "Math.abs*Math.atan2"}
 }
 
 # Global completions, no matches
@@ -133,11 +147,13 @@ njs_test {
      "a*aa*arguments*await"}
 }
 
+# z*z is WORKAROUND for libedit-20170329.3.1-r3
+# which inserts bogus '\a' between 'z'
 njs_test {
     {"var zz = 1\r\n"
      "var zz = 1\r\nundefined\r\n>> "}
     {"1 + z\t\r\n"
-     "1 + zz\r\n2"}
+     "1 + z*z*\r\n2"}
 }
 
 njs_test {
@@ -375,7 +391,7 @@ njs_test {
     {"var fs = require('fs')\r\n"
      "undefined\r\n>> "}
     {"fs.read\t"
-     "fs.read\aFile"}
+     "fs.read\a*File"}
 }
 
 # require('fs').readFile()
@@ -641,7 +657,7 @@ njs_run "-v" "\\d+\.\\d+\.\\d+"
 
 njs_test {
     {"1+1\r\n"
-     "00000 ADD*\r\n00040 STOP*\r\n\r\n2"}
+     "00000 ADD*\r\n*2"}
     {"for (var n in [1]) {try {break} finally{}}\r\n"
      "00000 ARRAY*\r\n*TRY BREAK*STOP*\r\n\r\nundefined"}
     {"(function() {try {return} finally{}})()\r\n"