blib/lib/Test/Nginx/Socket/Lua.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 1 Podpod n/a totaltotal 0.0% 0 / 28 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
CRAP 2.0
1 package Test::Nginx::Socket::Lua;
2  
3 use Test::Nginx::Socket -Base;
4  
5 our $VERSION = '0.32';
6  
7 my $code = $ENV{TEST_NGINX_INIT_BY_LUA};
8  
9 if ($code) {
10 (my $escaped_code = $code) =~ s/\\/\\\\/g;
11 $escaped_code =~ s/['"]/\\$&/g;
12  
13 Test::Nginx::Socket::set_http_config_filter(sub {
14 my $config = shift;
15 if ($config =~ /init_by_lua_file/) {
16 return $config;
17 }
18 unless ($config =~ s{(?<!\# )(?<!\# )(?<!\#)init_by_lua\s*(['"])((?:\\.|.)*)\1\s*;}{init_by_lua $1$escaped_code$2$1;}s) {
19 unless ($config =~ s{(?<!\# )(?<!\# )(?<!\#)init_by_lua_block\s*\{}{init_by_lua_block \{ $code }s) {
20 $config .= "init_by_lua '$escaped_code';";
21 }
22 }
23 return $config;
24 });
25 }
26  
27 1;
28 __END__