http server test, and also unignore http client test
This commit is contained in:
@@ -1,5 +1,21 @@
|
|||||||
:- module(http_open_hanging, [submit_request/0]).
|
% Server
|
||||||
|
:- use_module(library(process)).
|
||||||
|
:- use_module(library(iso_ext)).
|
||||||
|
:- use_module(library(os)).
|
||||||
|
|
||||||
|
server_start([Process,Out]) :-
|
||||||
|
getenv("PROLOG", Prolog),
|
||||||
|
process_create(Prolog,
|
||||||
|
["tests-pl/issue-http_open-hanging_server", "-t", "server"],
|
||||||
|
[process(Process), stdout(pipe(Out))]).
|
||||||
|
|
||||||
|
server_wait_start([_Process, Out]) :-
|
||||||
|
get_char(Out, _C).
|
||||||
|
|
||||||
|
server_stop([Process,_Out]) :-
|
||||||
|
process_kill(Process).
|
||||||
|
|
||||||
|
% Client
|
||||||
:- use_module(library(charsio)).
|
:- use_module(library(charsio)).
|
||||||
:- use_module(library(http/http_open)).
|
:- use_module(library(http/http_open)).
|
||||||
|
|
||||||
@@ -10,14 +26,21 @@ send_request :-
|
|||||||
request_headers([]),
|
request_headers([]),
|
||||||
headers(_)
|
headers(_)
|
||||||
],
|
],
|
||||||
http_open("https://scryer.pl", _Stream, Options),
|
http_open("http://localhost:8472", _Stream, Options),
|
||||||
write_term('received response with status code':StatusCode, []), nl.
|
write_term('received response with status code':StatusCode, []), nl.
|
||||||
|
|
||||||
main :-
|
main :-
|
||||||
|
setup_call_cleanup(
|
||||||
|
server_start(Server),
|
||||||
|
(
|
||||||
|
server_wait_start(Server),
|
||||||
send_request,
|
send_request,
|
||||||
send_request,
|
send_request,
|
||||||
send_request,
|
send_request,
|
||||||
send_request,
|
send_request,
|
||||||
send_request.
|
send_request
|
||||||
|
),
|
||||||
|
server_stop(Server)
|
||||||
|
).
|
||||||
|
|
||||||
:- initialization(main).
|
:- initialization(main).
|
||||||
8
tests-pl/issue-http_open-hanging_server.pl
Normal file
8
tests-pl/issue-http_open-hanging_server.pl
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
:- use_module(library(process)).
|
||||||
|
:- use_module(library(http/http_server)).
|
||||||
|
|
||||||
|
server :-
|
||||||
|
http_listen(8472, [get(/, hello)]).
|
||||||
|
|
||||||
|
hello(_Req, Res) :-
|
||||||
|
http_body(Res, text("Ok")).
|
||||||
@@ -155,12 +155,14 @@ fn issue_rename_file() {
|
|||||||
load_module_test("tests-pl/issue_rename_file.pl", "file_renamed");
|
load_module_test("tests-pl/issue_rename_file.pl", "file_renamed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[serial]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "http")]
|
#[cfg(feature = "http")]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[cfg_attr(miri, ignore = "it takes too long to run")]
|
#[cfg_attr(miri, ignore = "it takes too long to run")]
|
||||||
#[cfg_attr(not(miri), ignore = "flaky due to network requests")]
|
|
||||||
fn http_open_hanging() {
|
fn http_open_hanging() {
|
||||||
|
std::env::set_var("PROLOG", env!("CARGO_BIN_EXE_scryer-prolog"));
|
||||||
|
|
||||||
load_module_test_with_tokio_runtime(
|
load_module_test_with_tokio_runtime(
|
||||||
"tests-pl/issue-http_open-hanging.pl",
|
"tests-pl/issue-http_open-hanging.pl",
|
||||||
"received response with status code:200\nreceived response with status code:200\nreceived response with status code:200\nreceived response with status code:200\nreceived response with status code:200\n"
|
"received response with status code:200\nreceived response with status code:200\nreceived response with status code:200\nreceived response with status code:200\nreceived response with status code:200\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user