diff js.t @ 1247:edf5a3c9e36a

Tests: added tests for js backtraces.
author Dmitry Volyntsev <xeioex@nginx.com>
date Mon, 20 Nov 2017 20:23:24 +0300
parents 4b0b10e39a08
children 3882f8f3b2bc
line wrap: on
line diff
--- 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');
 
 ###############################################################################