Skip to content

Commit bd53547

Browse files
committed
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.
1 parent 05d58a9 commit bd53547

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

stream_js.t

+15-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ stream {
109109
js_filter js_filter_except;
110110
proxy_pass 127.0.0.1:8090;
111111
}
112+
113+
server {
114+
listen 127.0.0.1:8093;
115+
js_preread js_preread_except;
116+
proxy_pass 127.0.0.1:8090;
117+
}
112118
}
113119
114120
EOF
@@ -181,14 +187,19 @@ $t->write_file('functions.js', <<EOF);
181187
res += '3';
182188
}
183189
190+
function js_preread_except(sess) {
191+
var fs = require('fs');
192+
fs.readFileSync();
193+
}
194+
184195
function js_filter_except(sess) {
185196
sess.a.a;
186197
}
187198
188199
EOF
189200

190201
$t->run_daemon(\&stream_daemon, port(8090));
191-
$t->try_run('no stream njs available')->plan(13);
202+
$t->try_run('no stream njs available')->plan(14);
192203
$t->waitforsocket('127.0.0.1:' . port(8090));
193204

194205
###############################################################################
@@ -208,10 +219,13 @@ is(stream('127.0.0.1:' . port(8088))->io('xyz'), 'xyz', 'js_preread');
208219
is(stream('127.0.0.1:' . port(8089))->io('x'), 'z', 'js_filter');
209220
is(stream('127.0.0.1:' . port(8091))->io('0'), '01233', 'handlers order');
210221
stream('127.0.0.1:' . port(8092))->io('x');
222+
stream('127.0.0.1:' . port(8093))->io('x');
211223

212224
$t->stop();
213225

214226
ok(index($t->read_file('error.log'), 'SEE-THIS') > 0, 'stream js log');
227+
ok(index($t->read_file('error.log'), 'at fs.readFileSync') > 0,
228+
'stream js_preread backtrace');
215229
ok(index($t->read_file('error.log'), 'at js_filter_except') > 0,
216230
'stream js_filter backtrace');
217231

0 commit comments

Comments
 (0)