# HG changeset patch # User Sergey Kandaurov # Date 1511259399 -10800 # Node ID 70192b1baf014504d89e5db4d8778772489348ce # Parent edf5a3c9e36ab61ce6d93f5247a6234f1a9f5244 Tests: added exception test to stream_js.t using 'require'. The stream js tests introduced in edf5a3c9e36a fail on njs 0.1.14. It doesn't currently provide an easy way to check its version, whilst we are obligated to gracefully handle such cases somehow. With such an addition of 'require', now the tests are skipped instead on the previous versions. diff --git a/stream_js.t b/stream_js.t --- a/stream_js.t +++ b/stream_js.t @@ -109,6 +109,12 @@ stream { js_filter js_filter_except; proxy_pass 127.0.0.1:8090; } + + server { + listen 127.0.0.1:8093; + js_preread js_preread_except; + proxy_pass 127.0.0.1:8090; + } } EOF @@ -181,6 +187,11 @@ EOF res += '3'; } + function js_preread_except(sess) { + var fs = require('fs'); + fs.readFileSync(); + } + function js_filter_except(sess) { sess.a.a; } @@ -188,7 +199,7 @@ EOF EOF $t->run_daemon(\&stream_daemon, port(8090)); -$t->try_run('no stream njs available')->plan(13); +$t->try_run('no stream njs available')->plan(14); $t->waitforsocket('127.0.0.1:' . port(8090)); ############################################################################### @@ -208,10 +219,13 @@ is(stream('127.0.0.1:' . port(8088))->io 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'); +stream('127.0.0.1:' . port(8093))->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 fs.readFileSync') > 0, + 'stream js_preread backtrace'); ok(index($t->read_file('error.log'), 'at js_filter_except') > 0, 'stream js_filter backtrace');