[njs] Added quiet option for vm to support bit-exact output in test262.
Dmitry Volyntsev
xeioex at nginx.com
Fri Apr 12 17:49:09 UTC 2019
details: https://hg.nginx.org/njs/rev/802fe99c8881
branches:
changeset: 889:802fe99c8881
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Fri Apr 12 20:48:44 2019 +0300
description:
Added quiet option for vm to support bit-exact output in test262.
diffstat:
njs/njs.h | 1 +
njs/njs_generator.c | 9 ++++++++-
njs/njs_parser.c | 2 +-
njs/njs_shell.c | 26 +++++++++++++-------------
njs/test/njs_expect_test.exp | 3 +++
5 files changed, 26 insertions(+), 15 deletions(-)
diffs (99 lines):
diff -r d7a0eb59a7e7 -r 802fe99c8881 njs/njs.h
--- a/njs/njs.h Sun Apr 07 14:26:13 2019 +0800
+++ b/njs/njs.h Fri Apr 12 20:48:44 2019 +0300
@@ -149,6 +149,7 @@ typedef struct {
uint8_t backtrace; /* 1 bit */
uint8_t sandbox; /* 1 bit */
uint8_t module; /* 1 bit */
+ uint8_t quiet; /* 1 bit */
} njs_vm_opt_t;
diff -r d7a0eb59a7e7 -r 802fe99c8881 njs/njs_generator.c
--- a/njs/njs_generator.c Sun Apr 07 14:26:13 2019 +0800
+++ b/njs/njs_generator.c Fri Apr 12 20:48:44 2019 +0300
@@ -3246,7 +3246,14 @@ njs_generate_function_debug(njs_vm_t *vm
debug->lambda = lambda;
debug->line = node->token_line;
- debug->file = node->scope->file;
+
+ if (!vm->options.quiet) {
+ debug->file = node->scope->file;
+
+ } else {
+ debug->file = nxt_string_value("");
+ }
+
debug->name = (name != NULL) ? *name : no_label;
return NXT_OK;
diff -r d7a0eb59a7e7 -r 802fe99c8881 njs/njs_parser.c
--- a/njs/njs_parser.c Sun Apr 07 14:26:13 2019 +0800
+++ b/njs/njs_parser.c Fri Apr 12 20:48:44 2019 +0300
@@ -2378,7 +2378,7 @@ njs_parser_scope_error(njs_vm_t *vm, njs
p = end - width;
}
- if (file->length != 0) {
+ if (file->length != 0 && !vm->options.quiet) {
p = nxt_sprintf(p, end, " in %V:%uD", file, line);
} else {
diff -r d7a0eb59a7e7 -r 802fe99c8881 njs/njs_shell.c
--- a/njs/njs_shell.c Sun Apr 07 14:26:13 2019 +0800
+++ b/njs/njs_shell.c Fri Apr 12 20:48:44 2019 +0300
@@ -228,28 +228,28 @@ main(int argc, char **argv)
nxt_memzero(&vm_options, sizeof(njs_vm_opt_t));
- if (!opts.quiet) {
- if (opts.file == NULL) {
- p = getcwd(path, sizeof(path));
- if (p == NULL) {
- nxt_error("getcwd() failed:%s\n", strerror(errno));
- ret = NXT_ERROR;
- goto done;
- }
-
- memcpy(path + nxt_strlen(path), "/shell", sizeof("/shell"));
- opts.file = path;
+ if (opts.file == NULL) {
+ p = getcwd(path, sizeof(path));
+ if (p == NULL) {
+ nxt_error("getcwd() failed:%s\n", strerror(errno));
+ ret = NXT_ERROR;
+ goto done;
}
- vm_options.file.start = (u_char *) opts.file;
- vm_options.file.length = nxt_strlen(opts.file);
+ memcpy(path + nxt_strlen(path), "/shell", sizeof("/shell"));
+ opts.file = path;
}
+ vm_options.file.start = (u_char *) opts.file;
+ vm_options.file.length = nxt_strlen(opts.file);
+
vm_options.init = !opts.interactive;
vm_options.accumulative = opts.interactive;
vm_options.backtrace = 1;
+ vm_options.quiet = opts.quiet;
vm_options.sandbox = opts.sandbox;
vm_options.module = opts.module;
+
vm_options.ops = &njs_console_ops;
vm_options.external = &njs_console;
diff -r d7a0eb59a7e7 -r 802fe99c8881 njs/test/njs_expect_test.exp
--- a/njs/test/njs_expect_test.exp Sun Apr 07 14:26:13 2019 +0800
+++ b/njs/test/njs_expect_test.exp Fri Apr 12 20:48:44 2019 +0300
@@ -715,5 +715,8 @@ njs_test {
"12\r\n"}
} "-p njs/test/module/"
+njs_run "-q ./njs/test/module/normal.js" \
+ "SyntaxError: Cannot find module \"hash.js\" in 5"
+
njs_run "-p njs/test/module/libs/ -d ./njs/test/module/normal.js" \
"passed!"
More information about the nginx-devel
mailing list