Skip to content

Commit 441c7f6

Browse files
committed
tests: re-enabled a test case for using ngx.re.match in init_by_lua*.
1 parent 28cf5ce commit 441c7f6

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

t/034-match.t

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use Test::Nginx::Socket::Lua;
99

1010
repeat_each(2);
1111

12-
plan tests => repeat_each() * (blocks() * 2 + 15);
12+
plan tests => repeat_each() * (blocks() * 2 + 16);
1313

1414
#no_diff();
1515
no_long_string();
@@ -1129,27 +1129,33 @@ failed to match
11291129
11301130
11311131
1132-
=== TEST 48: init_by_lua
1132+
=== TEST 48: init_by_lua_block
11331133
--- http_config
1134-
init_by_lua '
1135-
package.loaded.m = ngx.re.match("hello, 1234", "(\\\\d+)")
1136-
';
1134+
init_by_lua_block {
1135+
local m, err = ngx.re.match("hello, 1234", [[(\d+)]])
1136+
if not m then
1137+
ngx.log(ngx.ERR, "failed to match: ", err)
1138+
else
1139+
package.loaded.m = m
1140+
end
1141+
}
11371142
--- config
11381143
location /re {
1139-
content_by_lua '
1144+
content_by_lua_block {
11401145
local m = package.loaded.m
11411146
if m then
11421147
ngx.say(m[0])
11431148
else
11441149
ngx.say("not matched!")
11451150
end
1146-
';
1151+
}
11471152
}
11481153
--- request
11491154
GET /re
11501155
--- response_body
11511156
1234
1152-
--- SKIP
1157+
--- no_error_log
1158+
[error]
11531159
11541160
11551161

0 commit comments

Comments
 (0)