From: Dmitry Volyntsev Date: Wed, 11 Nov 2026 00:48:58 +0000 (-0800) Subject: Tests: honor injected engines in QuickJS lifetime tests X-Git-Url: https://git.kaiwu.me/ngx_http_flv_module.html?a=commitdiff_plain;h=HEAD;p=njs.git Tests: honor injected engines in QuickJS lifetime tests Hardcoded QuickJS directives run these tests in the default njs pass and conflict with CI engine injection. Probe the selected engine and skip the QuickJS-specific checks when njs is active. Check both HTTP and stream engines for the GC test. Use an isolated probe module for the redirect test so probing does not change the source and destination visit counters. --- diff --git a/nginx/t/js_context_reuse_redirect.t b/nginx/t/js_context_reuse_redirect.t index 56f5e3c9..3c990656 100644 --- a/nginx/t/js_context_reuse_redirect.t +++ b/nginx/t/js_context_reuse_redirect.t @@ -37,7 +37,6 @@ events { http { %%TEST_GLOBALS_HTTP%% - js_engine qjs; js_context_reuse 4; js_context_reuse_max_size 64m; @@ -45,6 +44,12 @@ http { listen 127.0.0.1:8080; server_name localhost; + location = /engine { + js_context_reuse 0; + js_import test from engine.js; + js_content test.engine; + } + location = /source { js_import handler from source.js; js_content handler.content; @@ -59,6 +64,14 @@ http { EOF +$t->write_file('engine.js', <<'EOF'); + function engine(r) { + r.return(200, njs.engine); + } + + export default {engine}; +EOF + $t->write_file('source.js', <<'EOF'); let visits = 0; @@ -89,7 +102,10 @@ $t->write_file('destination.js', <<'EOF'); EOF -$t->try_run('no njs available')->plan(4); +$t->try_run('no njs available'); +plan(skip_all => 'QuickJS-specific context reuse tests') + if http_get('/engine') =~ /njs$/m; +$t->plan(4); ############################################################################### diff --git a/nginx/t/js_fetch_object_lifetime.t b/nginx/t/js_fetch_object_lifetime.t index c1d4fb22..65d6e62e 100644 --- a/nginx/t/js_fetch_object_lifetime.t +++ b/nginx/t/js_fetch_object_lifetime.t @@ -36,13 +36,16 @@ events { http { %%TEST_GLOBALS_HTTP%% - js_engine qjs; js_import test.js; server { listen 127.0.0.1:8080; server_name localhost; + location /engine { + js_content test.engine; + } + location /reuse { js_context_reuse 1; js_content test.reuse; @@ -67,6 +70,10 @@ my $p0 = port(8080); $t->write_file('test.js', <write_file('test.js', <try_run('no QuickJS support')->plan(11); +$t->try_run('no njs available'); +plan(skip_all => 'QuickJS-specific lifetime tests') + if http_get('/engine') =~ /njs$/m; +$t->plan(11); ############################################################################### diff --git a/nginx/t/js_qjs_gc_mark.t b/nginx/t/js_qjs_gc_mark.t index c1af9af3..a97ef980 100644 --- a/nginx/t/js_qjs_gc_mark.t +++ b/nginx/t/js_qjs_gc_mark.t @@ -36,7 +36,6 @@ events { http { %%TEST_GLOBALS_HTTP%% - js_engine qjs; js_context_reuse 0; js_import test.js; @@ -44,6 +43,10 @@ http { listen 127.0.0.1:8080; server_name localhost; + location /engine { + js_content test.engine; + } + location /cycle { js_content test.http_cycle; } @@ -65,7 +68,6 @@ http { stream { %%TEST_GLOBALS_STREAM%% - js_engine qjs; js_context_reuse 0; js_import test.js; @@ -74,11 +76,25 @@ stream { js_preread test.stream_cycle; return OK; } + + server { + listen 127.0.0.1:8082; + js_set $engine test.engine_name; + return $engine; + } } EOF $t->write_file('test.js', <<'EOF'); + function engine(r) { + r.return(200, njs.engine); + } + + function engine_name() { + return njs.engine; + } + function http_cycle(r) { r.args.request = r; r.return(200, 'ok'); @@ -107,11 +123,16 @@ $t->write_file('test.js', <<'EOF'); }); } - export default {http_cycle, request_body_cycle, response_body_cycle, + export default {engine, engine_name, http_cycle, + request_body_cycle, response_body_cycle, stream_cycle}; EOF -$t->try_run('no QuickJS support')->plan(4); +$t->try_run('no njs available'); +plan(skip_all => 'QuickJS-specific GC tests') + if http_get('/engine') =~ /njs$/m + || stream('127.0.0.1:' . port(8082))->read() =~ /njs$/; +$t->plan(4); ###############################################################################