Skip to content

Commit fd70edc

Browse files
authored
test(pkg): bring back timeout (#10761)
Signed-off-by: Rudi Grinberg <[email protected]> <!-- ps-id: d7a9413b-ee57-493f-bc88-5f323386ac42 -->
1 parent c4a6e84 commit fd70edc

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

test/blackbox-tests/test-cases/pkg/compute-checksums-when-missing.t

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ A file that will comprise the package source:
1515
$ echo "Hello, World!" > foo.txt
1616

1717
Run the server in the background:
18+
19+
We have some really slow tests here
20+
$ export DUNE_WEBSERVER_TIMEOUT=10
21+
1822
$ webserver_oneshot --content-file foo.txt --port-file port.txt &
1923
$ until test -f port.txt; do sleep 0.1; done
2024
$ PORT=$(cat port.txt)

test/http/http.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,23 @@ module Server = struct
3636
loop ()
3737
;;
3838

39+
let auto_shutdown_seconds =
40+
match Sys.getenv_opt "DUNE_WEBSERVER_TIMEOUT" with
41+
| None -> 5.
42+
| Some s -> Float.of_string s |> Option.value_exn
43+
;;
44+
3945
let accept t ~f =
40-
let descr, _sockaddr = Unix.accept ~cloexec:true t.sock in
46+
let descr, _sockaddr =
47+
let read_fds, _write_fds, _excpt_fds =
48+
Unix.select [ t.sock ] [] [] auto_shutdown_seconds
49+
in
50+
match read_fds with
51+
| _ :: _ -> Unix.accept ~cloexec:true t.sock
52+
| [] ->
53+
Format.eprintf "Exiting after timeout@.";
54+
failwith "timeout"
55+
in
4156
let out = Unix.out_channel_of_descr descr in
4257
let in_ = Unix.in_channel_of_descr descr in
4358
let session = in_, out in

0 commit comments

Comments
 (0)