[njs] Fixed expect file tests.
Dmitry Volyntsev
xeioex at nginx.com
Mon Nov 20 16:25:31 UTC 2017
details: http://hg.nginx.org/njs/rev/4fc65a23bcfc
branches:
changeset: 427:4fc65a23bcfc
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Mon Nov 20 19:24:55 2017 +0300
description:
Fixed expect file tests.
Using current directory for temporary files because /tmp
is not available for writing in BB environment.
diffstat:
njs/test/njs_expect_test.exp | 96 ++++++++++++++++++++++---------------------
1 files changed, 49 insertions(+), 47 deletions(-)
diffs (262 lines):
diff -r 5c6aa60224cb -r 4fc65a23bcfc njs/test/njs_expect_test.exp
--- a/njs/test/njs_expect_test.exp Fri Nov 17 18:55:07 2017 +0300
+++ b/njs/test/njs_expect_test.exp Mon Nov 20 19:24:55 2017 +0300
@@ -185,11 +185,11 @@ njs_test {
# require('fs')
-set file [open /tmp/njs_test_file w]
+set file [open njs_test_file w]
puts -nonewline $file "αβZγ"
flush $file
-exec /bin/echo -ne {\x80\x80} > /tmp/njs_test_file_non_utf8
+exec /bin/echo -ne {\x80\x80} > njs_test_file_non_utf8
njs_test {
{"var fs = require('fs')\r\n"
@@ -203,35 +203,37 @@ njs_test {
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.readFile('/tmp/njs_test_file', 'utf8', function (e, data) {console.log(data[2]+data.length)})\r\n"
+ {"fs.readFile('njs_test_file', 'utf8', function (e, data) {console.log(data[2]+data.length)})\r\n"
"Z4\r\nundefined\r\n>> "}
}
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.readFile('/tmp/njs_test_file', function (e, data) {console.log(data[4]+data.length)})\r\n"
+ {"fs.readFile('njs_test_file', function (e, data) {console.log(data[4]+data.length)})\r\n"
"Z7\r\nundefined\r\n>> "}
}
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.readFile('/tmp/njs_test_file', {encoding:'utf8',flag:'r+'}, function (e, data) {console.log(data)})\r\n"
+ {"fs.readFile('njs_test_file', {encoding:'utf8',flag:'r+'}, function (e, data) {console.log(data)})\r\n"
"αβZγ\r\nundefined\r\n>> "}
}
+exec rm -fr njs_unknown_path
+
+njs_test {
+ {"var fs = require('fs'); \r\n"
+ "undefined\r\n>> "}
+ {"fs.readFile('njs_unknown_path', 'utf8', function (e) {console.log(JSON.stringify(e))})\r\n"
+ "{\"errno\":2,\"path\":\"njs_unknown_path\",\"syscall\":\"open\"}\r\nundefined\r\n>> "}
+}
+
njs_test {
{"var fs = require('fs'); \r\n"
"undefined\r\n>> "}
- {"fs.readFile('/tmp/njs_unknown_path', 'utf8', function (e) {console.log(JSON.stringify(e))})\r\n"
- "{\"errno\":2,\"path\":\"/tmp/njs_unknown_path\",\"syscall\":\"open\"}\r\nundefined\r\n>> "}
-}
-
-njs_test {
- {"var fs = require('fs'); \r\n"
- "undefined\r\n>> "}
- {"fs.readFile('/tmp/njs_unknown_path', {encoding:'utf8', flag:'r+'}, function (e) {console.log(e)})\r\n"
+ {"fs.readFile('njs_unknown_path', {encoding:'utf8', flag:'r+'}, function (e) {console.log(e)})\r\n"
"Error: No such file or directory\r\nundefined\r\n>> "}
}
@@ -240,79 +242,79 @@ njs_test {
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.readFileSync('/tmp/njs_test_file', 'utf8')[2]\r\n"
+ {"fs.readFileSync('njs_test_file', 'utf8')[2]\r\n"
"Z\r\n>> "}
}
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.readFileSync('/tmp/njs_test_file')[4]\r\n"
+ {"fs.readFileSync('njs_test_file')[4]\r\n"
"Z\r\n>> "}
}
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.readFileSync('/tmp/njs_test_file', {encoding:'utf8',flag:'r+'})\r\n"
+ {"fs.readFileSync('njs_test_file', {encoding:'utf8',flag:'r+'})\r\n"
"αβZγ\r\n>> "}
}
njs_test {
{"var fs = require('fs'); \r\n"
"undefined\r\n>> "}
- {"try { fs.readFileSync('/tmp/njs_unknown_path')} catch (e) {console.log(JSON.stringify(e))}\r\n"
- "{\"errno\":2,\"path\":\"/tmp/njs_unknown_path\",\"syscall\":\"open\"}\r\nundefined\r\n>> "}
+ {"try { fs.readFileSync('njs_unknown_path')} catch (e) {console.log(JSON.stringify(e))}\r\n"
+ "{\"errno\":2,\"path\":\"njs_unknown_path\",\"syscall\":\"open\"}\r\nundefined\r\n>> "}
}
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.readFileSync('/tmp/njs_test_file_non_utf8').charCodeAt(1)\r\n"
+ {"fs.readFileSync('njs_test_file_non_utf8').charCodeAt(1)\r\n"
"128"}
}
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.readFileSync('/tmp/njs_test_file_non_utf8', 'utf8')\r\n"
+ {"fs.readFileSync('njs_test_file_non_utf8', 'utf8')\r\n"
"Error: Non-UTF8 file, convertion is not implemented"}
}
# require('fs').writeFile()
-exec rm -fr /tmp/njs_test_file2
+exec rm -fr njs_test_file2
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"function h1(e) {if (e) {throw e}; console.log(fs.readFileSync('/tmp/njs_test_file2'))}\r\n"
+ {"function h1(e) {if (e) {throw e}; console.log(fs.readFileSync('njs_test_file2'))}\r\n"
"undefined\r\n>> "}
- {"fs.writeFile('/tmp/njs_test_file2', 'ABC', h1)\r\n"
+ {"fs.writeFile('njs_test_file2', 'ABC', h1)\r\n"
"ABC\r\nundefined\r\n>> "}
}
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.writeFile('/tmp/njs_test_file2', 'ABC', 'utf8', function (e) { if (e) {throw e}; console.log(fs.readFileSync('/tmp/njs_test_file2'))})\r\n"
+ {"fs.writeFile('njs_test_file2', 'ABC', 'utf8', function (e) { if (e) {throw e}; console.log(fs.readFileSync('njs_test_file2'))})\r\n"
"ABC\r\nundefined\r\n>> "}
}
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.writeFile('/tmp/njs_test_file2', 'ABC', {encoding:'utf8', mode:0o666}, function (e) { if (e) {throw e}; console.log(fs.readFileSync('/tmp/njs_test_file2'))})\r\n"
+ {"fs.writeFile('njs_test_file2', 'ABC', {encoding:'utf8', mode:0o666}, function (e) { if (e) {throw e}; console.log(fs.readFileSync('njs_test_file2'))})\r\n"
"ABC\r\nundefined\r\n>> "}
}
-exec rm -fr /tmp/njs_wo_file
+exec rm -fr njs_wo_file
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.writeFile('/tmp/njs_wo_file', 'ABC', {mode:0o222}, function (e) {console.log(fs.readFileSync('/tmp/njs_wo_file'))})\r\n"
+ {"fs.writeFile('njs_wo_file', 'ABC', {mode:0o222}, function (e) {console.log(fs.readFileSync('njs_wo_file'))})\r\n"
"Error: Permission denied"}
}
@@ -325,81 +327,81 @@ njs_test {
# require('fs').writeFileSync()
-exec rm -fr /tmp/njs_test_file2
+exec rm -fr njs_test_file2
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.writeFileSync('/tmp/njs_test_file2', 'ABC')\r\n"
+ {"fs.writeFileSync('njs_test_file2', 'ABC')\r\n"
"undefined\r\n>> "}
- {"fs.readFileSync('/tmp/njs_test_file2')\r\n"
+ {"fs.readFileSync('njs_test_file2')\r\n"
"ABC\r\n>> "}
}
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.writeFileSync('/tmp/njs_test_file2', 'ABC', 'utf8')\r\n"
+ {"fs.writeFileSync('njs_test_file2', 'ABC', 'utf8')\r\n"
"undefined\r\n>> "}
- {"fs.readFileSync('/tmp/njs_test_file2')\r\n"
+ {"fs.readFileSync('njs_test_file2')\r\n"
"ABC\r\n>> "}
}
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.writeFileSync('/tmp/njs_test_file2', 'ABC')\r\n"
+ {"fs.writeFileSync('njs_test_file2', 'ABC')\r\n"
"undefined\r\n>> "}
- {"fs.writeFileSync('/tmp/njs_test_file2', 'ABC')\r\n"
+ {"fs.writeFileSync('njs_test_file2', 'ABC')\r\n"
"undefined\r\n>> "}
- {"fs.readFileSync('/tmp/njs_test_file2')\r\n"
+ {"fs.readFileSync('njs_test_file2')\r\n"
"ABC\r\n>> "}
}
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.writeFileSync('/tmp/njs_test_file2', 'ABC', {encoding:'utf8', mode:0o666})\r\n"
+ {"fs.writeFileSync('njs_test_file2', 'ABC', {encoding:'utf8', mode:0o666})\r\n"
"undefined\r\n>> "}
- {"fs.readFileSync('/tmp/njs_test_file2')\r\n"
+ {"fs.readFileSync('njs_test_file2')\r\n"
"ABC\r\n>> "}
}
-exec rm -fr /tmp/njs_wo_file
+exec rm -fr njs_wo_file
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.writeFileSync('/tmp/njs_wo_file', 'ABC', {mode:0o222}); fs.readFileSync('/tmp/njs_wo_file')\r\n"
+ {"fs.writeFileSync('njs_wo_file', 'ABC', {mode:0o222}); fs.readFileSync('njs_wo_file')\r\n"
"Error: Permission denied"}
}
# require('fs').appendFile()
-exec rm -fr /tmp/njs_test_file2
+exec rm -fr njs_test_file2
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"function h1(e) {console.log(fs.readFileSync('/tmp/njs_test_file2'))}\r\n"
+ {"function h1(e) {console.log(fs.readFileSync('njs_test_file2'))}\r\n"
"undefined\r\n>> "}
- {"function h2(e) {fs.appendFile('/tmp/njs_test_file2', 'ABC', h1)}\r\n"
+ {"function h2(e) {fs.appendFile('njs_test_file2', 'ABC', h1)}\r\n"
"undefined\r\n>> "}
- {"fs.appendFile('/tmp/njs_test_file2', 'ABC', h2)\r\n"
+ {"fs.appendFile('njs_test_file2', 'ABC', h2)\r\n"
"ABCABC\r\nundefined\r\n>> "}
}
# require('fs').appendFileSync()
-exec rm -fr /tmp/njs_test_file2
+exec rm -fr njs_test_file2
njs_test {
{"var fs = require('fs')\r\n"
"undefined\r\n>> "}
- {"fs.appendFileSync('/tmp/njs_test_file2', 'ABC')\r\n"
+ {"fs.appendFileSync('njs_test_file2', 'ABC')\r\n"
"undefined\r\n>> "}
- {"fs.appendFileSync('/tmp/njs_test_file2', 'ABC')\r\n"
+ {"fs.appendFileSync('njs_test_file2', 'ABC')\r\n"
"undefined\r\n>> "}
- {"fs.readFileSync('/tmp/njs_test_file2')\r\n"
+ {"fs.readFileSync('njs_test_file2')\r\n"
"ABCABC\r\n>> "}
}
More information about the nginx-devel
mailing list