ci: fix failing vweb test, increase timeout for vweb_test_server.v, add VWEB_LOGFILE
parent
01e098aa77
commit
d912ff165b
|
@ -7,8 +7,9 @@ import io
|
|||
|
||||
const (
|
||||
sport = 12380
|
||||
exit_after_time = 5000 // milliseconds
|
||||
exit_after_time = 7000 // milliseconds
|
||||
vexe = os.getenv('VEXE')
|
||||
vweb_logfile = os.getenv('VWEB_LOGFILE')
|
||||
vroot = os.dir(vexe)
|
||||
serverexe = os.join_path(os.cache_dir(), 'vweb_test_server.exe')
|
||||
tcp_r_timeout = 30 * time.second
|
||||
|
@ -30,7 +31,13 @@ fn test_a_simple_vweb_app_can_be_compiled() {
|
|||
}
|
||||
|
||||
fn test_a_simple_vweb_app_runs_in_the_background() {
|
||||
suffix := $if windows { '' } $else { ' > /dev/null &' }
|
||||
mut suffix := ''
|
||||
$if !windows {
|
||||
suffix = ' > /dev/null &'
|
||||
}
|
||||
if vweb_logfile != '' {
|
||||
suffix = ' 2>> $vweb_logfile >> $vweb_logfile &'
|
||||
}
|
||||
server_exec_cmd := '$serverexe $sport $exit_after_time $suffix'
|
||||
$if debug_net_socket_client ? {
|
||||
eprintln('running:\n$server_exec_cmd')
|
||||
|
@ -161,7 +168,7 @@ fn test_http_client_json_post() {
|
|||
json_for_ouser := json.encode(ouser)
|
||||
mut x := http.post_json('http://127.0.0.1:$sport/json_echo', json_for_ouser) or { panic(err) }
|
||||
$if debug_net_socket_client ? {
|
||||
eprintln('json response: $x')
|
||||
eprintln('/json_echo endpoint response: $x')
|
||||
}
|
||||
assert x.headers['Content-Type'] == 'application/json'
|
||||
assert x.text == json_for_ouser
|
||||
|
@ -170,7 +177,7 @@ fn test_http_client_json_post() {
|
|||
//
|
||||
x = http.post_json('http://127.0.0.1:$sport/json', json_for_ouser) or { panic(err) }
|
||||
$if debug_net_socket_client ? {
|
||||
eprintln('json response: $x')
|
||||
eprintln('/json endpoint response: $x')
|
||||
}
|
||||
assert x.headers['Content-Type'] == 'application/json'
|
||||
assert x.text == json_for_ouser
|
||||
|
|
|
@ -80,6 +80,7 @@ pub fn (mut app App) user_repo_settings(username string, repository string) vweb
|
|||
[post]
|
||||
['/json_echo']
|
||||
pub fn (mut app App) json_echo() vweb.Result {
|
||||
eprintln('>>>>> received http request at /json_echo is: $app.req')
|
||||
app.set_content_type(app.req.headers['Content-Type'])
|
||||
return app.ok(app.req.data)
|
||||
}
|
||||
|
@ -87,6 +88,7 @@ pub fn (mut app App) json_echo() vweb.Result {
|
|||
// Make sure [post] works without the path
|
||||
[post]
|
||||
pub fn (mut app App) json() vweb.Result {
|
||||
eprintln('>>>>> received http request at /json is: $app.req')
|
||||
app.set_content_type(app.req.headers['Content-Type'])
|
||||
return app.ok(app.req.data)
|
||||
}
|
||||
|
|
|
@ -275,10 +275,10 @@ fn handle_conn<T>(mut conn net.TcpConn, mut app T) {
|
|||
mut in_headers := true
|
||||
mut len := 0
|
||||
// for line in lines[1..] {
|
||||
for _ in 0 .. 100 {
|
||||
for lindex in 0 .. 100 {
|
||||
// println(j)
|
||||
line := reader.read_line() or {
|
||||
println('Failed read_line')
|
||||
println('Failed read_line $lindex')
|
||||
break
|
||||
}
|
||||
sline := strip(line)
|
||||
|
@ -419,7 +419,7 @@ fn handle_conn<T>(mut conn net.TcpConn, mut app T) {
|
|||
} else {
|
||||
route_words_a = attrs.filter(it.to_lower() != 'get').map(it[1..].split('/'))
|
||||
}
|
||||
if attrs.len == 0 {
|
||||
if attrs.len == 0 || (attrs.len == 1 && attrs[0][0] != `/`) {
|
||||
// No routing for this method. If it matches, call it and finish matching
|
||||
// since such methods have a priority.
|
||||
// For example URL `/register` matches route `/:user`, but `fn register()`
|
||||
|
|
Loading…
Reference in New Issue