@@ -5,6 +5,7 @@ repeat_each(2);
5
5
plan tests => repeat_each() * (blocks() * 2);
6
6
7
7
$ENV {TEST_NGINX_HTML_DIR } ||= html_dir();
8
+
8
9
my $html_dir = $ENV {TEST_NGINX_HTML_DIR };
9
10
my $http_config = <<_EOC_ ;
10
11
init_by_lua_block {
@@ -15,16 +16,15 @@ my $http_config = <<_EOC_;
15
16
}
16
17
http {
17
18
init_by_lua_block {
18
- -- if the code in the init_by_lua* is run, there
19
- -- will be a string contains the 'error'
20
19
ngx.log(ngx.ERR, "run init_by_lua")
21
20
}
22
21
}
23
22
]]
24
23
25
24
assert(os.execute("mkdir -p $html_dir /logs"))
25
+
26
26
local conf_file = "$html_dir /nginx.conf"
27
- local f, err = io.open(conf_file, 'w' )
27
+ local f, err = io.open(conf_file, "w" )
28
28
if not f then
29
29
ngx.log(ngx.ERR, err)
30
30
return
@@ -53,10 +53,9 @@ add_block_preprocessor(sub {
53
53
if (!defined $block -> request) {
54
54
$block -> set_value(" request" , " GET /t" );
55
55
}
56
-
57
56
});
58
57
59
- log_level(" debug " );
58
+ log_level(" warn " );
60
59
no_long_string();
61
60
run_tests();
62
61
@@ -76,7 +75,7 @@ __DATA__
76
75
return
77
76
end
78
77
79
- local out, err = p:read('*a' )
78
+ local out, err = p:read("*a" )
80
79
if not out then
81
80
ngx.log(ngx.ERR, err)
82
81
@@ -86,11 +85,11 @@ __DATA__
86
85
}
87
86
}
88
87
--- no_error_log eval
89
- qr/\[error\] .+ (?!:nginx.pid" failed \(2: No such file or directory\))$ /
88
+ qr/\[error\] .*? init_by_lua:\d+: run init_by_lua /
90
89
91
90
92
91
93
- === TEST 2: ensure init_by_lua* is not run when testing Nginx configuration
92
+ === TEST 2: init_by_lua* does not run when testing Nginx configuration
94
93
--- config
95
94
location = /t {
96
95
content_by_lua_block {
@@ -104,7 +103,7 @@ qr/\[error\] .+ (?!:nginx.pid" failed \(2: No such file or directory\))$/
104
103
return
105
104
end
106
105
107
- local out, err = p:read('*a' )
106
+ local out, err = p:read("*a" )
108
107
if not out then
109
108
ngx.log(ngx.ERR, err)
110
109
@@ -119,7 +118,7 @@ qr/\[error\] .+ (?!:nginx.pid" failed \(2: No such file or directory\))$/
119
118
return
120
119
end
121
120
122
- local out, err = p:read('*a' )
121
+ local out, err = p:read("*a" )
123
122
if not out then
124
123
ngx.log(ngx.ERR, err)
125
124
@@ -128,5 +127,5 @@ qr/\[error\] .+ (?!:nginx.pid" failed \(2: No such file or directory\))$/
128
127
end
129
128
}
130
129
}
131
- --- no_error_log
132
- [error]
130
+ --- no_error_log eval
131
+ qr/\ [error\] .*? init_by_lua:\d+: run init_by_lua/
0 commit comments