1- # vim:set ft= ts=4 sw=4 et:
2-
31use Test ::Nginx::Socket;
42use Cwd qw(cwd);
53
64plan tests => repeat_each() * (blocks() * 4 ) + 1 ;
75
86my $ pwd = cwd();
97
8+ $ ENV {TEST_NGINX_RESOLVER} = ' 8.8.8.8' ;
9+ $ ENV {TEST_COVERAGE} ||= 0 ;
10+
1011our $ HttpConfig = qq {
11- lua_package_path "$ pwd /lib/?.lua;;";
12+ lua_package_path "$ pwd /lib/?.lua;/usr/local/share/lua/5.1/?.lua; ;";
1213 error_log logs/error.log debug;
13- } ;
1414
15- $ ENV {TEST_NGINX_RESOLVER} = ' 8.8.8.8' ;
15+ init_by_lua_block {
16+ if $ ENV {TEST_COVERAGE} == 1 then
17+ jit. off()
18+ require (" luacov.runner" ). init()
19+ end
20+ }
21+ } ;
1622
1723no_long_string();
1824# no_diff();
@@ -35,7 +41,7 @@ __DATA__
3541
3642 ngx.status = res.status
3743 ngx.print(res:read_body())
38-
44+
3945 httpc:close()
4046 ' ;
4147 }
6773
6874 ngx.status = res.status
6975 ngx.print(res:read_body())
70-
76+
7177 httpc:close()
7278 ' ;
7379 }
9197 local http = require "resty.http"
9298 local httpc = http.new()
9399 httpc:connect("127.0.0.1", ngx.var.server_port)
94-
100+
95101 local res, err = httpc:request{
96102 path = "/b"
97103 }
98104
99105 ngx.status = res.status
100106 ngx.say(res.reason)
101107 ngx.print(res:read_body())
102-
108+
103109 httpc:close()
104110 ' ;
105111 }
128134 local http = require "resty.http"
129135 local httpc = http.new()
130136 httpc:connect("127.0.0.1", ngx.var.server_port)
131-
137+
132138 local res, err = httpc:request{
133139 path = "/b"
134140 }
135141
136142 ngx.status = res.status
137143 ngx.say(res.headers["X-Test"])
138-
144+
139145 httpc:close()
140146 ' ;
141147 }
@@ -162,7 +168,7 @@ x-value
162168 local http = require "resty.http"
163169 local httpc = http.new()
164170 httpc:connect("127.0.0.1", ngx.var.server_port)
165-
171+
166172 local res, err = httpc:request{
167173 query = {
168174 a = 1,
@@ -178,7 +184,7 @@ x-value
178184 end
179185
180186 ngx.print(res:read_body())
181-
187+
182188 httpc:close()
183189 ' ;
184190 }
@@ -207,7 +213,7 @@ X-Header-B: 2
207213 local http = require "resty.http"
208214 local httpc = http.new()
209215 httpc:connect("127.0.0.1", ngx.var.server_port)
210-
216+
211217 local res, err = httpc:request{
212218 method = "HEAD",
213219 path = "/b"
@@ -230,4 +236,3 @@ GET /a
230236-- - no_error_log
231237[error]
232238[warn ]
233-
0 commit comments