# HG changeset patch # User Dmitry Volyntsev # Date 1511198604 -10800 # Node ID edf5a3c9e36ab61ce6d93f5247a6234f1a9f5244 # Parent ebaa2c72879ddd7e64162ebd75af422e64b1894b Tests: added tests for js backtraces. diff --git a/js.t b/js.t --- a/js.t +++ b/js.t @@ -44,6 +44,7 @@ http { js_set $test_iarg test_iarg; js_set $test_var test_var; js_set $test_log test_log; + js_set $test_except test_except; js_include test.js; @@ -91,6 +92,10 @@ http { return 200 $test_log; } + location /req_except { + return 200 $test_except; + } + location /res_status { js_content status; } @@ -114,6 +119,10 @@ http { location /res_ihdr { js_content ihdr; } + + location /res_except { + js_content content_except; + } } } @@ -172,6 +181,11 @@ EOF req.log("SEE-THIS"); } + function test_except(req, res) { + var fs = require('fs'); + fs.readFileSync(); + } + function status(req, res) { res.status = 204; if (res.status != 204) @@ -240,9 +254,14 @@ EOF res.send(s); res.finish(); } + + function content_except(req, res) { + JSON.parse({}.a.a); + } + EOF -$t->try_run('no njs available')->plan(20); +$t->try_run('no njs available')->plan(22); ############################################################################### @@ -269,6 +288,9 @@ like(http_get('/res_hdr?foo=123&bar=copy like(http_get('/res_hdr?bar=empty'), qr/Bar: \x0d/, 'res.headers empty'); like(http_get('/res_ihdr?a=12&b=34'), qr/^1234$/m, 'res.headers iteration'); +http_get('/req_except'); +http_get('/res_except'); + TODO: { local $TODO = 'zero size buf in writer'; @@ -281,6 +303,10 @@ like(http_get('/res_ihdr'), qr/\x0d\x0a? $t->stop(); ok(index($t->read_file('error.log'), 'SEE-THIS') > 0, 'log js'); +ok(index($t->read_file('error.log'), 'at fs.readFileSync') > 0, + 'js_set backtrace'); +ok(index($t->read_file('error.log'), 'at JSON.parse') > 0, + 'js_content backtrace'); ############################################################################### diff --git a/stream_js.t b/stream_js.t --- a/stream_js.t +++ b/stream_js.t @@ -103,6 +103,12 @@ stream { js_filter js_filter_step; proxy_pass 127.0.0.1:8090; } + + server { + listen 127.0.0.1:8092; + js_filter js_filter_except; + proxy_pass 127.0.0.1:8090; + } } EOF @@ -174,10 +180,15 @@ EOF } res += '3'; } + + function js_filter_except(sess) { + sess.a.a; + } + EOF $t->run_daemon(\&stream_daemon, port(8090)); -$t->try_run('no stream njs available')->plan(12); +$t->try_run('no stream njs available')->plan(13); $t->waitforsocket('127.0.0.1:' . port(8090)); ############################################################################### @@ -196,10 +207,13 @@ is(stream('127.0.0.1:' . port(8087))->re is(stream('127.0.0.1:' . port(8088))->io('xyz'), 'xyz', 'js_preread'); is(stream('127.0.0.1:' . port(8089))->io('x'), 'z', 'js_filter'); is(stream('127.0.0.1:' . port(8091))->io('0'), '01233', 'handlers order'); +stream('127.0.0.1:' . port(8092))->io('x'); $t->stop(); ok(index($t->read_file('error.log'), 'SEE-THIS') > 0, 'stream js log'); +ok(index($t->read_file('error.log'), 'at js_filter_except') > 0, + 'stream js_filter backtrace'); ###############################################################################