From cd63d03f21ff214070533bf36a54fbc7640b6f36 Mon Sep 17 00:00:00 2001 From: spacewander Date: Thu, 19 Jul 2018 16:47:28 +0800 Subject: [PATCH] Test::Nginx::Socket::Lua::Stream: added support for TEST_NGINX_INIT_BY_LUA --- lib/Test/Nginx/Socket/Lua/Stream.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/Test/Nginx/Socket/Lua/Stream.pm b/lib/Test/Nginx/Socket/Lua/Stream.pm index c4d72dd1..135d5979 100644 --- a/lib/Test/Nginx/Socket/Lua/Stream.pm +++ b/lib/Test/Nginx/Socket/Lua/Stream.pm @@ -10,6 +10,14 @@ sub get_best_long_bracket_level ($); sub quote_as_lua_str ($); sub gen_data_file ($); +my $code = $ENV{TEST_NGINX_INIT_BY_LUA}; +my $escaped_code = ''; + +if ($code) { + ($escaped_code = $code) =~ s/\\/\\\\/g; + $escaped_code =~ s/['"]/\\$&/g; +} + my $port = $ENV{TEST_NGINX_STREAM_PORT} // ($ServerPort + 1); my $counter = 0; @@ -30,6 +38,18 @@ add_block_preprocessor(sub { $stream_server_config //= ''; $stream_config //= ''; + if ($code && $stream_config !~ /init_by_lua_file/) { + unless ($stream_config =~ + s{(?